11import { expect , test } from '@playwright/test' ;
22
3- import { createClerkClient } from '@clerk/backend' ;
43import { appConfigs } from '../presets' ;
5- import { instanceKeys } from '../presets/envs' ;
64import type { FakeUser } from '../testUtils' ;
75import { createTestUtils , testAgainstRunningApps } from '../testUtils' ;
8- import { createUserService } from '../testUtils/usersService' ;
96
107testAgainstRunningApps ( { withEnv : [ appConfigs . envs . withSessionTasks ] } ) (
118 'session tasks after sign-up flow @nextjs' ,
129 ( { app } ) => {
1310 test . describe . configure ( { mode : 'serial' } ) ;
1411
1512 let fakeUser : FakeUser ;
13+
14+ test . beforeAll ( ( ) => {
15+ const u = createTestUtils ( { app } ) ;
16+ fakeUser = u . services . users . createFakeUser ( {
17+ fictionalEmail : true ,
18+ withPhoneNumber : true ,
19+ withUsername : true ,
20+ } ) ;
21+ } ) ;
22+
1623 test . afterAll ( async ( ) => {
1724 const u = createTestUtils ( { app } ) ;
1825 await u . services . organizations . deleteAll ( ) ;
@@ -23,11 +30,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
2330 test ( 'navigate to task on after sign-up' , async ( { page, context } ) => {
2431 // Performs sign-up
2532 const u = createTestUtils ( { app, page, context } ) ;
26- fakeUser = u . services . users . createFakeUser ( {
27- fictionalEmail : true ,
28- withPhoneNumber : true ,
29- withUsername : true ,
30- } ) ;
3133
3234 await u . po . signUp . goTo ( ) ;
3335 await u . po . signUp . signUpWithEmailAndPassword ( {
@@ -48,42 +50,5 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
4850 // Navigates to after sign-up
4951 await u . page . waitForAppUrl ( '/' ) ;
5052 } ) ;
51-
52- test ( 'with sso, navigate to task on after sign-up' , async ( { page, context } ) => {
53- const u = createTestUtils ( { app, page, context } ) ;
54-
55- // Create a clerkClient for the OAuth provider instance
56- const client = createClerkClient ( {
57- secretKey : instanceKeys . get ( 'oauth-provider' ) . sk ,
58- publishableKey : instanceKeys . get ( 'oauth-provider' ) . pk ,
59- } ) ;
60- const users = createUserService ( client ) ;
61- fakeUser = users . createFakeUser ( {
62- withUsername : true ,
63- } ) ;
64- // Create the user on the OAuth provider instance so we do not need to sign up twice
65- await users . createBapiUser ( fakeUser ) ;
66-
67- // Performs sign-up (transfer flow with sign-in) with SSO
68- await u . po . signIn . goTo ( ) ;
69- await u . page . getByRole ( 'button' , { name : 'E2E OAuth Provider' } ) . click ( ) ;
70- await u . page . getByText ( 'Sign in to oauth-provider' ) . waitFor ( ) ;
71- await u . po . signIn . setIdentifier ( fakeUser . email ) ;
72- await u . po . signIn . continue ( ) ;
73- await u . po . signIn . enterTestOtpCode ( ) ;
74-
75- // Resolves task
76- const fakeOrganization = u . services . organizations . createFakeOrganization ( ) ;
77- await u . po . sessionTask . resolveForceOrganizationSelectionTask ( fakeOrganization ) ;
78- await u . po . expect . toHaveResolvedTask ( ) ;
79-
80- // Navigates to after sign-up
81- await u . page . waitForAppUrl ( '/' ) ;
82-
83- // Delete the user on the OAuth provider instance
84- await fakeUser . deleteIfExists ( ) ;
85- // Delete the user on the app instance.
86- await u . services . users . deleteIfExists ( { email : fakeUser . email } ) ;
87- } ) ;
8853 } ,
8954) ;
0 commit comments