Skip to content

Add e2e test for cross-client query invalidation via Centrifugo#699

Draft
valentin0h wants to merge 1 commit intodevfrom
e2e-query-invalidation
Draft

Add e2e test for cross-client query invalidation via Centrifugo#699
valentin0h wants to merge 1 commit intodevfrom
e2e-query-invalidation

Conversation

@valentin0h
Copy link
Collaborator

Summary

  • Adds a two-browser Playwright e2e test that verifies the full realtime query invalidation pipeline: mutation → Centrifugo publish → WebSocket broadcast → QueryInvalidationSubscriberqueryClient.invalidateQueries → query refetch → UI update
  • Adds Centrifugo env vars to dev:e2e script and playwright.config.ts
  • Starts a Centrifugo Docker container in the CI workflow before running e2e tests

How the test works

Two separate browser contexts, two different users, zero page refreshes:

  1. User A (org admin) loads the landing page — listJoinRequests query fires, registers on profileJoinRequest:target channel, WebSocket subscription opens
  2. User B (individual from another org) visits User A's org profile and clicks "Request" — createJoinRequest mutation publishes to Centrifugo on the same channel
  3. Centrifugo broadcasts → User A's QueryInvalidationSubscriber receives → invalidateQuerieslistJoinRequests refetches

Primary assertion: Network intercept (page.waitForResponse) catches the listJoinRequests refetch on User A's page — direct proof the invalidation pipeline triggered a refetch without navigation.

Secondary assertion: UI shows "Join requests" panel and "wants to join your organization" text on User A's page.

Files changed

File Change
tests/e2e/tests/query-invalidation.spec.ts New test
tests/e2e/playwright.config.ts Centrifugo env vars
package.json Centrifugo env vars in dev:e2e, end-to-end script alias
.github/workflows/e2e-tests.yml Start Centrifugo container before e2e tests

Two-browser Playwright test that proves the realtime query invalidation
pipeline works end-to-end: User B's mutation publishes to Centrifugo,
User A's WebSocket subscription triggers queryClient.invalidateQueries,
and the listJoinRequests query refetches without a page refresh.

Primary assertion is a network intercept (waitForResponse) catching the
refetch on User A's page — the direct proof that invalidation fired.

Also adds Centrifugo env vars to dev:e2e and playwright config, and
starts a Centrifugo Docker container in the CI workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant