@@ -4,101 +4,104 @@ import { sentryTest } from '../../../../utils/fixtures';
4
4
import { envelopeRequestParser , getEnvelopeType } from '../../../../utils/helpers' ;
5
5
import { getCustomRecordingEvents , getReplayEvent , waitForReplayRequest } from '../../../../utils/replayHelpers' ;
6
6
7
- sentryTest ( 'should capture feedback (@sentry-internal/feedback import)' , async ( { forceFlushReplay, getLocalTestPath, page } ) => {
8
- if ( process . env . PW_BUNDLE ) {
9
- sentryTest . skip ( ) ;
10
- }
11
-
12
- const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
13
- const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
14
- const reqPromise2 = waitForReplayRequest ( page , 2 ) ;
15
- const feedbackRequestPromise = page . waitForResponse ( res => {
16
- const req = res . request ( ) ;
17
-
18
- const postData = req . postData ( ) ;
19
- if ( ! postData ) {
20
- return false ;
7
+ sentryTest (
8
+ 'should capture feedback (@sentry-internal/feedback import)' ,
9
+ async ( { forceFlushReplay, getLocalTestPath, page } ) => {
10
+ if ( process . env . PW_BUNDLE ) {
11
+ sentryTest . skip ( ) ;
21
12
}
22
13
23
- try {
24
- return getEnvelopeType ( req ) === 'feedback' ;
25
- } catch ( err ) {
26
- return false ;
27
- }
28
- } ) ;
14
+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
15
+ const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
16
+ const reqPromise2 = waitForReplayRequest ( page , 2 ) ;
17
+ const feedbackRequestPromise = page . waitForResponse ( res => {
18
+ const req = res . request ( ) ;
29
19
30
- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
31
- return route . fulfill ( {
32
- status : 200 ,
33
- contentType : 'application/json' ,
34
- body : JSON . stringify ( { id : 'test-id' } ) ,
20
+ const postData = req . postData ( ) ;
21
+ if ( ! postData ) {
22
+ return false ;
23
+ }
24
+
25
+ try {
26
+ return getEnvelopeType ( req ) === 'feedback' ;
27
+ } catch ( err ) {
28
+ return false ;
29
+ }
35
30
} ) ;
36
- } ) ;
37
31
38
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
32
+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
33
+ return route . fulfill ( {
34
+ status : 200 ,
35
+ contentType : 'application/json' ,
36
+ body : JSON . stringify ( { id : 'test-id' } ) ,
37
+ } ) ;
38
+ } ) ;
39
39
40
- const [ , , replayReq0 ] = await Promise . all ( [ page . goto ( url ) , page . getByText ( 'Report a Bug' ) . click ( ) , reqPromise0 ] ) ;
40
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
41
41
42
- // Inputs are slow, these need to be serial
43
- await page . locator ( '[name="name"]' ) . fill ( 'Jane Doe' ) ;
44
- await page . locator ( '[name="email"]' ) . fill ( '[email protected] ' ) ;
45
- await page . locator ( '[name="message"]' ) . fill ( 'my example feedback' ) ;
42
+ const [ , , replayReq0 ] = await Promise . all ( [ page . goto ( url ) , page . getByText ( 'Report a Bug' ) . click ( ) , reqPromise0 ] ) ;
46
43
47
- // Force flush here, as inputs are slow and can cause click event to be in unpredictable segments
48
- await Promise . all ( [
49
- forceFlushReplay ( ) ,
50
- reqPromise1 ,
51
- ] ) ;
44
+ // Inputs are slow, these need to be serial
45
+ await page . locator ( '[name="name"]' ) . fill ( 'Jane Doe' ) ;
46
+ await page . locator ( '[name="email"]' ) . fill ( '[email protected] ' ) ;
47
+ await page . locator ( '[name="message"]' ) . fill ( 'my example feedback' ) ;
52
48
53
- const [ , feedbackResp , replayReq2 ] = await Promise . all ( [ page . getByLabel ( 'Send Bug Report' ) . click ( ) , feedbackRequestPromise , reqPromise2 ] ) ;
49
+ // Force flush here, as inputs are slow and can cause click event to be in unpredictable segments
50
+ await Promise . all ( [ forceFlushReplay ( ) , reqPromise1 ] ) ;
54
51
55
- const feedbackEvent = envelopeRequestParser ( feedbackResp . request ( ) ) ;
56
- const replayEvent = getReplayEvent ( replayReq0 ) ;
57
- // Feedback breadcrumb is on second segment because we flush when "Report a Bug" is clicked
58
- // And then the breadcrumb is sent when feedback form is submitted
59
- const { breadcrumbs } = getCustomRecordingEvents ( replayReq2 ) ;
52
+ const [ , feedbackResp , replayReq2 ] = await Promise . all ( [
53
+ page . getByLabel ( 'Send Bug Report' ) . click ( ) ,
54
+ feedbackRequestPromise ,
55
+ reqPromise2 ,
56
+ ] ) ;
60
57
58
+ const feedbackEvent = envelopeRequestParser ( feedbackResp . request ( ) ) ;
59
+ const replayEvent = getReplayEvent ( replayReq0 ) ;
60
+ // Feedback breadcrumb is on second segment because we flush when "Report a Bug" is clicked
61
+ // And then the breadcrumb is sent when feedback form is submitted
62
+ const { breadcrumbs } = getCustomRecordingEvents ( replayReq2 ) ;
61
63
62
- expect ( breadcrumbs ) . toEqual (
63
- expect . arrayContaining ( [
64
- expect . objectContaining ( {
65
- category : 'sentry.feedback' ,
66
- data : { feedbackId : expect . any ( String ) } ,
67
- timestamp : expect . any ( Number ) ,
68
- type : 'default' ,
69
- } ) ,
70
- ] ) ,
71
- ) ;
64
+ expect ( breadcrumbs ) . toEqual (
65
+ expect . arrayContaining ( [
66
+ expect . objectContaining ( {
67
+ category : 'sentry.feedback' ,
68
+ data : { feedbackId : expect . any ( String ) } ,
69
+ timestamp : expect . any ( Number ) ,
70
+ type : 'default' ,
71
+ } ) ,
72
+ ] ) ,
73
+ ) ;
72
74
73
- expect ( feedbackEvent ) . toEqual ( {
74
- type : 'feedback' ,
75
- breadcrumbs : expect . any ( Array ) ,
76
- contexts : {
77
- feedback : {
78
- contact_email :
'[email protected] ' ,
79
- message : 'my example feedback' ,
80
- name : 'Jane Doe' ,
81
- replay_id : replayEvent . event_id ,
82
- source : 'widget' ,
83
- url : expect . stringContaining ( '/dist/index.html' ) ,
75
+ expect ( feedbackEvent ) . toEqual ( {
76
+ type : 'feedback' ,
77
+ breadcrumbs : expect . any ( Array ) ,
78
+ contexts : {
79
+ feedback : {
80
+ contact_email :
'[email protected] ' ,
81
+ message : 'my example feedback' ,
82
+ name : 'Jane Doe' ,
83
+ replay_id : replayEvent . event_id ,
84
+ source : 'widget' ,
85
+ url : expect . stringContaining ( '/dist/index.html' ) ,
86
+ } ,
87
+ } ,
88
+ level : 'info' ,
89
+ timestamp : expect . any ( Number ) ,
90
+ event_id : expect . stringMatching ( / \w { 32 } / ) ,
91
+ environment : 'production' ,
92
+ sdk : {
93
+ integrations : expect . arrayContaining ( [ 'Feedback' ] ) ,
94
+ version : expect . any ( String ) ,
95
+ name : 'sentry.javascript.browser' ,
96
+ packages : expect . anything ( ) ,
84
97
} ,
85
- } ,
86
- level : 'info' ,
87
- timestamp : expect . any ( Number ) ,
88
- event_id : expect . stringMatching ( / \w { 32 } / ) ,
89
- environment : 'production' ,
90
- sdk : {
91
- integrations : expect . arrayContaining ( [ 'Feedback' ] ) ,
92
- version : expect . any ( String ) ,
93
- name : 'sentry.javascript.browser' ,
94
- packages : expect . anything ( ) ,
95
- } ,
96
- request : {
97
- url : expect . stringContaining ( '/dist/index.html' ) ,
98
- headers : {
99
- 'User-Agent' : expect . stringContaining ( '' ) ,
98
+ request : {
99
+ url : expect . stringContaining ( '/dist/index.html' ) ,
100
+ headers : {
101
+ 'User-Agent' : expect . stringContaining ( '' ) ,
102
+ } ,
100
103
} ,
101
- } ,
102
- platform : 'javascript' ,
103
- } ) ;
104
- } ) ;
104
+ platform : 'javascript' ,
105
+ } ) ;
106
+ } ,
107
+ ) ;
0 commit comments