Skip to content

[browser] Clean up Wasm.Build.Tests #114993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 30, 2025
Merged
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
1 change: 0 additions & 1 deletion eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.DebugLevelTests
Wasm.Build.Tests.FingerprintingTests
Wasm.Build.Tests.PreloadingTests
3 changes: 1 addition & 2 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/AppsettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ public AppsettingsTests(ITestOutputHelper output, SharedBuildPerTestClassFixture
}

[Fact]
[ActiveIssue("https://github.com/dotnet/aspnetcore/issues/60536")]
public async Task FileInVfs()
{
Configuration config = Configuration.Debug;
ProjectInfo info = CreateWasmTemplateProject(Template.BlazorWasm, config, aot: false, "blazor", extraProperties: "<OverrideHtmlAssetPlaceholders>true</OverrideHtmlAssetPlaceholders>");
ProjectInfo info = CreateWasmTemplateProject(Template.BlazorWasm, config, aot: false, "blazor");
UpdateHomePage();
string projectDirectory = Path.GetDirectoryName(info.ProjectFilePath)!;
File.WriteAllText(Path.Combine(projectDirectory, "wwwroot", "appsettings.json"), $"{{ \"Id\": \"{info.ProjectName}\" }}");
Expand Down
19 changes: 0 additions & 19 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,4 @@ public void BugRegression_60479_WithRazorClassLib()

Assert.Contains(bootJson.resources.lazyAssembly.Keys, f => f.StartsWith(razorClassLibraryName));
}


[Fact]
public async Task TestOverrideHtmlAssetPlaceholders()
{
var config = Configuration.Release;
string extraProperties = "<OverrideHtmlAssetPlaceholders>true</OverrideHtmlAssetPlaceholders>";
ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.BlazorBasicTestApp, "blz_import_map_html", extraProperties: extraProperties);
UpdateFile(Path.Combine("wwwroot", "index.html"), new Dictionary<string, string> {
{ """<base href="/" />""", """<script type="importmap"></script> <base href="/" />""" }
});

BuildProject(info, config);
BrowserRunOptions runOptions = new(config, TestScenario: "DotnetRun");
await RunForBuildWithDotnetRun(runOptions);

PublishProject(info, config, new PublishOptions(UseCache: false));
await RunForPublishWithWebServer(runOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ public record AssertBundleOptions(
bool ExpectSymbolsFile = true,
bool AssertIcuAssets = true,
bool AssertSymbolsFile = true,
bool? ExpectDotnetJsFingerprinting = false
bool? ExpectDotnetJsFingerprinting = null
);
39 changes: 0 additions & 39 deletions src/mono/wasm/Wasm.Build.Tests/FingerprintingTests.cs

This file was deleted.

11 changes: 5 additions & 6 deletions src/mono/wasm/Wasm.Build.Tests/PreloadingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ public PreloadingTests(ITestOutputHelper output, SharedBuildPerTestClassFixture
[InlineData(false, true)]
[InlineData(true, false)]
[InlineData(true, true)]
public void PreloadAssets(bool isPublish, bool fingerprintAssets)
public void PreloadAssets(bool isPublish, bool fingerprintDotnetJs)
{
Configuration config = Configuration.Debug;
ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.WasmBasicTestApp, "PreloadAssets");

// TODO: AssertAppBundle doesn't with fingerprinted dotnet.js at the moment
string extraMSBuildArgs = $"-p:OverrideHtmlAssetPlaceholders=true -p:WasmFingerprintAssets={fingerprintAssets}";
string extraMSBuildArgs = $"-p:WasmFingerprintDotnetJs={fingerprintDotnetJs}";
if (isPublish)
PublishProject(info, config, new PublishOptions(ExtraMSBuildArgs: extraMSBuildArgs, AssertAppBundle: false));
PublishProject(info, config, new PublishOptions(ExtraMSBuildArgs: extraMSBuildArgs), wasmFingerprintDotnetJs: fingerprintDotnetJs);
else
BuildProject(info, config, new BuildOptions(ExtraMSBuildArgs: extraMSBuildArgs, AssertAppBundle: false));
BuildProject(info, config, new BuildOptions(ExtraMSBuildArgs: extraMSBuildArgs), wasmFingerprintDotnetJs: fingerprintDotnetJs);

string? indexHtmlPath = null;
if (isPublish)
Expand All @@ -52,7 +51,7 @@ public void PreloadAssets(bool isPublish, bool fingerprintAssets)
Assert.True(File.Exists(indexHtmlPath));
string indexHtmlContent = File.ReadAllText(indexHtmlPath);

if (fingerprintAssets)
if (fingerprintDotnetJs)
{
// Expect to find fingerprinted preload
Assert.Contains("<link href=\"_framework/dotnet", indexHtmlContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ protected override IReadOnlyDictionary<string, bool> GetAllKnownDotnetFilesToFin
{ "dotnet.diagnostics.js.map", false },
};

if (assertOptions.BuildOptions.BootConfigFileName?.EndsWith(".js") ?? false)
if ((assertOptions.BuildOptions.BootConfigFileName?.EndsWith(".js")) ?? false)
result[assertOptions.BuildOptions.BootConfigFileName] = true;

if (assertOptions.ExpectDotnetJsFingerprinting == false)
result["dotnet.js"] = false;

return result;
}

Expand Down
Loading