Add e2e tests for server push events#36879
Conversation
Add tests for the three SSE features: notification count updates, stopwatch events, and logout propagation across tabs. Also extract user management helpers (apiCreateUser, apiDeleteUser, loginUser) into the shared e2e utils and use them in register tests. Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Remove SSE-specific code (raw EventSource connections) from e2e tests so they work with any transport (EventSource, WebSocket, etc.). - Stopwatch test: verify DOM element instead of raw EventSource data - Logout test: remove EventSource open probe and waitForTimeout - Remove unnecessary 5s sleep from logoutFromWorker (session is already destroyed server-side before the event reaches the client) - Reduce EVENT_SOURCE_UPDATE_TIME from 2s to 1s for faster tests - Raise timeouts for CI (60s assertions, 120s describe) Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds Playwright e2e coverage around the UI’s server-push/event-stream driven behaviors (notifications, stopwatch, logout propagation) and introduces supporting e2e utilities/config tweaks to make these tests run quickly and deterministically.
Changes:
- Add new
events.test.tscovering notification badge, active stopwatch rendering, and cross-tab logout behavior. - Speed up event polling for e2e runs by setting
ui.notification.EVENT_SOURCE_UPDATE_TIME=1s. - Extend e2e test utilities with admin user create/delete helpers and per-user auth headers.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web_src/js/modules/worker.ts | Simplifies worker-triggered logout redirect (removes delay + async). |
| tools/test-e2e.sh | Sets a faster EventSource update interval for the isolated e2e server. |
| tests/e2e/utils.ts | Adds API helpers for creating/deleting users and logging in as them. |
| tests/e2e/register.test.ts | Refactors cleanup to reuse apiDeleteUser() helper. |
| tests/e2e/events.test.ts | New e2e tests for notification count, stopwatch presence, and logout propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Reorder notification test to login first, then create issue, so the badge appearance is actually driven by server push, not SSR - Pass baseURL to browser.newContext() so relative URLs work in the logout propagation test - Add apiCreateIssue and apiStartStopwatch helpers with retry logic - Add optional headers param to apiCreateRepo for per-user auth - Use helpers instead of raw request.post() calls in event tests - Rename apiBaseUrl to baseUrl as it is the general server URL - Use env.GITEA_TEST_E2E_DOMAIN instead of hardcoded email domain Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
|
last call @go-gitea/technical-oversight-committee |
wxiaoguang
left a comment
There was a problem hiding this comment.
// wait for a while because other requests (eg: logout) may be in the flight
Need to handle the "logout" conflicts.
There can be 2 requests:
- User clicks
/user/logout?redirect_to=.... - Worker triggers redirection to
/
I don't think there can be a conflict. Here is Claude's analysis:
Maybe it's a problem in non-conformant browsers. I can add a safeguard if you really like. |
- Remove 90s describe timeout, reduce assertion timeouts from 60s to 15s - Lower EVENT_SOURCE_UPDATE_TIME from 1s to 500ms for faster event delivery - Parallelize cleanup apiDeleteUser calls - Remove unnecessary timeout on logout propagation assertion Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>
- Add $(WEBPACK_DEST) dependency to test-e2e target so frontend assets are rebuilt when sources change - Parallelize apiCreateRepo and loginUser in notification count test Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>
|
Not yet, need to refactor some legacy code |
It is just lucky enough because I recently refactored the "logout" to a pure href by Implements OIDC RP-Initiated Logout #36724. Otherwise, the old code uses "fetch" to do logout, there was no "beforeunload" before the logout had completed. |
|
I don't imagine us ever having more than 1 shared worker, would recommend a generic name. Maybe |
|
Websocket worker would replace the current worker but I don't want to rule out having more than 1, but I think it's highly unlikely. |
There is always a chance to rename it in the future if new code comes. Slightly longer names won't harm anyone, it also help to reduce AI hallucination: they just use grep to search the code base. |
|
Fine with me. |
* origin/main: Add e2e tests for server push events (go-gitea#36879) # Conflicts: # web_src/js/features/notification.ts # web_src/js/features/stopwatch.ts
* origin/main: Fix relative-time RangeError (go-gitea#37021) Restyle Workflow Graph (go-gitea#36912) Update message severity colors, fix navbar double border (go-gitea#37019) Clean up checkbox cursor styles (go-gitea#37016) add missing cron tasks to example ini (go-gitea#37012) Add e2e tests for server push events (go-gitea#36879)
* main: (35 commits) Correct swagger annotations for enums, status codes, and notification state (go-gitea#37030) Update Nix flake (go-gitea#37024) Bump go and python versions in nix flake (go-gitea#37031) Make task list checkboxes clickable in the preview tab (go-gitea#37010) Add support for in_progress event in workflow_run webhook (go-gitea#36979) Fix various problems (go-gitea#37029) Update AI Contribution Policy (go-gitea#37022) Migrate from webpack to vite (go-gitea#37002) Upgrade yaml (go-gitea#37015) Fix issue label deletion with Actions tokens (go-gitea#37013) Hide delete branch or tag buttons in mirror or archived repositories. (go-gitea#37006) Update AGENTS.md with additional guidelines (go-gitea#37018) Optimize 'refreshAccesses' to perform update without removing then adding (go-gitea#35702) Fix relative-time RangeError (go-gitea#37021) Restyle Workflow Graph (go-gitea#36912) Update message severity colors, fix navbar double border (go-gitea#37019) Clean up checkbox cursor styles (go-gitea#37016) add missing cron tasks to example ini (go-gitea#37012) Add e2e tests for server push events (go-gitea#36879) Update JS dependencies (go-gitea#37001) ...
* origin/main: (69 commits) Correct swagger annotations for enums, status codes, and notification state (go-gitea#37030) Update Nix flake (go-gitea#37024) Bump go and python versions in nix flake (go-gitea#37031) Make task list checkboxes clickable in the preview tab (go-gitea#37010) Add support for in_progress event in workflow_run webhook (go-gitea#36979) Fix various problems (go-gitea#37029) Update AI Contribution Policy (go-gitea#37022) Migrate from webpack to vite (go-gitea#37002) Upgrade yaml (go-gitea#37015) Fix issue label deletion with Actions tokens (go-gitea#37013) Hide delete branch or tag buttons in mirror or archived repositories. (go-gitea#37006) Update AGENTS.md with additional guidelines (go-gitea#37018) Optimize 'refreshAccesses' to perform update without removing then adding (go-gitea#35702) Fix relative-time RangeError (go-gitea#37021) Restyle Workflow Graph (go-gitea#36912) Update message severity colors, fix navbar double border (go-gitea#37019) Clean up checkbox cursor styles (go-gitea#37016) add missing cron tasks to example ini (go-gitea#37012) Add e2e tests for server push events (go-gitea#36879) Update JS dependencies (go-gitea#37001) ... # Conflicts: # package.json # pnpm-lock.yaml # tests/e2e/utils.ts # web_src/css/themes/theme-gitea-dark.css # web_src/css/themes/theme-gitea-light.css # web_src/js/bootstrap.ts # web_src/js/features/codeeditor.ts # web_src/js/modules/errors.test.ts # webpack.config.ts

Add e2e tests for the three server push features:
Tests are transport-agnostic in preparation for a future WebSocket migration.