aboutsummaryrefslogtreecommitdiff
path: root/tests/e2e/login.spec.ts
blob: e05cb7a849a3f1cbc19b8b9edc4906ef69c5c57d (plain)
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
import { test, expect } from '@playwright/test';
import { credentials } from './credentials.ts';

test.describe('Loggin In - HTML Web Form @auth', () => {
    test.describe('Visiting the homepage', () => {
        test('should take us to the login form @smoke', async ({ page, baseURL }) => {
            await page.goto('');

            const benutzername = page.getByLabel(/Benutzername/i);
            await expect(benutzername).toBeVisible();
            await expect(benutzername).toBeEditable();

            const passwort = page.getByLabel(/Passwort/i);
            await expect(passwort).toBeVisible();
            await expect(passwort).toBeEditable();
        });
    });

    test.describe('Unauthorized access', () => {
        test('redirects to the login form @smoke', async ({ page }) => {
            await page.goto('dispatch.php/start');

            await expect(page.getByLabel(/Passwort/)).toBeVisible();
            await expect(page.locator('#avatar-menu')).not.toBeVisible();
        });
    });

    test.describe('HTML Form submission', () => {
        test.beforeEach(async ({ page }) => {
            await page.goto('index.php?again=yes');
        });

        test('displays error on invalid login', async ({ page }) => {
            const benutzername = page.getByLabel(/Benutzername/i);
            const passwort = page.getByLabel(/Passwort/i);
            const submit = page.getByRole('button', { name: 'Anmelden' });

            await benutzername.fill('username');
            await passwort.fill('password');
            await submit.click();
            await expect(page.locator('css=.system-notification-exception')).toBeVisible();
        });

        test('redirects to start page', async ({ page, baseURL }) => {
            const benutzername = page.getByLabel(/Benutzername/i);
            const passwort = page.getByLabel(/Passwort/i);
            const submit = page.getByRole('button', { name: 'Anmelden' });

            await benutzername.fill(credentials.autor.username);
            await passwort.fill(credentials.autor.password);
            await submit.click();
            await page.getByLabel('Profilmenü').click();
            await page.getByText('Logout').click();
            await expect(page).toHaveURL(`${baseURL}/dispatch.php/login`);
        });
    });
});