11import { expect } from '@playwright/test' ;
2- import type { Event as SentryEvent } from '@sentry/core' ;
2+ import type { TransactionEvent } from '@sentry/core' ;
33import { sentryTest } from '../../../../utils/fixtures' ;
44import {
5- getFirstSentryEnvelopeRequest ,
6- getMultipleSentryEnvelopeRequests ,
5+ envelopeRequestParser ,
76 shouldSkipCdnBundleTest ,
87 shouldSkipTracingTest ,
8+ waitForTransactionRequest ,
99} from '../../../../utils/helpers' ;
1010
1111sentryTest (
@@ -20,27 +20,25 @@ sentryTest(
2020 await page . goto ( url ) ;
2121
2222 // Wait for the pageload transaction to complete
23- await getFirstSentryEnvelopeRequest < SentryEvent > ( page ) ;
23+ await waitForTransactionRequest ( page ) ;
2424
2525 // Click on the spotlight element — interaction span should be filtered
26- const spotlightEnvelopePromise = getMultipleSentryEnvelopeRequests < SentryEvent > ( page , 1 ) ;
26+ const spotlightTxnPromise = waitForTransactionRequest ( page , txn => txn . contexts ?. trace ?. op === 'ui.action.click' ) ;
2727 await page . locator ( '[data-test-id=spotlight-button]' ) . click ( ) ;
2828 await page . locator ( '.clicked[data-test-id=spotlight-button]' ) . isVisible ( ) ;
29- const [ spotlightTransaction ] = await spotlightEnvelopePromise ;
29+ const spotlightTransaction = envelopeRequestParser < TransactionEvent > ( await spotlightTxnPromise ) ;
3030
31- expect ( spotlightTransaction . type ) . toBe ( 'transaction' ) ;
3231 expect ( spotlightTransaction . contexts ?. trace ?. op ) . toBe ( 'ui.action.click' ) ;
3332
3433 const spotlightInteractionSpans = spotlightTransaction . spans ?. filter ( span => span . op === 'ui.interaction.click' ) ;
3534 expect ( spotlightInteractionSpans ) . toHaveLength ( 0 ) ;
3635
3736 // Click on the regular button — interaction span should be kept
38- const regularEnvelopePromise = getMultipleSentryEnvelopeRequests < SentryEvent > ( page , 1 ) ;
37+ const regularTxnPromise = waitForTransactionRequest ( page , txn => txn . contexts ?. trace ?. op === 'ui.action.click' ) ;
3938 await page . locator ( '[data-test-id=regular-button]' ) . click ( ) ;
4039 await page . locator ( '.clicked[data-test-id=regular-button]' ) . isVisible ( ) ;
41- const [ regularTransaction ] = await regularEnvelopePromise ;
40+ const regularTransaction = envelopeRequestParser < TransactionEvent > ( await regularTxnPromise ) ;
4241
43- expect ( regularTransaction . type ) . toBe ( 'transaction' ) ;
4442 expect ( regularTransaction . contexts ?. trace ?. op ) . toBe ( 'ui.action.click' ) ;
4543
4644 const regularInteractionSpans = regularTransaction . spans ?. filter ( span => span . op === 'ui.interaction.click' ) ;
0 commit comments