File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed
browser-integration-tests/suites/tracing/browsertracing/interactions Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ const delay = e => {
14
14
} ;
15
15
16
16
document . querySelector ( '[data-test-id=interaction-button]' ) . addEventListener ( 'click' , delay ) ;
17
+ document . querySelector ( '[data-test-id=annotated-button]' ) . addEventListener ( 'click' , delay ) ;
Original file line number Diff line number Diff line change 6
6
< body >
7
7
< div > Rendered Before Long Task</ div >
8
8
< button data-test-id ="interaction-button "> Click Me</ button >
9
+ < button data-test-id ="annotated-button " data-component ="AnnotatedButton "> Click Me</ button >
9
10
< script src ="https://example.com/path/to/script.js "> </ script >
10
11
</ body >
11
12
</ html >
Original file line number Diff line number Diff line change @@ -80,3 +80,35 @@ sentryTest(
80
80
}
81
81
} ,
82
82
) ;
83
+
84
+ sentryTest (
85
+ 'should use the component name for a clicked element when it is available' ,
86
+ async ( { browserName, getLocalTestPath, page } ) => {
87
+ const supportedBrowsers = [ 'chromium' , 'firefox' ] ;
88
+
89
+ if ( shouldSkipTracingTest ( ) || ! supportedBrowsers . includes ( browserName ) ) {
90
+ sentryTest . skip ( ) ;
91
+ }
92
+
93
+ await page . route ( '**/path/to/script.js' , ( route : Route ) =>
94
+ route . fulfill ( { path : `${ __dirname } /assets/script.js` } ) ,
95
+ ) ;
96
+
97
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
98
+
99
+ await page . goto ( url ) ;
100
+ await getFirstSentryEnvelopeRequest < Event > ( page ) ;
101
+
102
+ await page . locator ( '[data-test-id=annotated-button]' ) . click ( ) ;
103
+
104
+ const envelopes = await getMultipleSentryEnvelopeRequests < TransactionJSON > ( page , 1 ) ;
105
+ expect ( envelopes ) . toHaveLength ( 1 ) ;
106
+ const eventData = envelopes [ 0 ] ;
107
+
108
+ expect ( eventData . spans ) . toHaveLength ( 1 ) ;
109
+
110
+ const interactionSpan = eventData . spans ! [ 0 ] ;
111
+ expect ( interactionSpan . op ) . toBe ( 'ui.interaction.click' ) ;
112
+ expect ( interactionSpan . description ) . toBe ( 'AnnotatedButton' ) ;
113
+ } ,
114
+ ) ;
Original file line number Diff line number Diff line change 1
1
import { JSDOM } from 'jsdom' ;
2
2
3
- import { getDomElement , getElementIdentifier , htmlTreeAsString } from '../src/browser' ;
3
+ import { getDomElement , htmlTreeAsString } from '../src/browser' ;
4
4
5
5
beforeAll ( ( ) => {
6
6
const dom = new JSDOM ( ) ;
You can’t perform that action at this time.
0 commit comments