Skip to content

Add e2e tests for server push events#36879

Open
silverwind wants to merge 10 commits intogo-gitea:mainfrom
silverwind:e2eevents
Open

Add e2e tests for server push events#36879
silverwind wants to merge 10 commits intogo-gitea:mainfrom
silverwind:e2eevents

Conversation

@silverwind
Copy link
Member

@silverwind silverwind commented Mar 10, 2026

Add e2e tests for the three server push features:

  • Notification count: verifies badge appears when another user creates an issue
  • Stopwatch: verifies stopwatch element is rendered when a stopwatch is active
  • Logout propagation: verifies logout in one tab triggers redirect in another

Tests are transport-agnostic in preparation for a future WebSocket migration.

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>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 10, 2026
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>
@silverwind silverwind changed the title Add e2e tests for server-sent events Add e2e tests for server push events Mar 10, 2026
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
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 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.ts covering 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>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 10, 2026
silverwind and others added 2 commits March 10, 2026 20:01
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/frontend type/testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants