@@ -59,7 +59,7 @@ sentryTest('captures multi click when not detecting slow click', async ({ getLoc
59
59
] ) ;
60
60
} ) ;
61
61
62
- sentryTest ( 'captures multiple multi clicks' , async ( { getLocalTestUrl, page } ) => {
62
+ sentryTest ( 'captures multiple multi clicks' , async ( { getLocalTestUrl, page, forceFlushReplay } ) => {
63
63
if ( shouldSkipReplayTest ( ) ) {
64
64
sentryTest . skip ( ) ;
65
65
}
@@ -104,13 +104,18 @@ sentryTest('captures multiple multi clicks', async ({ getLocalTestUrl, page }) =
104
104
return check ;
105
105
} ) ;
106
106
107
+ const time = Date . now ( ) ;
108
+
107
109
await page . click ( '#mutationButtonImmediately' , { clickCount : 4 } ) ;
108
110
109
- await new Promise ( resolve => setTimeout ( resolve , 1001 ) ) ;
111
+ // Ensure we waited at least 1s, which is the threshold to create a new ui.click breadcrumb
112
+ await waitForFunction ( ( ) => Date . now ( ) - time > 1000 ) ;
110
113
111
114
await page . click ( '#mutationButtonImmediately' , { clickCount : 2 } ) ;
112
115
113
116
const { breadcrumbs } = getCustomRecordingEvents ( await reqPromise1 ) ;
117
+ await forceFlushReplay ( ) ;
118
+
114
119
const { breadcrumbs : breadcrumb2 } = getCustomRecordingEvents ( await reqPromise2 ) ;
115
120
116
121
const slowClickBreadcrumbs = breadcrumbs
@@ -160,3 +165,10 @@ sentryTest('captures multiple multi clicks', async ({ getLocalTestUrl, page }) =
160
165
} ,
161
166
] ) ;
162
167
} ) ;
168
+
169
+ async function waitForFunction ( cb : ( ) => boolean , timeout = 2000 , increment = 100 ) {
170
+ while ( timeout > 0 && ! cb ( ) ) {
171
+ await new Promise ( resolve => setTimeout ( resolve , increment ) ) ;
172
+ await waitForFunction ( cb , timeout - increment , increment ) ;
173
+ }
174
+ }
0 commit comments