forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal-setup.ts
41 lines (33 loc) · 1.32 KB
/
global-setup.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
import { execSync } from 'child_process';
import { test as setup } from '@playwright/test';
setup.describe('certifieduser', () => {
setup.use({ storageState: { cookies: [], origins: [] } });
setup.beforeAll(() => {
execSync('node ./tools/scripts/seed/seed-demo-user --certified-user ');
});
setup('can sign in', async ({ request }) => {
await request.get(process.env.API_LOCATION + '/signin');
await request.storageState({
path: 'playwright/.auth/certified-user.json'
});
});
});
setup.describe('developmentuser', () => {
// We need to make sure the development user does not have any cookies from the certified user.
// As the certified user now has the default storage state.
setup.use({ storageState: { cookies: [], origins: [] } });
// We can only sign in as a single user (one with email: '[email protected]'), so
// changing users means changing the record with that email in the database.
setup.beforeAll(() => {
execSync('node ./tools/scripts/seed/seed-demo-user');
});
setup.afterAll(() => {
execSync('node ./tools/scripts/seed/seed-demo-user --certified-user');
});
setup('can sign in', async ({ request }) => {
await request.get(process.env.API_LOCATION + '/signin');
await request.storageState({
path: 'playwright/.auth/development-user.json'
});
});
});