-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): Set artificial zero-value CLS measurement to report no …
…layout shift
- Loading branch information
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ser-integration-tests/suites/tracing/metrics/web-vitals-cls-no-layout-shift/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
Some content | ||
</div> | ||
</body> | ||
</html> |
41 changes: 41 additions & 0 deletions
41
...s/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-no-layout-shift/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
|
||
sentryTest.beforeEach(async ({ page }) => { | ||
await page.setViewportSize({ width: 800, height: 1200 }); | ||
}); | ||
|
||
sentryTest('captures 0 CLS if the browser supports reporting CLS', async ({ getLocalTestPath, page, browserName }) => { | ||
if (shouldSkipTracingTest() || browserName !== 'chromium') { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
const transactionEvent = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(transactionEvent.measurements).toBeDefined(); | ||
expect(transactionEvent.measurements?.cls?.value).toBe(0); | ||
|
||
// but no source entry (no source if there is no layout shift) | ||
expect(transactionEvent.contexts?.trace?.data?.['cls.source.1']).toBeUndefined(); | ||
}); | ||
|
||
sentryTest( | ||
"doesn't capture 0 CLS if the browser doesn't support reporting CLS", | ||
async ({ getLocalTestPath, page, browserName }) => { | ||
if (shouldSkipTracingTest() || browserName === 'chromium') { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
const transactionEvent = await getFirstSentryEnvelopeRequest<Event>(page, `${url}#no-cls`); | ||
|
||
expect(transactionEvent.measurements).toBeDefined(); | ||
expect(transactionEvent.measurements?.cls).toBeUndefined(); | ||
|
||
expect(transactionEvent.contexts?.trace?.data?.['cls.source.1']).toBeUndefined(); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters