|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { sentryTest } from '../../../../utils/fixtures'; |
| 3 | +import { shouldSkipCdnBundleTest, shouldSkipTracingTest } from '../../../../utils/helpers'; |
| 4 | +import { getSpanOp, observeStreamedSpan, waitForStreamedSpan, waitForStreamedSpans } from '../../../../utils/spanUtils'; |
| 5 | + |
| 6 | +sentryTest( |
| 7 | + 'filters ui.interaction.click spans for spotlight elements via ignoreSpans in streaming mode', |
| 8 | + async ({ getLocalTestUrl, page }) => { |
| 9 | + // spotlightBrowserIntegration is not available in CDN bundles |
| 10 | + if (shouldSkipTracingTest() || shouldSkipCdnBundleTest()) { |
| 11 | + sentryTest.skip(); |
| 12 | + } |
| 13 | + |
| 14 | + const url = await getLocalTestUrl({ testDir: __dirname }); |
| 15 | + |
| 16 | + // Set up an observer that fails if a spotlight interaction span is ever sent |
| 17 | + let sawSpotlightInteractionSpan = false; |
| 18 | + await observeStreamedSpan(page, span => { |
| 19 | + if (getSpanOp(span) === 'ui.interaction.click' && span.name?.includes('#sentry-spotlight')) { |
| 20 | + sawSpotlightInteractionSpan = true; |
| 21 | + return true; |
| 22 | + } |
| 23 | + return false; |
| 24 | + }); |
| 25 | + |
| 26 | + await page.goto(url); |
| 27 | + |
| 28 | + // Wait for pageload to finish before clicking |
| 29 | + await waitForStreamedSpan(page, span => getSpanOp(span) === 'pageload'); |
| 30 | + |
| 31 | + // Click on the spotlight element — its ui.interaction.click child should be filtered |
| 32 | + await page.locator('[data-test-id=spotlight-button]').click(); |
| 33 | + await page.locator('.clicked[data-test-id=spotlight-button]').isVisible(); |
| 34 | + |
| 35 | + // Wait for the spotlight click's segment span to arrive |
| 36 | + await waitForStreamedSpans(page, spans => |
| 37 | + spans.some(span => span.is_segment && getSpanOp(span) === 'ui.action.click'), |
| 38 | + ); |
| 39 | + |
| 40 | + // Click on the regular button — its ui.interaction.click child should be kept |
| 41 | + const regularInteractionSpansPromise = waitForStreamedSpans(page, spans => |
| 42 | + spans.some(span => getSpanOp(span) === 'ui.interaction.click' && !span.name?.includes('#sentry-spotlight')), |
| 43 | + ); |
| 44 | + |
| 45 | + await page.locator('[data-test-id=regular-button]').click(); |
| 46 | + await page.locator('.clicked[data-test-id=regular-button]').isVisible(); |
| 47 | + |
| 48 | + const regularSpans = await regularInteractionSpansPromise; |
| 49 | + const regularInteractionSpan = regularSpans.find( |
| 50 | + span => getSpanOp(span) === 'ui.interaction.click' && !span.name?.includes('#sentry-spotlight'), |
| 51 | + ); |
| 52 | + expect(regularInteractionSpan).toBeDefined(); |
| 53 | + expect(regularInteractionSpan!.name).toContain('button'); |
| 54 | + |
| 55 | + // Verify no spotlight interaction span was ever sent |
| 56 | + expect(sawSpotlightInteractionSpan).toBe(false); |
| 57 | + }, |
| 58 | +); |
0 commit comments