Skip to content

Commit 23e7e44

Browse files
bruno-garciajamescrosswellclaude
authored
test(blazor): Add Playwright E2E tests for navigation breadcrumbs (#4908)
* Update solution filters * Fixing my mess * test(blazor): Add Playwright E2E tests for navigation breadcrumbs 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> * Add Playwright test projects to solution and regenerate filters Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Increase Blazor WASM test app startup timeout to 120s CI environments can be slow; 60s was not enough. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Improve test app startup: capture output, detect early exit, 180s timeout - 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> * Remove --no-build from dotnet run for test app 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> * Install Playwright Chromium in test setup 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> * Exclude Playwright tests from CI solution filters 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> * Address PR review comments - 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> * Add Playwright test projects to SLNX solution files 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> * ci: Add Playwright workflow for Blazor WASM E2E tests 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> --------- Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 66923ef commit 23e7e44

22 files changed

Lines changed: 439 additions & 2 deletions

.generated.NoMobile.slnx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@
179179
<Project Path="test/Sentry.Tests/Sentry.Tests.csproj" />
180180
<Project Path="test/Sentry.TrimTest/Sentry.TrimTest.csproj" />
181181
<Project Path="test/SingleFileTestApp/SingleFileTestApp.csproj" />
182-
<Project Path="test\Sentry.AspNetCore.Blazor.WebAssembly.Tests\Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj" />
182+
<Project Path="test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj" />
183+
<Project Path="test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj" />
184+
<Project Path="test/Sentry.AspNetCore.Blazor.WebAssembly.Tests/Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj" />
183185
</Folder>
184186
</Solution>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Blazor WASM Playwright Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
pull_request:
9+
paths:
10+
- 'src/*'
11+
- 'src/Sentry/**'
12+
- 'src/Sentry.AspNetCore/**'
13+
- 'src/Sentry.AspNetCore.Blazor.WebAssembly/**'
14+
- 'src/Sentry.Extensions.Logging/**'
15+
- 'test/*'
16+
- 'test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/**'
17+
- 'test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/**'
18+
- 'test/Sentry.Testing/**'
19+
- 'global.json'
20+
- 'Directory.Build.props'
21+
- 'Directory.Build.targets'
22+
- 'nuget.config'
23+
- '.github/workflows/playwright-blazor-wasm.yml'
24+
workflow_dispatch:
25+
26+
jobs:
27+
playwright:
28+
name: Blazor WASM E2E
29+
runs-on: ubuntu-latest
30+
env:
31+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
32+
DOTNET_NOLOGO: 1
33+
steps:
34+
- name: Cancel Previous Runs
35+
if: github.ref_name != 'main' && !startsWith(github.ref_name, 'release/')
36+
uses: styfle/cancel-workflow-action@3155a141048f8f89c06b4cdae32e7853e97536bc # 0.13.0
37+
38+
- name: Checkout
39+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
40+
with:
41+
submodules: recursive
42+
43+
- name: Install .NET SDK
44+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
45+
with:
46+
global-json-file: global.json
47+
48+
- name: Install .NET Workloads
49+
run: dotnet workload restore --temp-dir "${{ runner.temp }}" --skip-sign-check
50+
51+
- name: Build
52+
run: dotnet build test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests -c Release
53+
54+
- name: Install Playwright Browsers
55+
run: pwsh test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/bin/Release/net10.0/playwright.ps1 install chromium --with-deps
56+
57+
- name: Run Playwright Tests
58+
run: dotnet test test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests -c Release --no-build --logger "trx;LogFileName=results.trx"
59+
60+
- name: Upload Test Results
61+
if: failure()
62+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
63+
with:
64+
name: playwright-blazor-wasm-results
65+
path: test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/TestResults/

Sentry.slnx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@
179179
<Project Path="test/Sentry.Tests/Sentry.Tests.csproj" />
180180
<Project Path="test/Sentry.TrimTest/Sentry.TrimTest.csproj" />
181181
<Project Path="test/SingleFileTestApp/SingleFileTestApp.csproj" />
182-
<Project Path="test\Sentry.AspNetCore.Blazor.WebAssembly.Tests\Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj" />
182+
<Project Path="test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj" />
183+
<Project Path="test/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp/Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj" />
184+
<Project Path="test/Sentry.AspNetCore.Blazor.WebAssembly.Tests/Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj" />
183185
</Folder>
184186
</Solution>

SentryAspNetCore.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
2525
"src\\Sentry\\Sentry.csproj",
2626
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
27+
"test\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj",
28+
"test\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj",
2729
"test\\Sentry.AspNetCore.Blazor.WebAssembly.Tests\\Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj",
2830
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
2931
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",

SentryNoMobile.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"src\\Sentry\\Sentry.csproj",
5353
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
5454
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
55+
"test\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.TestApp.csproj",
56+
"test\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj",
5557
"test\\Sentry.AspNetCore.Blazor.WebAssembly.Tests\\Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj",
5658
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
5759
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",

SentryNoSamples.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
2828
"test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj",
2929
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
30+
"test\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests\\Sentry.AspNetCore.Blazor.WebAssembly.PlaywrightTests.csproj",
3031
"test\\Sentry.AspNetCore.Blazor.WebAssembly.Tests\\Sentry.AspNetCore.Blazor.WebAssembly.Tests.csproj",
3132
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
3233
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",

scripts/generate-solution-filters-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ groupConfigs:
3232
trimTests:
3333
- "**/Sentry.TrimTest.csproj"
3434
- "**/Sentry.MauiTrimTest.csproj"
35+
playwrightTests:
36+
- "**/*PlaywrightTests*.csproj"
3537
mobileOnly:
3638
- "**/*Android*.csproj"
3739
- "**/*Ios*.csproj"
@@ -50,6 +52,7 @@ filterConfigs:
5052
- "windowsOnly"
5153
- "artefacts"
5254
- "trimTests"
55+
- "playwrightTests"
5356
patterns:
5457
- "**/*AndroidTestApp.csproj"
5558
- "**/*DeviceTests*.csproj"
@@ -67,6 +70,7 @@ filterConfigs:
6770
- "artefacts"
6871
- "trimTests"
6972
- "mobileOnly"
73+
- "playwrightTests"
7074
patterns:
7175
- "**/*Android*.csproj"
7276
- "**/*DeviceTests*.csproj"
@@ -83,6 +87,7 @@ filterConfigs:
8387
groups:
8488
- "artefacts"
8589
- "trimTests"
90+
- "playwrightTests"
8691
patterns:
8792
- "**/*AndroidTestApp.csproj"
8893
- "**/*DeviceTests*.csproj"
@@ -100,6 +105,7 @@ filterConfigs:
100105
- "macOnly"
101106
- "artefacts"
102107
- "trimTests"
108+
- "playwrightTests"
103109
patterns:
104110
- "**/*AndroidTestApp.csproj"
105111
# AssemblyReader tests are flaky on Windows: https://github.com/getsentry/sentry-dotnet/issues/4091
@@ -121,6 +127,7 @@ filterConfigs:
121127
- "macOnly"
122128
- "artefacts"
123129
- "trimTests"
130+
- "playwrightTests"
124131
patterns:
125132
- "**/*AndroidTestApp.csproj"
126133
# AssemblyReader tests are flaky on Windows: https://github.com/getsentry/sentry-dotnet/issues/4091
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(Shared.MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<p>Not found</p>
7+
</NotFound>
8+
</Router>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<!-- Stop inheriting test-specific props from test/Directory.Build.props -->
3+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<!-- Stop inheriting test-specific targets from test/Directory.Build.targets -->
3+
</Project>

0 commit comments

Comments
 (0)