|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { sentryTest } from '../../../../utils/fixtures'; |
| 3 | +import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../utils/helpers'; |
| 4 | + |
| 5 | +sentryTest( |
| 6 | + 'click-triggered navigation should produce a root navigation transaction', |
| 7 | + async ({ getLocalTestUrl, page }) => { |
| 8 | + if (shouldSkipTracingTest()) { |
| 9 | + sentryTest.skip(); |
| 10 | + } |
| 11 | + |
| 12 | + const url = await getLocalTestUrl({ testDir: __dirname }); |
| 13 | + |
| 14 | + await page.goto(url); |
| 15 | + await waitForTransactionRequest(page); // "pageload" root span |
| 16 | + |
| 17 | + const interactionRequestPromise = waitForTransactionRequest( |
| 18 | + page, |
| 19 | + evt => evt.contexts?.trace?.op === 'ui.action.click', |
| 20 | + ); |
| 21 | + const navigationRequestPromise = waitForTransactionRequest(page, evt => evt.contexts?.trace?.op === 'navigation'); |
| 22 | + |
| 23 | + await page.locator('[data-test-id=navigate-button]').click(); |
| 24 | + |
| 25 | + const interactionEvent = envelopeRequestParser(await interactionRequestPromise); |
| 26 | + const navigationEvent = envelopeRequestParser(await navigationRequestPromise); |
| 27 | + |
| 28 | + // Navigation is root span, not a child span on the interaction |
| 29 | + expect(interactionEvent.contexts?.trace?.op).toBe('ui.action.click'); |
| 30 | + expect(navigationEvent.contexts?.trace?.op).toBe('navigation'); |
| 31 | + |
| 32 | + expect(interactionEvent.contexts?.trace?.trace_id).not.toEqual(navigationEvent.contexts?.trace?.trace_id); |
| 33 | + |
| 34 | + // does not contain a child navigation span |
| 35 | + const interactionSpans = interactionEvent.spans || []; |
| 36 | + const hasNavigationChild = interactionSpans.some(span => span.op === 'navigation' || span.op === 'http.server'); |
| 37 | + expect(hasNavigationChild).toBeFalsy(); |
| 38 | + }, |
| 39 | +); |
0 commit comments