@@ -151,44 +151,53 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign in f
151151 await u . po . expect . toBeSignedIn ( ) ;
152152 } ) ;
153153
154- test ( 'redirects when attempting to sign in with existing session' , async ( { page, context } ) => {
155- const u = createTestUtils ( { app, page, context } ) ;
154+ test ( 'redirects when attempting to sign in with existing session in another tab' , async ( {
155+ page,
156+ context,
157+ browser,
158+ } ) => {
159+ const u = createTestUtils ( { app, page, context, browser } ) ;
156160
157- // First, sign in the user
161+ // Sign in on the first tab
158162 await u . po . signIn . goTo ( ) ;
159163 await u . po . signIn . setIdentifier ( fakeUser . email ) ;
160164 await u . po . signIn . continue ( ) ;
161165 await u . po . signIn . setPassword ( fakeUser . password ) ;
162166 await u . po . signIn . continue ( ) ;
163167 await u . po . expect . toBeSignedIn ( ) ;
164168
165- // Now attempt to go to sign-in page again while already signed in
166- await u . po . signIn . goTo ( ) ;
169+ // Open a new tab and attempt to sign in again with the same user
170+ await u . tabs . runInNewTab ( async u2 => {
171+ await u2 . po . signIn . goTo ( ) ;
172+ await u2 . po . signIn . setIdentifier ( fakeUser . email ) ;
173+ await u2 . po . signIn . continue ( ) ;
174+ await u2 . po . signIn . setPassword ( fakeUser . password ) ;
175+ await u2 . po . signIn . continue ( ) ;
167176
168- // User should be redirected and remain signed in instead of seeing an error
169- await u . po . expect . toBeSignedIn ( ) ;
177+ // Should redirect and be signed in without error
178+ await u2 . po . expect . toBeSignedIn ( ) ;
179+ } ) ;
170180 } ) ;
171181
172- test ( 'redirects when attempting to sign in again with instant password and existing session ' , async ( {
182+ test ( 'redirects when attempting to sign in again with instant password in another tab ' , async ( {
173183 page,
174184 context,
185+ browser,
175186 } ) => {
176- const u = createTestUtils ( { app, page, context } ) ;
187+ const u = createTestUtils ( { app, page, context, browser } ) ;
177188
178- // First, sign in the user
189+ // Sign in on the first tab
179190 await u . po . signIn . goTo ( ) ;
180191 await u . po . signIn . signInWithEmailAndInstantPassword ( { email : fakeUser . email , password : fakeUser . password } ) ;
181192 await u . po . expect . toBeSignedIn ( ) ;
182193
183- // Clear the page to go back to sign-in
184- await u . page . goToRelative ( '/' ) ;
185- await u . po . expect . toBeSignedIn ( ) ;
194+ // Open a new tab and attempt to sign in again with instant password
195+ await u . tabs . runInNewTab ( async u2 => {
196+ await u2 . po . signIn . goTo ( ) ;
197+ await u2 . po . signIn . signInWithEmailAndInstantPassword ( { email : fakeUser . email , password : fakeUser . password } ) ;
186198
187- // Attempt to sign in again with instant password
188- await u . po . signIn . goTo ( ) ;
189- await u . po . signIn . signInWithEmailAndInstantPassword ( { email : fakeUser . email , password : fakeUser . password } ) ;
190-
191- // Should redirect and remain signed in without error
192- await u . po . expect . toBeSignedIn ( ) ;
199+ // Should redirect and remain signed in without error
200+ await u2 . po . expect . toBeSignedIn ( ) ;
201+ } ) ;
193202 } ) ;
194203} ) ;
0 commit comments