Skip to content

test(blazor): Add Playwright E2E tests for navigation breadcrumbs#4908

Open
bruno-garcia wants to merge 13 commits intomainfrom
feat/blazor-wasm-playwright-tests
Open

test(blazor): Add Playwright E2E tests for navigation breadcrumbs#4908
bruno-garcia wants to merge 13 commits intomainfrom
feat/blazor-wasm-playwright-tests

Conversation

@bruno-garcia
Copy link
Member

Summary

How it works

  1. A minimal Blazor WASM test host app (PlaywrightTests.TestApp) with a fake DSN (https://key@o0.ingest.sentry.io/0) serves as the test target
  2. The Playwright test navigates: //second/trigger-capture
  3. On the trigger page, SentrySdk.CaptureMessage("playwright-test") fires, sending a Sentry envelope containing breadcrumbs
  4. Playwright's page.RouteAsync() intercepts the envelope POST before it hits the network
  5. The test parses the envelope and asserts:
    • Two navigation breadcrumbs present
    • First: from: "/", to: "/second"
    • Second: from: "/second", to: "/trigger-capture"

New projects

Project Purpose
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/ Minimal Blazor WASM app with 3 pages and a fake DSN
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/ xUnit + Playwright test project

Test plan

  • Test host app builds (net10.0)
  • Playwright test project builds (net10.0)
  • NavigationBreadcrumbTests.Navigation_CreatesBreadcrumbs_WithCorrectFromAndTo passes

Running locally

dotnet build test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/
pwsh test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/bin/Debug/net10.0/playwright.ps1 install chromium
dotnet test test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/

🤖 Generated with Claude Code

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features ✨

  • feat(blazor): Add navigation breadcrumbs for Blazor WebAssembly by bruno-garcia in #4907

Dependencies ⬆️

Deps

  • chore(deps): update Java SDK to v8.32.0 by github-actions in #4843
  • chore(deps): add protobuf-javalite 3.25.8 dependency on Android by github-actions in #4843
  • chore(deps): Bumped Xamarin.AndroidX.Lifecycle.Common.Java8 and CommunityToolkit.Mvvm to 2.2.20 and 8.4.0 by jamescrosswell in #4876

Other

  • test(blazor): Add Playwright E2E tests for navigation breadcrumbs by bruno-garcia in #4908
  • ci: Skip device tests for non-mobile PRs by bruno-garcia in #4909

🤖 This preview updates automatically when you update the PR.

@bruno-garcia bruno-garcia force-pushed the feat/blazor-wasm-playwright-tests branch from 6e53bf5 to be0139e Compare February 10, 2026 04:18
@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.87%. Comparing base (14ec84f) to head (55bc42d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4908   +/-   ##
=======================================
  Coverage   73.86%   73.87%           
=======================================
  Files         496      496           
  Lines       17921    17927    +6     
  Branches     3510     3511    +1     
=======================================
+ Hits        13237    13243    +6     
  Misses       3824     3824           
  Partials      860      860           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruno-garcia bruno-garcia marked this pull request as ready for review February 10, 2026 05:57
Copilot AI review requested due to automatic review settings February 10, 2026 05:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Playwright-based end-to-end coverage for the new Blazor WebAssembly navigation breadcrumb integration by standing up a minimal WASM host app and intercepting Sentry envelope posts to assert breadcrumb contents.

Changes:

  • Introduce a minimal Blazor WASM test host app used as the Playwright target.
  • Add an xUnit + Playwright test project that navigates across pages and asserts navigation breadcrumbs in the intercepted Sentry envelope.
  • Update solution filters/solutions to include/exclude the new Playwright projects appropriately.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/SentryEnvelopeParser.cs Adds helper to extract event JSON from an envelope payload.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj New Playwright test project definition.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/NavigationBreadcrumbTests.cs E2E test asserting navigation breadcrumbs.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/BlazorWasmTestApp.cs Harness to start/stop the Blazor WASM test host via dotnet run.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/wwwroot/index.html WASM host page for the test app.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/_Imports.razor Shared imports for test app components.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Shared/MainLayout.razor Minimal layout for routing.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj New Blazor WASM test host project definition.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Program.cs Configures Sentry with a fake DSN and runs the WASM host.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Pages/TriggerCapture.razor Page that triggers SentrySdk.CaptureMessage to emit an envelope.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Pages/Second.razor Intermediate navigation page for breadcrumb generation.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Pages/Index.razor Root page with navigation link to /second.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/App.razor Router setup for the minimal test app.
scripts/generate-solution-filters-config.yaml Adds a playwrightTests exclusion group to CI solution filter generation.
SentryNoSamples.slnf Includes the new Playwright test project in this solution filter.
SentryNoMobile.slnf Includes both the test app + Playwright test project in this solution filter.
SentryAspNetCore.slnf Includes both the test app + Playwright test project in this solution filter.
Sentry.sln Adds the two new projects to the main solution.
.generated.NoMobile.sln Adds the two new projects to the generated no-mobile solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bruno-garcia
Copy link
Member Author

Review Comments Summary

# File Reviewer Comment Outcome
1 SentryEnvelopeParser.cs Copilot JsonDocument leak — Parse() result never disposed, leaking pooled buffers Fixed — Added using on JsonDocument.Parse() and return RootElement.Clone()
2 NavigationBreadcrumbTests.cs Copilot DisposeAsync crashes on null if InitializeAsync fails partway, leaking the external process Fixed — Made _playwright and _browser nullable, added null checks in DisposeAsync
3 NavigationBreadcrumbTests.cs Copilot IPage from NewPageAsync() never disposed/closed, leaking browser resources Fixed — Added await page.CloseAsync() at end of test (IPage doesn't implement IAsyncDisposable so await using isn't available)
4 TestApp.csproj Copilot TestApp inherits test-only PackageReferences from test/Directory.Build.props (xUnit, NSubstitute, etc.) No change — The inherited packages don't affect the WASM app at runtime (tree-shaken by the linker). Conditionalizing them would require modifying shared test infrastructure for a minor concern.
5 BlazorWasmTestApp.cs Copilot Disposable TcpListener not disposed Fixed — Added using keyword
6 SentryNoSamples.slnf cursor[bot] TestApp project missing from SentryNoSamples.slnf filter No change — The .slnf files are auto-generated by scripts/generate-solution-filters.ps1. The TestApp is intentionally excluded from SentryNoSamples because it's not needed for the standard CI build filter. MSBuild resolves ProjectReference dependencies automatically regardless of filter membership.
7 NavigationBreadcrumbTests.cs cursor[bot] Duplicate of #2DisposeAsync crashes on null, leaking external process Fixed — Same fix as #2 (already resolved)

All actionable items have been addressed in commit 07c6608.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

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

Can we run these on CI? Do we want to?

btw: the sln files no longer exist... so will need to add this to the slnx instead:

@bruno-garcia bruno-garcia force-pushed the feat/blazor-wasm-playwright-tests branch from 07c6608 to 6983ba1 Compare February 13, 2026 04:01
@bruno-garcia
Copy link
Member Author

Added a dedicated Playwright CI workflow in be5c367: .github/workflows/playwright-blazor-wasm.yml

It's lightweight — just .NET SDK + Chromium on ubuntu-latest (no Java, Android SDK, Mono, etc. from the shared environment action). Only triggers on PRs touching Blazor WASM, core SDK, or ASP.NET Core code.

@bruno-garcia
Copy link
Member Author

Can we run these on CI? Do we want to?

btw: the sln files no longer exist... so will need to add this to the slnx instead:

Good catch: https://github.com/getsentry/sentry-dotnet/actions/runs/21975465099/job/63486133424?pr=4908

Base automatically changed from feat/blazor-wasm-nav-breadcrumbs to main February 13, 2026 15:16
jamescrosswell and others added 12 commits February 13, 2026 10:27
Add browser-level tests using Playwright to verify that navigation
breadcrumbs are created end-to-end in a real Blazor WebAssembly app.

The test navigates between pages, triggers SentrySdk.CaptureMessage,
intercepts the Sentry envelope via Playwright's route API, and verifies
the event contains navigation breadcrumbs with correct from/to paths.

Includes a minimal Blazor WASM test host app with a fake DSN.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI environments can be slow; 60s was not enough.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eout

- Capture stdout/stderr into a queue for diagnostics
- Detect early process exit and fail immediately with logs
- Increase timeout to 180s for slow CI environments
- Include process output in both error and timeout messages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Blazor WASM DevServer needs the staticwebassets.endpoints.json
manifest which is only generated during build of the project itself,
not when built from the solution level. Letting dotnet run build the
project ensures this manifest is generated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI doesn't have Playwright browsers pre-installed. Call
Program.Main(["install", "chromium"]) in InitializeAsync so the
test is self-contained. The download is cached, so subsequent
runs are a no-op.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Playwright requires browser binaries and system dependencies that
aren't available across all CI platforms (ARM64, musl). Exclude
the PlaywrightTests projects from all CI build filters. They remain
in local dev filters (SentryAspNetCore, SentryNoMobile, etc.)
and can be run manually or in a dedicated CI job later.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix JsonDocument leak: clone RootElement and dispose document
- Make _playwright/_browser nullable, null-check in DisposeAsync
- Close page after test to avoid resource leak
- Use using on TcpListener

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The base branch migrated from .sln to .slnx format. Update the new
solution files to include the Playwright test projects and fix
backslash path separators.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a lightweight CI workflow that runs the Blazor WebAssembly
Playwright tests. Only triggers on PRs that touch Blazor WASM,
core SDK, or ASP.NET Core code.

Uses a minimal setup (just .NET SDK + Chromium) instead of the
heavy shared environment action that installs Java, Android SDK,
Mono, etc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bruno-garcia bruno-garcia force-pushed the feat/blazor-wasm-playwright-tests branch from be5c367 to 16c7fe3 Compare February 13, 2026 15:31
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@bruno-garcia bruno-garcia enabled auto-merge (squash) February 13, 2026 17:04
- Add src/*, test/*, test/Sentry.Testing/** to CI workflow paths (Flash0ver)
- Use --configuration Release in dotnet run to match CI build (Flash0ver)
- Add empty Directory.Build.props/targets for TestApp to stop inheriting
  test-specific packages, removing Using Remove hacks (Flash0ver)
- Remove redundant ! null-forgiving on Nullable<T> (Flash0ver)
- Remove StringSplitOptions.RemoveEmptyEntries from envelope parser to
  preserve header/payload pair alignment (cursor bugbot)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bruno-garcia
Copy link
Member Author

Review feedback addressed

All review comments from @Flash0ver and automated reviewers have been addressed in 55bc42d:

Fixes:

  • CI workflow paths — added src/*, test/*, and test/Sentry.Testing/** so changes to Directory.Build.props/targets at the src/ and test/ levels trigger the workflow
  • Configuration mismatchdotnet run now passes --configuration Release to match the CI build, avoiding unnecessary rebuilds
  • TestApp build isolation — added empty Directory.Build.props and Directory.Build.targets (consistent with SingleFileTestApp) to stop inheriting test-specific packages/usings, replacing the <Using Remove> workarounds
  • Nullable<T> access — removed redundant ! null-forgiving operator on eventPayload.Value
  • Envelope parser — removed StringSplitOptions.RemoveEmptyEntries to preserve header/payload pair alignment

Acknowledged (no code change needed):

  • 180s startup timeout — fine as a starting point; with matching Release config, dotnet run skips rebuild so actual wait is much shorter
  • Parallel test synchronization — will address when we add more tests

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants