Skip to content
Closed
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
19 changes: 13 additions & 6 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/AssetCachingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Playwright;
using Xunit;
Expand All @@ -22,7 +23,6 @@ public AssetCachingTests(ITestOutputHelper output, SharedBuildPerTestClassFixtur
}

[Fact, TestCategory("no-fingerprinting")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/122338")] // add it back to eng\testing\scenarios\BuildWasmAppsJobsList.txt
public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache()
{
var project = CopyTestAsset(
Expand All @@ -35,7 +35,9 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache()

(string projectDir, string output) = BlazorPublish(project, Configuration.Release, new PublishOptions(AssertAppBundle: false));

var counterLoaded = new TaskCompletionSource();
var firstCounterLoaded = new TaskCompletionSource();
var secondCounterLoaded = new TaskCompletionSource();
var loadCount = 0;
var wasmRequestRecorder = new WasmRequestRecorder();

var runOptions = new BlazorRunOptions(Configuration.Release)
Expand All @@ -45,23 +47,28 @@ public async Task BlazorApp_BasedOnFingerprinting_LoadsWasmAssetsFromCache()
OnConsoleMessage = (type, msg) =>
{
if (msg.Contains("Counter.OnAfterRender"))
counterLoaded.SetResult();
{
var count = Interlocked.Increment(ref loadCount);
if (count == 1)
firstCounterLoaded.SetResult();
else if (count == 2)
secondCounterLoaded.SetResult();
}
},
Test = async (page) =>
{
await counterLoaded.Task;
await firstCounterLoaded.Task;

// Check server request logs after the first load.
Assert.NotEmpty(wasmRequestRecorder.ResponseCodes);
Assert.All(wasmRequestRecorder.ResponseCodes, r => Assert.Equal(200, r.ResponseCode));

wasmRequestRecorder.ResponseCodes.Clear();
counterLoaded = new();

// Perform browser navigation to cause resource reload.
// We use the initial base URL because the test server is not configured for SPA routing.
await page.ReloadAsync();
await counterLoaded.Task;
await secondCounterLoaded.Task;

// Check server logs after the second load.
if (EnvironmentVariables.UseFingerprinting)
Expand Down
Loading