Skip to content

Commit 284e5ea

Browse files
msonnbclaude
andcommitted
test(e2e): Trigger INP flush via visibilitychange instead of pagehide
The Safari 14 support removal dropped the `pagehide` listener from the vendored web-vitals code, so the React/react-router SPA E2E apps that flushed the INP span by dispatching a bare `pagehide` event no longer triggered a flush and timed out. Switch them to the same `visibilitychange` pattern already used in the browser integration tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8bbc4b3 commit 284e5ea

5 files changed

Lines changed: 10 additions & 5 deletions

File tree

dev-packages/e2e-tests/test-applications/react-17/tests/transactions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ test('sends an INP span', async ({ page }) => {
8080

8181
// Page hide to trigger INP
8282
await page.evaluate(() => {
83-
window.dispatchEvent(new Event('pagehide'));
83+
Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });
84+
document.dispatchEvent(new Event('visibilitychange'));
8485
});
8586

8687
const inpSpan = await inpSpanPromise;

dev-packages/e2e-tests/test-applications/react-router-6/tests/transactions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ test('sends an INP span', async ({ page }) => {
8080

8181
// Page hide to trigger INP
8282
await page.evaluate(() => {
83-
window.dispatchEvent(new Event('pagehide'));
83+
Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });
84+
document.dispatchEvent(new Event('visibilitychange'));
8485
});
8586

8687
const inpSpan = await inpSpanPromise;

dev-packages/e2e-tests/test-applications/react-router-7-spa-streaming/tests/spans.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ test('sends an INP span', async ({ page }) => {
6060

6161
// Page hide to trigger INP
6262
await page.evaluate(() => {
63-
window.dispatchEvent(new Event('pagehide'));
63+
Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });
64+
document.dispatchEvent(new Event('visibilitychange'));
6465
});
6566

6667
const inpSpan = await inpSpanPromise;

dev-packages/e2e-tests/test-applications/react-router-7-spa/tests/transactions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ test('sends an INP span', async ({ page }) => {
8080

8181
// Page hide to trigger INP
8282
await page.evaluate(() => {
83-
window.dispatchEvent(new Event('pagehide'));
83+
Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });
84+
document.dispatchEvent(new Event('visibilitychange'));
8485
});
8586

8687
const inpSpan = await inpSpanPromise;

dev-packages/e2e-tests/test-applications/react-router-8-spa/tests/transactions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ test('sends an INP span', async ({ page }) => {
8080

8181
// Page hide to trigger INP
8282
await page.evaluate(() => {
83-
window.dispatchEvent(new Event('pagehide'));
83+
Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });
84+
document.dispatchEvent(new Event('visibilitychange'));
8485
});
8586

8687
const inpSpan = await inpSpanPromise;

0 commit comments

Comments
 (0)