-
Notifications
You must be signed in to change notification settings - Fork 327
/
Copy pathnavigation.test.ts
64 lines (49 loc) · 2.07 KB
/
navigation.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { test } from '@playwright/test';
import type { FakeUser } from '../testUtils';
import { createTestUtils, testAgainstRunningApps } from '../testUtils';
testAgainstRunningApps({ withPattern: ['next.appRouter.withEmailCodes'] })('navigation modes @generic', ({ app }) => {
test.describe.configure({ mode: 'serial' });
let fakeUser: FakeUser;
test.beforeAll(async () => {
const m = createTestUtils({ app });
fakeUser = m.services.users.createFakeUser();
await m.services.users.createBapiUser(fakeUser);
});
test.afterAll(async () => {
await fakeUser.deleteIfExists();
await app.teardown();
});
test('sign in with path routing', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
await u.po.signIn.goTo();
await u.po.signIn.waitForMounted();
await u.po.signIn.setIdentifier(fakeUser.email);
await u.po.signIn.continue();
await u.page.waitForURL(`${app.serverUrl}/sign-in/factor-one`);
await u.po.signIn.setPassword(fakeUser.password);
await u.po.signIn.continue();
await u.po.expect.toBeSignedIn();
});
test('sign in with hash routing', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
await u.page.goToRelative('/hash/sign-in');
await u.po.signIn.waitForMounted();
await u.po.signIn.setIdentifier(fakeUser.email);
await u.po.signIn.continue();
await u.page.waitForURL(`${app.serverUrl}/hash/sign-in#/factor-one`);
await u.po.signIn.setPassword(fakeUser.password);
await u.po.signIn.continue();
await u.po.expect.toBeSignedIn();
});
test('sign in with path routing navigates to previous page', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
await u.po.signIn.goTo();
await u.po.signIn.waitForMounted();
await u.po.signIn.getGoToSignUp().click();
await u.po.signUp.waitForMounted();
await u.page.waitForURL(`${app.serverUrl}/sign-up`);
await page.goBack();
await u.po.signIn.waitForMounted();
await u.page.waitForURL(`${app.serverUrl}/sign-in`);
});
});