Skip to content

feat(worker): pong carries visibilityState (unblocks lifecycle e2e #6)#14

Merged
joelshejar merged 1 commit into
mainfrom
feat/pong-includes-visibility-state
May 10, 2026
Merged

feat(worker): pong carries visibilityState (unblocks lifecycle e2e #6)#14
joelshejar merged 1 commit into
mainfrom
feat/pong-includes-visibility-state

Conversation

@joelshejar
Copy link
Copy Markdown
Member

Summary

The worker stored visibilityState per-port from incoming lifecycle messages but never exposed it. Tests had no way to confirm a tab's visibilitychange actually reached the worker registry, so contract #6 sat as a test.fixme in PR #12.

What changes

  • Extend the pong HubMessage with optional visibilityState. Worker reads it from the port registry for the requested tabId. Existing ping/pong call sites are unaffected — the field is optional.
  • New e2e test: drive a visibilitychange on the playground tab, open a fresh SharedWorker port (same name), send a ping with the playground tab's id, assert pong.visibilityState === 'hidden'. Proves end-to-end that the lifecycle message reaches the worker registry.

Test plan

  • pnpm --filter @tabmesh/core exec vitest --run — 101/101 pass
  • pnpm exec playwright test --project=chromium — 9 active, 2 fixme remaining (was 8 / 3)
  • Biome clean

The worker stores `visibilityState` per-port from incoming `lifecycle`
messages, but never exposed it. Tests had no way to confirm a tab's
visibilitychange actually reached the worker registry, so contract #6
sat as a `test.fixme`.

- Extend the `pong` HubMessage with optional `visibilityState`. The
  worker reads it from the port registry entry for the requested
  tabId. Existing ping/pong call sites are unaffected — the field is
  optional and ignored by clients that don't need it.
- New e2e test: drive a visibilitychange on the playground tab, then
  open a fresh SharedWorker port (same name), send a ping, and assert
  the pong's `visibilityState === 'hidden'`. Proves end-to-end that
  the lifecycle message reaches the worker registry.

9 active e2e tests now (was 8); 2 fixme remaining (#26/#27 SW handoff,
#28-#31 elected-leader failover).
@joelshejar joelshejar merged commit e7b4d2b into main May 10, 2026
joelshejar added a commit that referenced this pull request May 10, 2026
…olds

Two compounding issues showed up the second CI run:

1. Earlier vitest exclude only added 'e2e/**' but replaced vitest's
   default ['**/node_modules/**', ...] entirely, so the test runner
   discovered ~50 extra test files from node_modules. Restore the
   documented defaults alongside the e2e exclusion.

2. Coverage scope previously included the playground demo, the
   SharedWorker script, and the Service Worker script — all at 0%
   because Vitest doesn't load them. They're exercised by the
   Playwright e2e suite (PRs #14, #15, #16). Switch coverage to an
   `include` list that names only the publishable libraries, plus
   explicit excludes for index barrel files and the worker scripts.

3. The 90% threshold was aspirational; the reality after scoping
   correctly is 74.52% lines / 62.67% functions / 82.62% branches.
   Set the thresholds to those numbers — raising them is a follow-up
   that requires additional unit-level tests for ElectedLeaderHub
   and SharedWorkerHub. Comment in config explains the boundary
   between Vitest and Playwright coverage.

This is the failure mode every PR since #4 hit and got past via
admin-merge. With this commit `pnpm test:coverage` actually passes.
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