-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcookies.spec.ts
83 lines (66 loc) · 2.25 KB
/
cookies.spec.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { delay } from 'msw';
import { LoginForm } from '../models/login-form';
import { test } from '../test';
test.describe.parallel('cookies', () => {
test('should not have a session cookie if the user has not logged in yet', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.assertSessionStatus(401);
});
test('should still have a valid session if the user refreshes the page after logging in', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.loginWithValidCredentials();
await delay(500);
// Reload the page
await page.reload();
await loginForm.assertSessionStatus(200);
});
test('should allow the user to clear their session by logging out', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.loginWithValidCredentials();
await loginForm.assertSessionStatus(200);
await loginForm.logout();
await loginForm.assertSessionStatus(401);
});
test('should display an invalid credentials message if the user enters incorrect credentials', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.loginWithInvalidCredentials();
await loginForm.assertError(LoginForm.Error.InvalidCredentials);
});
test('should display a success message if the user successfully logs in', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.loginWithValidCredentials();
await loginForm.assertSuccessful();
});
test.describe.serial('when running sequentially', () => {
test('should have a valid session once the user logs in', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.loginWithValidCredentials();
await loginForm.assertSessionStatus(200);
});
test('should not have a session from the previous test run', async ({
page,
}) => {
await page.goto('/login');
const loginForm = new LoginForm(page);
await loginForm.assertSessionStatus(401);
});
});
});