|
1 | 1 | import { expect, test } from '@playwright/test';
|
2 |
| -import { waitForTransaction } from '@sentry-internal/test-utils'; |
| 2 | +import { waitForEnvelopeItem, waitForTransaction } from '@sentry-internal/test-utils'; |
3 | 3 |
|
4 | 4 | test('sends a pageload transaction with a parameterized URL', async ({ page }) => {
|
5 | 5 | const transactionPromise = waitForTransaction('react-router-6', async transactionEvent => {
|
@@ -54,3 +54,45 @@ test('sends a navigation transaction with a parameterized URL', async ({ page })
|
54 | 54 | },
|
55 | 55 | });
|
56 | 56 | });
|
| 57 | + |
| 58 | +test('sends an INP span', async ({ page }) => { |
| 59 | + const inpSpanPromise = waitForEnvelopeItem('react-router-6', item => { |
| 60 | + return item[0].type === 'span'; |
| 61 | + }); |
| 62 | + |
| 63 | + await page.goto(`/`); |
| 64 | + |
| 65 | + await page.click('#exception-button'); |
| 66 | + |
| 67 | + await page.waitForTimeout(500); |
| 68 | + |
| 69 | + // Page hide to trigger INP |
| 70 | + await page.evaluate(() => { |
| 71 | + window.dispatchEvent(new Event('pagehide')); |
| 72 | + }); |
| 73 | + |
| 74 | + const inpSpan = await inpSpanPromise; |
| 75 | + |
| 76 | + expect(inpSpan[1]).toEqual({ |
| 77 | + data: { |
| 78 | + 'sentry.origin': 'auto.http.browser.inp', |
| 79 | + 'sentry.op': 'ui.interaction.click', |
| 80 | + release: 'e2e-test', |
| 81 | + environment: 'qa', |
| 82 | + transaction: '/', |
| 83 | + 'sentry.exclusive_time': expect.any(Number), |
| 84 | + replay_id: expect.any(String), |
| 85 | + }, |
| 86 | + description: 'body > div#root > input#exception-button[type="button"]', |
| 87 | + op: 'ui.interaction.click', |
| 88 | + parent_span_id: expect.any(String), |
| 89 | + span_id: expect.any(String), |
| 90 | + start_timestamp: expect.any(Number), |
| 91 | + timestamp: expect.any(Number), |
| 92 | + trace_id: expect.any(String), |
| 93 | + origin: 'auto.http.browser.inp', |
| 94 | + exclusive_time: expect.any(Number), |
| 95 | + measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } }, |
| 96 | + segment_id: expect.any(String), |
| 97 | + }); |
| 98 | +}); |
0 commit comments