Add E2E tests for webworker template#65405
Open
ilonatommy wants to merge 8 commits intodotnet:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive end-to-end browser tests for the webworker template introduced in PR #65037. The tests validate the webworker template by creating a Blazor WASM host application, adding a webworker library, and using Playwright to exercise worker functionality through the browser UI.
Changes:
- Added new E2E test class with three test methods validating worker initialization, method invocation, error handling, and disposal
- Created test assets including a Razor test page and JSExport worker methods for exercising worker functionality
- Updated project file to include test assets with proper copy and compilation exclusions
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| WebWorkerTemplateE2ETest.cs | New test class implementing IAsyncLifetime to create host project once, then run three tests validating worker operations via Playwright |
| TestAssets/WebWorker/WebWorkerTest.razor | Blazor test page with UI buttons to initialize worker and test Add, Echo, JSON, error handling, and disposal operations |
| TestAssets/WebWorker/TestWorkerMethods.cs | JSExport methods (Add, Echo, GetPersonJson, ThrowError, plus unused IsEven, Divide, Concat) for worker testing |
| Templates.Blazor.Tests.csproj | Added ItemGroup to copy test assets to output and exclude them from compilation |
Comments suppressed due to low confidence (1)
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateE2ETest.cs:283
- The string interpolation in WaitForFunctionAsync creates a potential security vulnerability if selector or expectedText contain single quotes. The JavaScript code is constructed using string interpolation which could break if the values contain special characters. Consider using Playwright's more robust waitForSelector with text matching, or properly escape the values before interpolation.
src/ProjectTemplates/test/Templates.Blazor.Tests/TestAssets/WebWorker/TestWorkerMethods.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateE2ETest.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateE2ETest.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateE2ETest.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateE2ETest.cs
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/test/Templates.Blazor.Tests/WebWorkerTemplateE2ETest.cs
Show resolved
Hide resolved
This was referenced Feb 12, 2026
Open
ilonatommy
commented
Feb 13, 2026
src/ProjectTemplates/test/Templates.Blazor.Tests/TestAssets/WebWorker/TestWorkerMethods.cs
Show resolved
Hide resolved
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up for #65037.
Summary
Adds end-to-end browser tests for the webworker template introduced in #65037. Tests verify that the template produces a functional web worker that can be invoked from a Blazor WASM application.
Changes
Test Coverage
WebWorkerTemplate_CanInvokeMethodsWebWorkerTemplate_HandlesErrorsWebWorkerTemplate_CanDisposeWorkerDisposeAsync