Skip to content

Commit

Permalink
Merge branch 'develop' into release/8.31.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome committed Sep 23, 2024
2 parents a7bc76d + 7584ae4 commit af0528e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,39 @@ sentryTest(
);

const url = await getLocalTestPath({ testDir: __dirname });

const [eventData] = await Promise.all([
getFirstSentryEnvelopeRequest<Event>(page),
page.goto(url),
page.click('button'),
page.locator('button').click(),
]);

expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.lcp?.value).toBeDefined();

expect(eventData.contexts?.trace?.data?.['lcp.element']).toBe('body > img');
expect(eventData.contexts?.trace?.data?.['lcp.size']).toBe(107400);
expect(eventData.contexts?.trace?.data?.['lcp.url']).toBe('https://example.com/path/to/image.png');
// This should be body > img, but it can be flakey as sometimes it will report
// the button as LCP.
expect(eventData.contexts?.trace?.data?.['lcp.element'].startsWith('body >')).toBe(true);

// Working around flakiness
// Only testing this when the LCP element is an image, not a button
if (eventData.contexts?.trace?.data?.['lcp.element'] === 'body > img') {
expect(eventData.contexts?.trace?.data?.['lcp.size']).toBe(107400);

const lcp = await (await page.waitForFunction('window._LCP')).jsonValue();
const lcp2 = await (await page.waitForFunction('window._LCP2')).jsonValue();
const lcp3 = await page.evaluate('window._LCP3');
const lcp = await (await page.waitForFunction('window._LCP')).jsonValue();
const lcp2 = await (await page.waitForFunction('window._LCP2')).jsonValue();
const lcp3 = await page.evaluate('window._LCP3');

expect(lcp).toEqual(107400);
expect(lcp2).toEqual(107400);
// this has not been triggered yet
expect(lcp3).toEqual(undefined);
expect(lcp).toEqual(107400);
expect(lcp2).toEqual(107400);
// this has not been triggered yet
expect(lcp3).toEqual(undefined);

// Adding a handler after LCP is completed still triggers the handler
await page.evaluate('window.ADD_HANDLER()');
const lcp3_2 = await (await page.waitForFunction('window._LCP3')).jsonValue();
// Adding a handler after LCP is completed still triggers the handler
await page.evaluate('window.ADD_HANDLER()');
const lcp3_2 = await (await page.waitForFunction('window._LCP3')).jsonValue();

expect(lcp3_2).toEqual(107400);
expect(lcp3_2).toEqual(107400);
}
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"@nestjs/core": "^10.3.10",
"@nestjs/graphql": "^12.2.0",
"@nestjs/platform-express": "^10.3.10",
"@sentry/nestjs": "^8.30.0",
"@sentry/nestjs": "latest || *",
"@sentry/types": "latest || *",
"graphql": "^16.9.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
Expand All @@ -47,4 +48,4 @@
"tsconfig-paths": "^4.2.0",
"typescript": "^4.9.5"
}
}
}

0 comments on commit af0528e

Please sign in to comment.