@@ -156,10 +156,12 @@ export async function localizedScreenshots(
156
156
async function forEachLocale ( callback : ( localeCode : string ) => Promise < void > ) : Promise < void > {
157
157
for ( let i = 0 ; i < preset . locales . length ; i ++ ) {
158
158
const localeCode = preset . locales [ i ] ;
159
+ // Only switch the language if not already on the default
159
160
if ( i !== 0 ) await switchLanguage ( page , localeCode ) ;
160
161
await callback ( localeCode ) ;
161
162
}
162
- await switchLanguage ( page , 'en' ) ;
163
+ // Only switch back to the default language if there was another locale to switch to
164
+ if ( preset . locales . length > 1 ) await switchLanguage ( page , 'en' ) ;
163
165
}
164
166
165
167
await forEachLocale ( async locale => {
@@ -395,9 +397,10 @@ export async function localizedScreenshots(
395
397
await expect ( page . getByText ( 'Your draft is ready' ) ) . toBeVisible ( { timeout : 180_000 } ) ;
396
398
await page . reload ( ) ;
397
399
await installMouseFollower ( page ) ;
398
- // Wait for the draft status to start updating
400
+ // When the page first loads it will say "Your draft is ready", but then switch to saying it's finishing. Wait for a
401
+ // few seconds for it to no longer say "Your draft is ready", and then wait for it to say it's ready again
399
402
await page . waitForTimeout ( 5_000 ) ;
400
- await expect ( page . getByText ( 'Your draft is ready' ) ) . toBeVisible ( ) ;
403
+ await expect ( page . getByText ( 'Your draft is ready' ) ) . toBeVisible ( { timeout : 10_000 } ) ;
401
404
await expect ( page . getByText ( 'No books have any drafts' ) ) . not . toBeVisible ( ) ;
402
405
await expect ( page . getByText ( 'Draft is finishing' ) ) . not . toBeVisible ( ) ;
403
406
0 commit comments