@@ -9,88 +9,85 @@ import {
9
9
shouldSkipTracingTest ,
10
10
} from '../../../../utils/helpers' ;
11
11
12
- sentryTest (
13
- 'should capture an INP click event span during pageload' ,
14
- async ( { browserName, getLocalTestUrl, page } ) => {
15
- const supportedBrowsers = [ 'chromium' ] ;
12
+ sentryTest ( 'should capture an INP click event span during pageload' , async ( { browserName, getLocalTestUrl, page } ) => {
13
+ const supportedBrowsers = [ 'chromium' ] ;
16
14
17
- if ( shouldSkipTracingTest ( ) || ! supportedBrowsers . includes ( browserName ) ) {
18
- sentryTest . skip ( ) ;
19
- }
15
+ if ( shouldSkipTracingTest ( ) || ! supportedBrowsers . includes ( browserName ) ) {
16
+ sentryTest . skip ( ) ;
17
+ }
20
18
21
- const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
19
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
22
20
23
- await page . goto ( url ) ;
21
+ await page . goto ( url ) ;
24
22
25
- const spanEnvelopePromise = getMultipleSentryEnvelopeRequests < SpanEnvelope > (
26
- page ,
27
- 1 ,
28
- { envelopeType : 'span' } ,
29
- properFullEnvelopeRequestParser ,
30
- ) ;
23
+ const spanEnvelopePromise = getMultipleSentryEnvelopeRequests < SpanEnvelope > (
24
+ page ,
25
+ 1 ,
26
+ { envelopeType : 'span' } ,
27
+ properFullEnvelopeRequestParser ,
28
+ ) ;
31
29
32
- await page . locator ( '[data-test-id=normal-button]' ) . click ( ) ;
33
- await page . locator ( '.clicked[data-test-id=normal-button]' ) . isVisible ( ) ;
30
+ await page . locator ( '[data-test-id=normal-button]' ) . click ( ) ;
31
+ await page . locator ( '.clicked[data-test-id=normal-button]' ) . isVisible ( ) ;
34
32
35
- await page . waitForTimeout ( 500 ) ;
33
+ await page . waitForTimeout ( 500 ) ;
36
34
37
- // Page hide to trigger INP
38
- await page . evaluate ( ( ) => {
39
- window . dispatchEvent ( new Event ( 'pagehide' ) ) ;
40
- } ) ;
35
+ // Page hide to trigger INP
36
+ await page . evaluate ( ( ) => {
37
+ window . dispatchEvent ( new Event ( 'pagehide' ) ) ;
38
+ } ) ;
41
39
42
- // Get the INP span envelope
43
- const spanEnvelope = ( await spanEnvelopePromise ) [ 0 ] ;
44
-
45
- const spanEnvelopeHeaders = spanEnvelope [ 0 ] ;
46
- const spanEnvelopeItem = spanEnvelope [ 1 ] [ 0 ] [ 1 ] ;
47
-
48
- const traceId = spanEnvelopeHeaders . trace ! . trace_id ;
49
- expect ( traceId ) . toMatch ( / [ a - f 0 - 9 ] { 32 } / ) ;
50
-
51
- expect ( spanEnvelopeHeaders ) . toEqual ( {
52
- sent_at : expect . any ( String ) ,
53
- trace : {
54
- environment : 'production' ,
55
- public_key : 'public' ,
56
- sample_rate : '1' ,
57
- sampled : 'true' ,
58
- trace_id : traceId ,
59
- // no transaction, because span source is URL
60
- } ,
61
- } ) ;
40
+ // Get the INP span envelope
41
+ const spanEnvelope = ( await spanEnvelopePromise ) [ 0 ] ;
62
42
63
- const inpValue = spanEnvelopeItem . measurements ?. inp . value ;
64
- expect ( inpValue ) . toBeGreaterThan ( 0 ) ;
43
+ const spanEnvelopeHeaders = spanEnvelope [ 0 ] ;
44
+ const spanEnvelopeItem = spanEnvelope [ 1 ] [ 0 ] [ 1 ] ;
65
45
66
- expect ( spanEnvelopeItem ) . toEqual ( {
67
- data : {
68
- 'sentry.exclusive_time' : inpValue ,
69
- 'sentry.op' : 'ui.interaction.click' ,
70
- 'sentry.origin' : 'auto.http.browser.inp' ,
71
- transaction : 'test-url' ,
72
- 'user_agent.original' : expect . stringContaining ( 'Chrome' ) ,
73
- } ,
74
- measurements : {
75
- inp : {
76
- unit : 'millisecond' ,
77
- value : inpValue ,
78
- } ,
79
- } ,
80
- description : 'body > NormalButton' ,
81
- exclusive_time : inpValue ,
82
- op : 'ui.interaction.click' ,
83
- origin : 'auto.http.browser.inp' ,
84
- segment_id : expect . not . stringMatching ( spanEnvelopeItem . span_id ! ) ,
85
- // Parent is the pageload span
86
- parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
87
- span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
88
- start_timestamp : expect . any ( Number ) ,
89
- timestamp : expect . any ( Number ) ,
46
+ const traceId = spanEnvelopeHeaders . trace ! . trace_id ;
47
+ expect ( traceId ) . toMatch ( / [ a - f 0 - 9 ] { 32 } / ) ;
48
+
49
+ expect ( spanEnvelopeHeaders ) . toEqual ( {
50
+ sent_at : expect . any ( String ) ,
51
+ trace : {
52
+ environment : 'production' ,
53
+ public_key : 'public' ,
54
+ sample_rate : '1' ,
55
+ sampled : 'true' ,
90
56
trace_id : traceId ,
91
- } ) ;
92
- } ,
93
- ) ;
57
+ // no transaction, because span source is URL
58
+ } ,
59
+ } ) ;
60
+
61
+ const inpValue = spanEnvelopeItem . measurements ?. inp . value ;
62
+ expect ( inpValue ) . toBeGreaterThan ( 0 ) ;
63
+
64
+ expect ( spanEnvelopeItem ) . toEqual ( {
65
+ data : {
66
+ 'sentry.exclusive_time' : inpValue ,
67
+ 'sentry.op' : 'ui.interaction.click' ,
68
+ 'sentry.origin' : 'auto.http.browser.inp' ,
69
+ transaction : 'test-url' ,
70
+ 'user_agent.original' : expect . stringContaining ( 'Chrome' ) ,
71
+ } ,
72
+ measurements : {
73
+ inp : {
74
+ unit : 'millisecond' ,
75
+ value : inpValue ,
76
+ } ,
77
+ } ,
78
+ description : 'body > NormalButton' ,
79
+ exclusive_time : inpValue ,
80
+ op : 'ui.interaction.click' ,
81
+ origin : 'auto.http.browser.inp' ,
82
+ segment_id : expect . not . stringMatching ( spanEnvelopeItem . span_id ! ) ,
83
+ // Parent is the pageload span
84
+ parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
85
+ span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
86
+ start_timestamp : expect . any ( Number ) ,
87
+ timestamp : expect . any ( Number ) ,
88
+ trace_id : traceId ,
89
+ } ) ;
90
+ } ) ;
94
91
95
92
sentryTest (
96
93
'should choose the slowest interaction click event when INP is triggered.' ,
0 commit comments