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
|
import { test as setup, expect } from '@playwright/test';
import { credentials } from './credentials.ts';
const rootFile = 'tests/e2e/.auth/root.json';
const adminFile = 'tests/e2e/.auth/admin.json';
const dozentFile = 'tests/e2e/.auth/dozent.json';
const tutorFile = 'tests/e2e/.auth/tutor.json';
const autorFile = 'tests/e2e/.auth/autor.json';
setup('authenticate as root', async ({ page }) => {
await login(page, credentials.root);
await page.context().storageState({ path: rootFile });
});
setup('authenticate as admin', async ({ page }) => {
await login(page, credentials.admin);
await page.context().storageState({ path: adminFile });
});
setup('authenticate as dozent', async ({ page }) => {
await login(page, credentials.dozent);
await page.context().storageState({ path: dozentFile });
});
setup('authenticate as tutor', async ({ page }) => {
await login(page, credentials.tutor);
await page.context().storageState({ path: tutorFile });
});
setup('authenticate as autor', async ({ page }) => {
await login(page, credentials.autor);
await page.context().storageState({ path: autorFile });
});
async function login(page, { username, password }) {
await page.goto('index.php?again=yes');
await page.getByLabel(/Benutzername/i).fill(username);
await page.getByLabel(/Passwort/i).fill(password);
await page.getByRole('button', { name: 'Anmelden' }).click();
await expect(page.locator('#avatar-menu')).toBeVisible();
}
|