Skip to content

Commit

Permalink
Merge branch 'develop' into bo-amqplib
Browse files Browse the repository at this point in the history
  • Loading branch information
obecny authored Sep 23, 2024
2 parents 5015ddc + 7584ae4 commit 24b2236
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 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.21.0",
"@sentry/nestjs": "latest || *",
"@sentry/types": "latest || *",
"graphql": "^16.9.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
Expand Down

0 comments on commit 24b2236

Please sign in to comment.