Skip to content

Commit 6b626d2

Browse files
committed
test(browser-integration): Finalize LCP with a trusted click
web-vitals finalizes LCP on the first trusted input or visibility change and checks `isTrusted`, so the synthetic `visibilitychange` this test dispatched never finalized it. It passed anyway while `reportAllChanges` was on, since every LCP entry was reported as it arrived. Soft navigation reporting turns that off, so on a browser that supports the Soft Navigations API no LCP span was emitted at all. Clicking finalizes it the way a real user does.
1 parent df8b1d2 commit 6b626d2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-streamed-spans

dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-streamed-spans/test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Route } from '@playwright/test';
22
import { expect } from '@playwright/test';
33
import { sentryTest } from '../../../../utils/fixtures';
4-
import { hidePage, shouldSkipTracingTest } from '../../../../utils/helpers';
4+
import { shouldSkipTracingTest } from '../../../../utils/helpers';
55
import { getSpanOp, waitForStreamedSpan } from '../../../../utils/spanUtils';
66

77
sentryTest.beforeEach(async ({ browserName, page }) => {
@@ -30,7 +30,10 @@ sentryTest('captures LCP as a streamed span with element attributes', async ({ g
3030
// Wait for LCP to be captured
3131
await page.waitForTimeout(1000);
3232

33-
await hidePage(page);
33+
// LCP finalizes on the first trusted input or visibility change, and web-vitals checks
34+
// `isTrusted`, so a synthetically dispatched `visibilitychange` does not finalize it. Click to
35+
// finalize the way a real user would.
36+
await page.click('body');
3437

3538
const lcpSpan = await lcpSpanPromise;
3639
const pageloadSpan = await pageloadSpanPromise;

0 commit comments

Comments
 (0)