|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | + |
| 3 | +import { sentryTest } from '../../../utils/fixtures'; |
| 4 | +import { |
| 5 | + expectedFCPPerformanceSpan, |
| 6 | + expectedFPPerformanceSpan, |
| 7 | + expectedLCPPerformanceSpan, |
| 8 | + expectedMemoryPerformanceSpan, |
| 9 | + expectedNavigationPerformanceSpan, |
| 10 | + getExpectedReplayEvent, |
| 11 | +} from '../../../utils/replayEventTemplates'; |
| 12 | +import { getCustomRecordingEvents, getReplayEvent, waitForReplayRequest } from '../../../utils/replayHelpers'; |
| 13 | + |
| 14 | +sentryTest('replay recording should contain default performance spans', async ({ getLocalTestPath, page }) => { |
| 15 | + // Replay bundles are es6 only |
| 16 | + if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) { |
| 17 | + sentryTest.skip(); |
| 18 | + } |
| 19 | + |
| 20 | + const reqPromise0 = waitForReplayRequest(page, 0); |
| 21 | + const reqPromise1 = waitForReplayRequest(page, 1); |
| 22 | + |
| 23 | + await page.route('https://dsn.ingest.sentry.io/**/*', route => { |
| 24 | + return route.fulfill({ |
| 25 | + status: 200, |
| 26 | + contentType: 'application/json', |
| 27 | + body: JSON.stringify({ id: 'test-id' }), |
| 28 | + }); |
| 29 | + }); |
| 30 | + |
| 31 | + const url = await getLocalTestPath({ testDir: __dirname }); |
| 32 | + |
| 33 | + await page.goto(url); |
| 34 | + const replayEvent0 = getReplayEvent(await reqPromise0); |
| 35 | + const { performanceSpans: performanceSpans0 } = getCustomRecordingEvents(await reqPromise0); |
| 36 | + |
| 37 | + expect(replayEvent0).toEqual(getExpectedReplayEvent({ segment_id: 0 })); |
| 38 | + expect(performanceSpans0).toEqual([expectedMemoryPerformanceSpan]); |
| 39 | + |
| 40 | + await page.click('button'); |
| 41 | + |
| 42 | + const replayEvent1 = getReplayEvent(await reqPromise1); |
| 43 | + const { performanceSpans: performanceSpans1 } = getCustomRecordingEvents(await reqPromise1); |
| 44 | + |
| 45 | + expect(replayEvent1).toEqual(getExpectedReplayEvent({ segment_id: 1, urls: [], replay_start_timestamp: undefined })); |
| 46 | + |
| 47 | + expect(performanceSpans1).toEqual([ |
| 48 | + expectedNavigationPerformanceSpan, |
| 49 | + expectedLCPPerformanceSpan, |
| 50 | + expectedFPPerformanceSpan, |
| 51 | + expectedFCPPerformanceSpan, |
| 52 | + expectedMemoryPerformanceSpan, |
| 53 | + ]); |
| 54 | +}); |
0 commit comments