@@ -163,6 +163,23 @@ describe('pause', (suite, { mode }) => {
163
163
await scriptPromise ;
164
164
} ) ;
165
165
166
+ it ( 'should highlight waitForEvent' , async ( { page, recorderPageGetter} ) => {
167
+ await page . setContent ( '<button onclick="console.log(1)">Submit</button>' ) ;
168
+ const scriptPromise = ( async ( ) => {
169
+ await page . pause ( ) ;
170
+ await Promise . all ( [
171
+ page . waitForEvent ( 'console' ) ,
172
+ page . click ( 'button' ) ,
173
+ ] ) ;
174
+ } ) ( ) ;
175
+ const recorderPage = await recorderPageGetter ( ) ;
176
+ await recorderPage . click ( '[title="Step over"]' ) ;
177
+ await recorderPage . waitForSelector ( '.source-line-paused:has-text("page.click")' ) ;
178
+ await recorderPage . waitForSelector ( '.source-line-running:has-text("page.waitForEvent")' ) ;
179
+ await recorderPage . click ( '[title="Resume"]' ) ;
180
+ await scriptPromise ;
181
+ } ) ;
182
+
166
183
it ( 'should populate log with waitForEvent' , async ( { page, recorderPageGetter} ) => {
167
184
await page . setContent ( '<button onclick="console.log(1)">Submit</button>' ) ;
168
185
const scriptPromise = ( async ( ) => {
@@ -178,7 +195,7 @@ describe('pause', (suite, { mode }) => {
178
195
await recorderPage . waitForSelector ( '.source-line-paused:has-text("page.pause(); // 2")' ) ;
179
196
expect ( await sanitizeLog ( recorderPage ) ) . toEqual ( [
180
197
'page.pause- XXms' ,
181
- 'page.waitForEvent(console)- XXms ' ,
198
+ 'page.waitForEvent(console)' ,
182
199
'page.click(button)- XXms' ,
183
200
'page.pause' ,
184
201
] ) ;
@@ -200,12 +217,36 @@ describe('pause', (suite, { mode }) => {
200
217
'page.isChecked(button)- XXms' ,
201
218
'checking \"checked\" state of \"button\"' ,
202
219
'selector resolved to <button onclick=\"console.log(1)\">Submit</button>' ,
203
- 'Not a checkbox or radio button' ,
220
+ 'error: Not a checkbox or radio button' ,
204
221
] ) ;
205
222
const error = await scriptPromise ;
206
223
expect ( error . message ) . toContain ( 'Not a checkbox or radio button' ) ;
207
224
} ) ;
208
225
226
+ it ( 'should populate log with error in waitForEvent' , async ( { page, recorderPageGetter} ) => {
227
+ await page . setContent ( '<button>Submit</button>' ) ;
228
+ const scriptPromise = ( async ( ) => {
229
+ await page . pause ( ) ;
230
+ await Promise . all ( [
231
+ page . waitForEvent ( 'console' , { timeout : 1 } ) ,
232
+ page . click ( 'button' ) ,
233
+ ] ) ;
234
+ } ) ( ) . catch ( ( ) => { } ) ;
235
+ const recorderPage = await recorderPageGetter ( ) ;
236
+ await recorderPage . click ( '[title="Step over"]' ) ;
237
+ await recorderPage . waitForSelector ( '.source-line-paused:has-text("page.click")' ) ;
238
+ await recorderPage . waitForSelector ( '.source-line-error:has-text("page.waitForEvent")' ) ;
239
+ await recorderPage . click ( '[title="Resume"]' ) ;
240
+ expect ( await sanitizeLog ( recorderPage ) ) . toEqual ( [
241
+ 'page.pause- XXms' ,
242
+ 'page.waitForEvent(console)' ,
243
+ 'waiting for event \"console\"' ,
244
+ 'error: Timeout while waiting for event \"console\"' ,
245
+ 'page.click(button)- XXms' ,
246
+ ] ) ;
247
+ await scriptPromise ;
248
+ } ) ;
249
+
209
250
it ( 'should pause on page close' , async ( { page, recorderPageGetter } ) => {
210
251
const scriptPromise = ( async ( ) => {
211
252
await page . pause ( ) ;
@@ -234,13 +275,11 @@ describe('pause', (suite, { mode }) => {
234
275
async function sanitizeLog ( recorderPage : Page ) : Promise < string [ ] > {
235
276
const results = [ ] ;
236
277
for ( const entry of await recorderPage . $$ ( '.call-log-call' ) ) {
237
- const header = await ( await ( await entry . $ ( '.call-log-call-header' ) ) . textContent ( ) ) . replace ( / — \d + ( \. \d + ) ? ( m s | s ) / , '- XXms' ) ;
238
- results . push ( header ) ;
239
- results . push ( ...await entry . $$eval ( '.call-log-message' , ee => ee . map ( e => e . textContent ) ) ) ;
240
- const errorElement = await entry . $ ( '.call-log-error' ) ;
241
- const error = errorElement ? await errorElement . textContent ( ) : undefined ;
242
- if ( error )
243
- results . push ( error ) ;
278
+ const header = ( await ( await entry . $ ( '.call-log-call-header' ) ) . textContent ( ) ) . replace ( / — [ \d . ] + ( m s | s ) / , '- XXms' ) ;
279
+ results . push ( header . replace ( / p a g e \. w a i t F o r E v e n t \( c o n s o l e \) .* / , 'page.waitForEvent(console)' ) ) ;
280
+ results . push ( ...await entry . $$eval ( '.call-log-message' , ee => ee . map ( e => {
281
+ return ( e . classList . contains ( 'error' ) ? 'error: ' : '' ) + e . textContent ;
282
+ } ) ) ) ;
244
283
}
245
284
return results ;
246
285
}
0 commit comments