1
1
import { expect , test } from '@playwright/test' ;
2
2
3
- import { createClerkClient } from '@clerk/backend' ;
4
3
import { appConfigs } from '../presets' ;
5
- import { instanceKeys } from '../presets/envs' ;
6
4
import type { FakeUser } from '../testUtils' ;
7
5
import { createTestUtils , testAgainstRunningApps } from '../testUtils' ;
8
- import { createUserService } from '../testUtils/usersService' ;
9
6
10
7
testAgainstRunningApps ( { withEnv : [ appConfigs . envs . withSessionTasks ] } ) (
11
8
'session tasks after sign-up flow @nextjs' ,
12
9
( { app } ) => {
13
10
test . describe . configure ( { mode : 'serial' } ) ;
14
11
15
12
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
+
16
23
test . afterAll ( async ( ) => {
17
24
const u = createTestUtils ( { app } ) ;
18
25
await u . services . organizations . deleteAll ( ) ;
@@ -23,11 +30,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
23
30
test ( 'navigate to task on after sign-up' , async ( { page, context } ) => {
24
31
// Performs sign-up
25
32
const u = createTestUtils ( { app, page, context } ) ;
26
- fakeUser = u . services . users . createFakeUser ( {
27
- fictionalEmail : true ,
28
- withPhoneNumber : true ,
29
- withUsername : true ,
30
- } ) ;
31
33
32
34
await u . po . signUp . goTo ( ) ;
33
35
await u . po . signUp . signUpWithEmailAndPassword ( {
@@ -48,42 +50,5 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
48
50
// Navigates to after sign-up
49
51
await u . page . waitForAppUrl ( '/' ) ;
50
52
} ) ;
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
- } ) ;
88
53
} ,
89
54
) ;
0 commit comments