test(blazor): Add Playwright E2E tests for navigation breadcrumbs#4908
test(blazor): Add Playwright E2E tests for navigation breadcrumbs#4908bruno-garcia wants to merge 13 commits intomainfrom
Conversation
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features ✨
Dependencies ⬆️Deps
Other
🤖 This preview updates automatically when you update the PR. |
6e53bf5 to
be0139e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
navigationbreadcrumbs 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.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/SentryEnvelopeParser.cs
Outdated
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/NavigationBreadcrumbTests.cs
Outdated
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/NavigationBreadcrumbTests.cs
Outdated
Show resolved
Hide resolved
....PlaywrightTests.TestApp/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj
Outdated
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/BlazorWasmTestApp.cs
Outdated
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/NavigationBreadcrumbTests.cs
Show resolved
Hide resolved
Review Comments Summary
All actionable items have been addressed in commit |
jamescrosswell
left a comment
There was a problem hiding this comment.
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:
07c6608 to
6983ba1
Compare
|
Added a dedicated Playwright CI workflow in be5c367: It's lightweight — just .NET SDK + Chromium on |
Good catch: https://github.com/getsentry/sentry-dotnet/actions/runs/21975465099/job/63486133424?pr=4908 |
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>
be5c367 to
16c7fe3
Compare
There was a problem hiding this comment.
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.
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/SentryEnvelopeParser.cs
Outdated
Show resolved
Hide resolved
....PlaywrightTests.TestApp/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj
Outdated
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/BlazorWasmTestApp.cs
Outdated
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/BlazorWasmTestApp.cs
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/BlazorWasmTestApp.cs
Show resolved
Hide resolved
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/NavigationBreadcrumbTests.cs
Outdated
Show resolved
Hide resolved
- 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>
Review feedback addressedAll review comments from @Flash0ver and automated reviewers have been addressed in 55bc42d: Fixes:
Acknowledged (no code change needed):
|
Summary
How it works
PlaywrightTests.TestApp) with a fake DSN (https://key@o0.ingest.sentry.io/0) serves as the test target/→/second→/trigger-captureSentrySdk.CaptureMessage("playwright-test")fires, sending a Sentry envelope containing breadcrumbspage.RouteAsync()intercepts the envelope POST before it hits the networknavigationbreadcrumbs presentfrom: "/",to: "/second"from: "/second",to: "/trigger-capture"New projects
test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/Test plan
NavigationBreadcrumbTests.Navigation_CreatesBreadcrumbs_WithCorrectFromAndTopassesRunning 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