Skip to content

test(plugin-autocapture-browser): cover exposure snapshot re-arm on navigation - #2068

Draft
jxiwang wants to merge 1 commit into
mainfrom
cursor/viewport-snapshot-navigation-tests-9693
Draft

jxiwang wants to merge 1 commit into
mainfrom
cursor/viewport-snapshot-navigation-tests-9693

Conversation

@jxiwang

@jxiwang jxiwang commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Verifies that the initial exposure snapshot (rescan DOM, then flush [Amplitude] Viewport Content Updated) runs again on each page navigation, not only on first load.

No source change was needed: every page-end path in handleViewportContentUpdated (and rearmDeferredPageView for redirect and in-flight navigation cases) calls initialExposureSnapshotScheduler.reset(), which re-arms the snapshot. Before this PR, only the "second URL change within 100ms" case was explicitly tested.

This adds regression tests that let the initial page-load snapshot complete, navigate, expose an element, and assert that a fresh snapshot flushes it, for:

  • history.pushState
  • history.replaceState
  • popstate
  • Navigation API navigate + navigatesuccess

I confirmed that removing the reset() call on page end makes all four tests fail.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No
Open in Web Open in Cursor 

@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 67.47 KB (0%)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 136.37 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 221.57 KB (0%)
@amplitude/element-selector (gzipped esm) 3.48 KB (0%)

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.

2 participants