Skip to content

Commit 2a7ecba

Browse files
committed
Create user on every test block instead of on hook
1 parent fc8b706 commit 2a7ecba

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

integration/tests/session-tasks-sign-in.test.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
1313
test.describe.configure({ mode: 'serial' });
1414

1515
let fakeUser: FakeUser;
16-
17-
test.beforeAll(async () => {
18-
const u = createTestUtils({ app });
19-
fakeUser = u.services.users.createFakeUser();
20-
await u.services.users.createBapiUser(fakeUser);
21-
});
22-
2316
test.afterAll(async () => {
2417
const u = createTestUtils({ app });
2518
await fakeUser.deleteIfExists();
@@ -29,6 +22,8 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
2922

3023
test('with email and password, navigate to task on after sign-in', async ({ page, context }) => {
3124
const u = createTestUtils({ app, page, context });
25+
fakeUser = u.services.users.createFakeUser();
26+
await u.services.users.createBapiUser(fakeUser);
3227

3328
// Performs sign-in
3429
await u.po.signIn.goTo();
@@ -87,5 +82,34 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
8782
// Delete the user on the app instance.
8883
await u.services.users.deleteIfExists({ email: fakeUser.email });
8984
});
85+
86+
test('when switching sessions, navigate to task', async ({ page, context }) => {
87+
const u = createTestUtils({ app, page, context });
88+
fakeUser = u.services.users.createFakeUser();
89+
await u.services.users.createBapiUser(fakeUser);
90+
91+
// Create user for second session
92+
const fakeUser2 = u.services.users.createFakeUser();
93+
await u.services.users.createBapiUser(fakeUser2);
94+
95+
// Performs sign-in
96+
await u.po.signIn.goTo();
97+
await u.po.signIn.setIdentifier(fakeUser.email);
98+
await u.po.signIn.continue();
99+
await u.po.signIn.setPassword(fakeUser.password);
100+
await u.po.signIn.continue();
101+
await u.po.expect.toBeSignedIn();
102+
103+
// Resolves task
104+
const fakeOrganization = u.services.organizations.createFakeOrganization();
105+
await u.po.sessionTask.resolveForceOrganizationSelectionTask(fakeOrganization);
106+
await u.po.expect.toHaveResolvedTask();
107+
108+
// Navigates to after sign-in
109+
await u.page.waitForAppUrl('/');
110+
111+
await u.po.userButton.toggleTrigger();
112+
await u.po.userButton.waitForPopover();
113+
});
90114
},
91115
);

integration/tests/session-tasks-sign-up.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
1313
test.describe.configure({ mode: 'serial' });
1414

1515
let fakeUser: FakeUser;
16-
17-
test.beforeAll(() => {
18-
const u = createTestUtils({ app });
19-
fakeUser = u.services.users.createFakeUser({
20-
fictionalEmail: true,
21-
withPhoneNumber: true,
22-
withUsername: true,
23-
});
24-
});
25-
2616
test.afterAll(async () => {
2717
const u = createTestUtils({ app });
2818
await u.services.organizations.deleteAll();
@@ -33,6 +23,12 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withSessionTasks] })(
3323
test('navigate to task on after sign-up', async ({ page, context }) => {
3424
// Performs sign-up
3525
const u = createTestUtils({ app, page, context });
26+
fakeUser = u.services.users.createFakeUser({
27+
fictionalEmail: true,
28+
withPhoneNumber: true,
29+
withUsername: true,
30+
});
31+
3632
await u.po.signUp.goTo();
3733
await u.po.signUp.signUpWithEmailAndPassword({
3834
email: fakeUser.email,

0 commit comments

Comments
 (0)