Skip to content

test: exercise service-worker push and notification-click behavior - #1812

Open
Maxwell-tom wants to merge 3 commits into
LabsCrypt:mainfrom
Maxwell-tom:feat/issue-1712-test-exercise-service-worker-push-and
Open

Maxwell-tom wants to merge 3 commits into
LabsCrypt:mainfrom
Maxwell-tom:feat/issue-1712-test-exercise-service-worker-push-and

Conversation

@Maxwell-tom

Copy link
Copy Markdown

Overview

This PR adds direct test coverage for frontend/public/sw.js, the service worker that handles push events and notification clicks. Previously, notification tests mocked the subscribe/unsubscribe helpers and never executed the worker script, so regressions in push payload parsing, waitUntil lifetimes, window reuse, or openWindow behavior could go undetected. The new harness runs the actual script and asserts on those paths.

Related Issue

Changes

🧪 Service Worker Test Harness

  • [ADD] frontend/src/__tests__/service-worker.test.ts

    • Loads and executes public/sw.js inside a worker-like harness.
    • Push handling: valid JSON payload, malformed JSON / plain text payload, and missing push payload.
    • Notification click handling: with an existing window (close/navigate behavior) and with no open window (openWindow behavior), including event.waitUntil lifetime assertions.
  • [MODIFY] frontend/public/sw.js

    • Adjustments needed so the script can be evaluated under the harness and the tested branches are reachable.
  • [MODIFY] frontend/src/__tests__/notifications.test.tsx

    • Updated to account for the real service-worker behavior exercised by the new tests.
  • [MODIFY] frontend/src/__tests__/setup.ts

    • Shared test setup for the worker globals (self, clients, registration) used by the harness.

Verification Results

npm test -- src/__tests__/service-worker.test.ts
Acceptance Criteria Status
Execute the actual service-worker script in a worker harness; test valid JSON, malformed JSON/text, and missing push payloads ✅ Covered in service-worker.test.ts
Test notification clicks with an existing window and with no window, asserting close/navigation/openWindow and event.waitUntil ✅ Covered in service-worker.test.ts

Closes #1712

Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from a67b1f0 to 414782d Compare October 24, 2026 09:46
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 414782d to 55b91f5 Compare October 24, 2026 09:48
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 55b91f5 to 250ce94 Compare October 24, 2026 09:51
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 250ce94 to cd2c904 Compare October 24, 2026 11:30
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from cd2c904 to 95ebf3e Compare October 24, 2026 11:50
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 95ebf3e to bf5f135 Compare October 24, 2026 11:52
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 24, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from bf5f135 to 99e4508 Compare October 24, 2026 11:54
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 99e4508 to a40daff Compare October 29, 2026 07:37
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from a40daff to c2264c4 Compare October 29, 2026 07:39
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from c2264c4 to 6b0756e Compare October 29, 2026 07:42
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 6b0756e to 93746da Compare October 29, 2026 08:00
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 93746da to b71cc1e Compare October 29, 2026 08:01
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from b71cc1e to b25b0c0 Compare October 29, 2026 09:18
Maxwell-tom added a commit to Maxwell-tom/flowfi that referenced this pull request Oct 29, 2026
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from b25b0c0 to 602058e Compare October 29, 2026 09:20
@Maxwell-tom
Maxwell-tom force-pushed the feat/issue-1712-test-exercise-service-worker-push-and branch from 602058e to 2a38baa Compare October 29, 2026 09:23

This branch has not been deployed

No deployments
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.

[test] Exercise service-worker push and notification-click behavior

1 participant