Skip to content

test(router): cover popstate handler propagation - #75

Merged
jonlaing merged 1 commit into
mainfrom
test/navigation-popstate-coverage
Aug 3, 2026
Merged

test(router): cover popstate handler propagation#75
jonlaing merged 1 commit into
mainfrom
test/navigation-popstate-coverage

Conversation

@jonlaing

@jonlaing jonlaing commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

The existing Navigation tests mocked window.addEventListener as a vi.fn() that captured the handler but never fired it — so nothing verified that browser back/forward actually flowed through to the pathname signal and its subscribers.

Adds three regression tests (currently ALL PASSING on main):

  • popstate updates pathname signal — basic mechanism, verifies the ref update.
  • popstate notifies subscribers — subscribes to pathname.changes the way Outlet does and verifies the change stream fires on popstate.
  • popstate handler's Effect.runSync doesn't throw — captures errors thrown by the raw event dispatch and asserts none happen.

Updated the mock window's addEventListener to store the handler so it can be dispatched via a new dispatchWindowEvent helper.

Context

Locked in as regression coverage while investigating a report that browser back/forward doesn't work in SSG dev mode. The framework mechanism itself passes cleanly — issue is likely something environment-specific in the reporter's setup. These tests will catch it next time if the actual framework code regresses.

🤖 Generated with Claude Code

The existing Navigation tests mocked window.addEventListener as a
vi.fn() that captured the handler but never fired it — so nothing
verified that browser back/forward actually flowed through to the
pathname signal and its subscribers.

Add three tests:
- popstate updates pathname signal (basic mechanism).
- popstate propagates to a .changes subscriber (drives Outlet reconcile).
- popstate handler's Effect.runSync doesn't throw or fail silently.

Updated the mock window's addEventListener to store the handler so it
can be dispatched via a new dispatchWindowEvent helper.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying effex with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1c29ea4
Status: ✅  Deploy successful!
Preview URL: https://4ab8cc69.effex.pages.dev
Branch Preview URL: https://test-navigation-popstate-cov.effex.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying effex-api with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1c29ea4
Status: ✅  Deploy successful!
Preview URL: https://ac68117f.effex-api.pages.dev
Branch Preview URL: https://test-navigation-popstate-cov.effex-api.pages.dev

View logs

@jonlaing
jonlaing merged commit 7416672 into main Aug 3, 2026
4 checks passed
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