@@ -16,103 +16,105 @@ function isInputMutation(
1616 return snap . data . source == IncrementalSource . Input ;
1717}
1818
19- sentryTest (
20- 'should mask input initial value and its changes from `maskAllInputs` and allow unmasked selector' ,
21- async ( { browserName, forceFlushReplay, getLocalTestPath, page } ) => {
22- // TODO(replay): This is flakey on firefox and webkit (~1%) where we do not always get the latest mutation.
23- if ( shouldSkipReplayTest ( ) || [ 'firefox' , 'webkit' ] . includes ( browserName ) ) {
24- sentryTest . skip ( ) ;
25- }
26-
27- // We want to ensure to check the correct event payloads
28- let firstInputMutationSegmentId : number | undefined = undefined ;
29- const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
30- const reqPromise1 = waitForReplayRequest ( page , ( event , res ) => {
31- const check =
32- firstInputMutationSegmentId === undefined && getIncrementalRecordingSnapshots ( res ) . some ( isInputMutation ) ;
33-
34- if ( check ) {
35- firstInputMutationSegmentId = event . segment_id ;
19+ for ( let i = 0 ; i < 100 ; i ++ ) {
20+ sentryTest (
21+ `should mask input initial value and its changes from \`maskAllInputs\` and allow unmasked selector RUN ${ i } ` ,
22+ async ( { browserName, forceFlushReplay, getLocalTestPath, page } ) => {
23+ // TODO(replay): This is flakey on firefox and webkit (~1%) where we do not always get the latest mutation.
24+ if ( shouldSkipReplayTest ( ) || [ 'firefox' , 'webkit' ] . includes ( browserName ) ) {
25+ sentryTest . skip ( ) ;
3626 }
3727
38- return check ;
39- } ) ;
40- const reqPromise2 = waitForReplayRequest ( page , ( event , res ) => {
41- return (
42- typeof firstInputMutationSegmentId === 'number' &&
43- firstInputMutationSegmentId < event . segment_id &&
44- getIncrementalRecordingSnapshots ( res ) . some ( isInputMutation )
45- ) ;
46- } ) ;
47-
48- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
49- return route . fulfill ( {
50- status : 200 ,
51- contentType : 'application/json' ,
52- body : JSON . stringify ( { id : 'test-id' } ) ,
28+ // We want to ensure to check the correct event payloads
29+ let firstInputMutationSegmentId : number | undefined = undefined ;
30+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
31+ const reqPromise1 = waitForReplayRequest ( page , ( event , res ) => {
32+ const check =
33+ firstInputMutationSegmentId === undefined && getIncrementalRecordingSnapshots ( res ) . some ( isInputMutation ) ;
34+
35+ if ( check ) {
36+ firstInputMutationSegmentId = event . segment_id ;
37+ }
38+
39+ return check ;
40+ } ) ;
41+ const reqPromise2 = waitForReplayRequest ( page , ( event , res ) => {
42+ return (
43+ typeof firstInputMutationSegmentId === 'number' &&
44+ firstInputMutationSegmentId < event . segment_id &&
45+ getIncrementalRecordingSnapshots ( res ) . some ( isInputMutation )
46+ ) ;
47+ } ) ;
48+
49+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
50+ return route . fulfill ( {
51+ status : 200 ,
52+ contentType : 'application/json' ,
53+ body : JSON . stringify ( { id : 'test-id' } ) ,
54+ } ) ;
5355 } ) ;
54- } ) ;
55-
56- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
57-
58- await page . goto ( url ) ;
59- await reqPromise0 ;
60-
61- const text = 'test' ;
62-
63- await page . locator ( '#input' ) . fill ( text ) ;
64- await forceFlushReplay ( ) ;
65-
66- const snapshots = getIncrementalRecordingSnapshots ( await reqPromise1 ) . filter ( isInputMutation ) ;
67- const lastSnapshot = snapshots [ snapshots . length - 1 ] ;
68- expect ( lastSnapshot . data . text ) . toBe ( '*' . repeat ( text . length ) ) ;
69-
70- await page . locator ( '#input-unmasked' ) . fill ( text ) ;
71- await forceFlushReplay ( ) ;
72- const snapshots2 = getIncrementalRecordingSnapshots ( await reqPromise2 ) . filter ( isInputMutation ) ;
73- const lastSnapshot2 = snapshots2 [ snapshots2 . length - 1 ] ;
74- expect ( lastSnapshot2 . data . text ) . toBe ( text ) ;
75- } ,
76- ) ;
77-
78- sentryTest (
79- 'should mask textarea initial value and its changes from `maskAllInputs` and allow unmasked selector' ,
80- async ( { browserName , forceFlushReplay , getLocalTestPath , page } ) => {
81- // TODO(replay): This is flakey on firefox and webkit (~1%) where we do not always get the latest mutation.
82- if ( shouldSkipReplayTest ( ) || [ 'firefox' , 'webkit' ] . includes ( browserName ) ) {
83- sentryTest . skip ( ) ;
84- }
85-
86- const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
87- const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
88- const reqPromise2 = waitForReplayRequest ( page , 2 ) ;
89-
90- await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
91- return route . fulfill ( {
92- status : 200 ,
93- contentType : 'application/json' ,
94- body : JSON . stringify ( { id : 'test-id' } ) ,
56+
57+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
58+
59+ await page . goto ( url ) ;
60+ await reqPromise0 ;
61+
62+ const text = 'test' ;
63+
64+ await page . locator ( '#input' ) . fill ( text ) ;
65+ await forceFlushReplay ( ) ;
66+
67+ const snapshots = getIncrementalRecordingSnapshots ( await reqPromise1 ) . filter ( isInputMutation ) ;
68+ const lastSnapshot = snapshots [ snapshots . length - 1 ] ;
69+ expect ( lastSnapshot . data . text ) . toBe ( '*' . repeat ( text . length ) ) ;
70+
71+ await page . locator ( '#input-unmasked' ) . fill ( text ) ;
72+ await forceFlushReplay ( ) ;
73+ const snapshots2 = getIncrementalRecordingSnapshots ( await reqPromise2 ) . filter ( isInputMutation ) ;
74+ const lastSnapshot2 = snapshots2 [ snapshots2 . length - 1 ] ;
75+ expect ( lastSnapshot2 . data . text ) . toBe ( text ) ;
76+ } ,
77+ ) ;
78+
79+ sentryTest (
80+ `should mask textarea initial value and its changes from \`maskAllInputs\` and allow unmasked selector RUN ${ i } ` ,
81+ async ( { browserName , forceFlushReplay , getLocalTestPath , page } ) => {
82+ // TODO(replay): This is flakey on firefox and webkit (~1%) where we do not always get the latest mutation.
83+ if ( shouldSkipReplayTest ( ) || [ ' firefox' , ' webkit' ] . includes ( browserName ) ) {
84+ sentryTest . skip ( ) ;
85+ }
86+
87+ const reqPromise0 = waitForReplayRequest ( page , 0 ) ;
88+ const reqPromise1 = waitForReplayRequest ( page , 1 ) ;
89+ const reqPromise2 = waitForReplayRequest ( page , 2 ) ;
90+
91+ await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
92+ return route . fulfill ( {
93+ status : 200 ,
94+ contentType : 'application/json' ,
95+ body : JSON . stringify ( { id : 'test-id' } ) ,
96+ } ) ;
9597 } ) ;
96- } ) ;
9798
98- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
99+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
99100
100- await page . goto ( url ) ;
101+ await page . goto ( url ) ;
101102
102- await reqPromise0 ;
103+ await reqPromise0 ;
103104
104- const text = 'test' ;
105+ const text = 'test' ;
105106
106- await page . locator ( '#textarea' ) . fill ( text ) ;
107- await forceFlushReplay ( ) ;
108- const snapshots = getIncrementalRecordingSnapshots ( await reqPromise1 ) . filter ( isInputMutation ) ;
109- const lastSnapshot = snapshots [ snapshots . length - 1 ] ;
110- expect ( lastSnapshot . data . text ) . toBe ( '*' . repeat ( text . length ) ) ;
107+ await page . locator ( '#textarea' ) . fill ( text ) ;
108+ await forceFlushReplay ( ) ;
109+ const snapshots = getIncrementalRecordingSnapshots ( await reqPromise1 ) . filter ( isInputMutation ) ;
110+ const lastSnapshot = snapshots [ snapshots . length - 1 ] ;
111+ expect ( lastSnapshot . data . text ) . toBe ( '*' . repeat ( text . length ) ) ;
111112
112- await page . locator ( '#textarea-unmasked' ) . fill ( text ) ;
113- await forceFlushReplay ( ) ;
114- const snapshots2 = getIncrementalRecordingSnapshots ( await reqPromise2 ) . filter ( isInputMutation ) ;
115- const lastSnapshot2 = snapshots2 [ snapshots2 . length - 1 ] ;
116- expect ( lastSnapshot2 . data . text ) . toBe ( text ) ;
117- } ,
118- ) ;
113+ await page . locator ( '#textarea-unmasked' ) . fill ( text ) ;
114+ await forceFlushReplay ( ) ;
115+ const snapshots2 = getIncrementalRecordingSnapshots ( await reqPromise2 ) . filter ( isInputMutation ) ;
116+ const lastSnapshot2 = snapshots2 [ snapshots2 . length - 1 ] ;
117+ expect ( lastSnapshot2 . data . text ) . toBe ( text ) ;
118+ } ,
119+ ) ;
120+ }
0 commit comments