Skip to content

Fix local WASM Components E2E tests returning 404 - #67903

Merged
ilonatommy merged 3 commits into
dotnet:mainfrom
ilonatommy:ilonatommy/fix-wasm-e2e-gateway-pathbase
Jul 20, 2026
Merged

ilonatommy merged 3 commits into
dotnet:mainfrom
ilonatommy:ilonatommy/fix-wasm-e2e-gateway-pathbase

Conversation

@ilonatommy

@ilonatommy ilonatommy commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Problem

Running the Blazor WebAssembly (client-mode) Components E2E tests locally in Debug (non-trimmed) fails before the app even boots. The browser navigates to  /subdir, the host returns 404, the Blazor app never loads, and the test fails with:

OpenQA.Selenium.BrowserAssertFailedException : Xunit.Sdk.NotEmptyException: Assert.NotEmpty() Failure: Collection was empty
Encountered browser errors
[Severe] chrome-error://chromewebdata/ - Failed to load resource: the server responded with a status of 404 ()

Each affected test also burns its full ~1-minute long-running timeout before failing.

Why it happened

Introduced in #65982.
Locally (non-trimmed), BlazorWasmTestAppFixture hosts BasicTestApp through the Blazor Gateway (BlazorGateway.BuildWebHost). Two things were misconfigured for that path:

  1. Path base never applied. The fixture passed the app's path base as --pathbase, but the gateway binds its options from the Gateway configuration section (BlazorGatewayOptions.SectionName = "Gateway", read via Configuration.GetSection("Gateway").Bind(options)). --pathbase populates the top-level pathbase key, which nothing reads (so  options.PathBase stayed null and app.UsePathBase("/subdir") was never called).
  2. No SPA fallback. The gateway serves assets via  MapStaticAssets  from the endpoints manifest, which has no client-side-routing fallback. So requests under  /subdir  had no  index.html  to fall back to and 404'd.

This only affects local Debug runs. On CI (TestTrimmedApps == true) the fixture takes a different code path (CreateStaticWebHost  ->  StaticSiteStartup) that already calls UsePathBase and MapFallbackToFile("index.html"), so CI was unaffected. That's why the breakage was invisible in CI and only bit local development.

The non-trimmed local E2E runs host BasicTestApp via the Blazor Gateway. The fixture passed --pathbase, but the gateway only binds Gateway:PathBase, so UsePathBase was never applied and the gateway's MapStaticAssets had no SPA fallback. Navigating to /subdir returned 404 and the browser-error assertion failed. Pass --Gateway:PathBase and enable StaticWebAssetSpaFallbackEnabled so the gateway serves index.html under the path base.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 343bb4ce-5611-47e2-90e3-d5485623d145
@ilonatommy ilonatommy added this to the 11.0-preview7 milestone Jul 20, 2026
@ilonatommy ilonatommy self-assigned this Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 10:59
@ilonatommy
ilonatommy requested a review from a team as a code owner July 20, 2026 10:59
@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Jul 20, 2026
@ilonatommy
ilonatommy enabled auto-merge (squash) July 20, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a local-only failure in Blazor WebAssembly (client-mode) Components E2E tests where navigating under /subdir returned 404 before the app could boot when hosted via the Blazor Gateway in non-trimmed Debug runs.

Changes:

  • Pass the Gateway path base via the correct configuration key (Gateway:PathBase) so UsePathBase is applied.
  • Enable SPA fallback generation in the static web assets endpoints manifest so client-side routes under the path base fall back to index.html instead of 404ing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj Enables SPA fallback in the static web assets endpoints manifest for BasicTestApp so client-side routes resolve under the Gateway host.
src/Components/test/E2ETest/Infrastructure/ServerFixtures/BlazorWasmTestAppFixture.cs Fixes local Gateway hosting by binding the path base from the expected Gateway configuration section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants