Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@
looks the file up by its path with separators replaced by dots. -->
<EmbeddedResource Include="_static/.vite/manifest.json" LogicalName="Elastic.Documentation.Site._static..vite.manifest.json" Watch="false" />
<EmbeddedResource Include="_static/**/*.js" Watch="false" />
<EmbeddedResource Include="_static/**/*.js.map" Watch="false" Condition="'$(Configuration)' == 'Debug'" />
<EmbeddedResource Include="_static/**/*.js.map" Watch="false" />
<EmbeddedResource Include="_static/**/*.css" Watch="false" />
<EmbeddedResource Include="_static/**/*.css.map" Watch="false" Condition="'$(Configuration)' == 'Debug'" />
<EmbeddedResource Include="_static/**/*.css.map" Watch="false" />
<EmbeddedResource Include="_static/**/*.svg" Watch="false" />
<EmbeddedResource Include="_static/**/*.png" Watch="false" />
<EmbeddedResource Include="_static/**/*.ttf" Watch="false" />
Expand Down
44 changes: 44 additions & 0 deletions tests/Elastic.Markdown.Tests/EmbeddedStaticAssetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using AwesomeAssertions;
using Elastic.Documentation.Configuration;
using Elastic.Documentation.Site.FileProviders;

namespace Elastic.Markdown.Tests;

public class EmbeddedStaticAssetTests
{
private static readonly string[] ResourceNames = typeof(EmbeddedOrPhysicalFileProvider).Assembly.GetManifestResourceNames();

[Test]
public void EmbedGeneratedAssets_includes_source_maps_unconditionally()
{
var mapEmbeds = File
.ReadAllLines(SiteCsprojPath())
.Where(
static line => line.Contains("EmbeddedResource", StringComparison.Ordinal) &&
(line.Contains("*.js.map", StringComparison.Ordinal) || line.Contains("*.css.map", StringComparison.Ordinal))
)
.ToArray();

mapEmbeds.Should().HaveCount(2);
mapEmbeds.Should().NotContain(static line => line.Contains("Condition", StringComparison.Ordinal));
}

[Test]
public void NpmRunBuild_deletes_stale_vite_outputs_inside_the_skippable_target()
{
var csproj = File.ReadAllText(SiteCsprojPath());
csproj.Should().Contain("""Include="_static/main-*" """);
csproj.Should().NotContain("CleanOldHashedAssets");
Comment on lines +33 to +35

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

This cleanup test passes even if the Delete task is removed or cleanup is moved outside NpmRunBuild: it only checks that a glob appears somewhere in the project and that one target name is absent. It therefore does not protect the stale-map cleanup or incremental-build safety that this test claims to cover. Add coverage that verifies stale bundles and maps are deleted when the target runs and current outputs survive when it is skipped.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

}

[Test]
public void Site_assembly_embeds_js_source_maps() =>
ResourceNames.Should().Contain(static n => n.EndsWith(".js.map", StringComparison.Ordinal));

private static string SiteCsprojPath() =>
Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", "Elastic.Documentation.Site", "Elastic.Documentation.Site.csproj");
}
Loading