AstroCol/tests/frontend/login.spec.ts

47 lines
2.0 KiB
TypeScript

import { test, expect, } from '@playwright/test';
test.use({
ignoreHTTPSErrors: true
});
test('successfull_login', async ({ page }) => {
await page.goto('https://localhost:4321/login');
await page.locator("[name='username']").click();
await page.locator("[name='username']").fill('gargamel');
await page.locator("[name='username']").press('Tab');
await page.locator("[name='password']").fill('klakier1');
await page.locator(".login-submit").click();
await expect(page.locator('#fleet-status')).toBeVisible();
});
test('invalid_username', async ({ page }) => {
await page.goto('https://localhost:4321/login');
await page.locator("[name='username']").click();
await page.locator("[name='username']").fill('wihwkdietaielgba');
await page.locator("[name='username']").press('Tab');
await page.locator("[name='password']").fill('qwerty123');
await page.locator(".login-submit").click();
await expect(page.getByText('Invalid username or password')).toBeVisible();
});
test('invalid_password', async ({ page }) => {
await page.goto('https://localhost:4321/login');
await page.locator("[name='username']").click();
await page.locator("[name='username']").fill('gargamel');
await page.locator("[name='username']").press('Tab');
await page.locator("[name='password']").fill('qwerty123');
await page.locator(".login-submit").click();
await expect(page.getByText('Invalid username or password')).toBeVisible();
});
test('logout', async ({ page }) => {
await page.goto('https://localhost:4321/login');
await page.locator("[name='username']").click();
await page.locator("[name='username']").fill('gargamel');
await page.locator("[name='username']").press('Tab');
await page.locator("[name='password']").fill('klakier1');
await page.locator(".login-submit").click();
await page.getByRole('link', { name: '[profile]' }).click();
await page.getByRole('link', { name: '[log out]' }).click();
await expect(page.locator("[name='username']")).toBeVisible();
});