@@ -30,14 +30,14 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
3030 await app . teardown ( ) ;
3131 } ) ;
3232
33- test . afterEach ( async ( { page, context } ) => {
33+ test ( 'when switching sessions, navigate to task' , async ( { page, context } ) => {
3434 const u = createTestUtils ( { app, page, context } ) ;
35- await u . page . signOut ( ) ;
36- await u . page . context ( ) . clearCookies ( ) ;
37- } ) ;
3835
39- test . skip ( 'when switching sessions, navigate to task' , async ( { page, context } ) => {
40- const u = createTestUtils ( { app, page, context } ) ;
36+ // TODO -> Figure out why test is flaky on Next.js 14
37+ if ( u . nextJsVersion === '14' ) {
38+ test . skip ( ) ;
39+ return ;
40+ }
4141
4242 // Performs sign-in
4343 await u . po . signIn . goTo ( ) ;
@@ -82,15 +82,22 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
8282 await u . po . userButton . waitForPopover ( ) ;
8383 await u . po . userButton . toHaveVisibleMenuItems ( [ / M a n a g e a c c o u n t / i, / S i g n o u t $ / i] ) ;
8484 await u . po . userButton . switchAccount ( user2 . email ) ;
85+ await u . po . userButton . waitForPopoverClosed ( ) ;
8586
86- // Resolve task
87+ // Wait for sign-in component to be mounted after switching accounts
8788 await u . po . signIn . waitForMounted ( ) ;
89+ await page . waitForURL ( / t a s k s / ) ;
90+
91+ // Resolve task
8892 const fakeOrganization2 = u . services . organizations . createFakeOrganization ( ) ;
8993 await u . po . sessionTask . resolveForceOrganizationSelectionTask ( fakeOrganization2 ) ;
9094 await u . po . expect . toHaveResolvedTask ( ) ;
9195
9296 // Navigates to after sign-in
9397 await u . page . waitForAppUrl ( '/' ) ;
98+
99+ await u . page . signOut ( ) ;
100+ await u . page . context ( ) . clearCookies ( ) ;
94101 } ) ;
95102 } ,
96103) ;
0 commit comments