@@ -7,8 +7,9 @@ import { expect, test } from '@playwright/test';
77
88const REPLAY_ALL_SELECTOR = '.replay-all-mode-wrapper' ;
99const TIME_DISPLAY_SELECTOR = `${ REPLAY_ALL_SELECTOR } .time-display` ;
10- const PLAYBACK_ADVANCE_TIMEOUT = 15_000 ;
11- const PLAYBACK_COMPLETE_TIMEOUT = 30_000 ;
10+ const PLAYBACK_ADVANCE_TIMEOUT = 30_000 ;
11+ const PLAYBACK_COMPLETE_TIMEOUT = 90_000 ;
12+ const PLAYBACK_POLL_INTERVAL = 500 ;
1213const TEST_TIMEOUT = 15 * 60 * 1000 ;
1314
1415function parseTimeText ( text : string ) : number {
@@ -50,7 +51,7 @@ async function waitForPlaybackToAdvance(
5051 if ( currentSeconds > previousSeconds ) {
5152 return currentSeconds ;
5253 }
53- await sleep ( 500 ) ;
54+ await sleep ( PLAYBACK_POLL_INTERVAL ) ;
5455 }
5556
5657 throw new Error (
@@ -61,19 +62,20 @@ async function waitForPlaybackToAdvance(
6162async function waitForPlaybackToReach (
6263 readCurrentSeconds : ( ) => Promise < number > ,
6364 targetSeconds : number ,
65+ timeoutMs : number ,
6466) : Promise < number > {
6567 const startTime = Date . now ( ) ;
6668
67- while ( Date . now ( ) - startTime < PLAYBACK_COMPLETE_TIMEOUT ) {
69+ while ( Date . now ( ) - startTime < timeoutMs ) {
6870 const currentSeconds = await readCurrentSeconds ( ) ;
6971 if ( currentSeconds >= targetSeconds ) {
7072 return currentSeconds ;
7173 }
72- await sleep ( 500 ) ;
74+ await sleep ( PLAYBACK_POLL_INTERVAL ) ;
7375 }
7476
7577 throw new Error (
76- `Replay time did not reach ${ targetSeconds } s within ${ PLAYBACK_COMPLETE_TIMEOUT } ms` ,
78+ `Replay time did not reach ${ targetSeconds } s within ${ timeoutMs } ms` ,
7779 ) ;
7880}
7981
@@ -115,6 +117,13 @@ test.describe('report replay-all', () => {
115117
116118 await reportPage . setViewportSize ( { width : 1440 , height : 900 } ) ;
117119 await reportPage . goto ( `file://${ reportFile } ` ) ;
120+ await reportPage . bringToFront ( ) ;
121+ await reportPage . waitForFunction (
122+ ( ) => document . visibilityState === 'visible' ,
123+ {
124+ timeout : 30_000 ,
125+ } ,
126+ ) ;
118127 await reportPage . waitForSelector ( REPLAY_ALL_SELECTOR , {
119128 timeout : 30_000 ,
120129 } ) ;
@@ -131,6 +140,10 @@ test.describe('report replay-all', () => {
131140 . innerText ( ) ;
132141 const { currentSeconds : initialSeconds , totalSeconds } =
133142 parsePlaybackTime ( initialTimeText . trim ( ) ) ;
143+ const completionTimeoutMs = Math . max (
144+ PLAYBACK_COMPLETE_TIMEOUT ,
145+ ( totalSeconds + 5 ) * 5_000 ,
146+ ) ;
134147
135148 const advancedSeconds = await waitForPlaybackToAdvance ( async ( ) => {
136149 const timeText = await reportPage
@@ -147,6 +160,7 @@ test.describe('report replay-all', () => {
147160 return parsePlaybackTime ( timeText . trim ( ) ) . currentSeconds ;
148161 } ,
149162 Math . max ( advancedSeconds + 1 , totalSeconds ) ,
163+ completionTimeoutMs ,
150164 ) ;
151165
152166 await sleep ( 1_000 ) ;
0 commit comments