forked from clerk/javascript
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail-code.test.ts
51 lines (43 loc) · 1.81 KB
/
email-code.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
import { test } from '@playwright/test';
import type { Application } from '../models/application';
import { appConfigs } from '../presets';
import type { FakeUser } from '../testUtils';
import { createTestUtils } from '../testUtils';
test.describe('sign up and sign in with email code', () => {
const configs = [];
configs.forEach(config => {
test.describe(`${config.name}`, () => {
test.describe.configure({ mode: 'serial' });
let app: Application;
let fakeUser: FakeUser;
test.beforeAll(async () => {
app = await config.commit();
await app.setup();
await app.withEnv(appConfigs.envs.withEmailCodes);
await app.dev();
fakeUser = createTestUtils({ app }).services.users.createFakeUser();
});
test.afterAll(async () => {
await fakeUser.deleteIfExists();
await app.teardown();
});
test('sign up', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
await u.po.signUp.goTo();
await u.po.signUp.signUpWithEmailAndPassword({ email: fakeUser.email, password: fakeUser.password });
await u.po.signUp.enterOtpCode(await u.services.email.getCodeForEmailAddress(fakeUser.email));
await u.po.expect.toBeSignedIn();
});
test('sign in', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
await u.po.signIn.goTo();
await u.po.signIn.getIdentifierInput().fill(fakeUser.email);
await u.po.signIn.continue();
await u.po.signIn.getUseAnotherMethodLink().click();
await u.po.signIn.getAltMethodsEmailCodeButton().click();
await u.po.signIn.enterOtpCode(await u.services.email.getCodeForEmailAddress(fakeUser.email));
await u.po.expect.toBeSignedIn();
});
});
});
});