leaflet_svelte/tests/e2e/auth.spec.ts

27 lines
1,003 B
TypeScript

import { test, expect, login, logout } from './fixtures';
test('anonymous users are redirected to /login from /predict', async ({ page, context }) => {
await logout(context);
await page.goto('/predict');
await page.waitForURL('**/login', { timeout: 10_000 });
await expect(page.getByRole('heading', { level: 5 }).first()).toContainText(
/Вход|Sign in/,
);
});
test('submitting the login form authenticates and redirects', async ({ page, context }) => {
await logout(context);
await page.goto('/login');
await page.getByLabel(/Имя пользователя|Username/).fill('demo');
await page.getByLabel(/Пароль|Password/).fill('demo');
await page.getByRole('button', { name: /^(Войти|Sign in)$/ }).click();
await page.waitForURL('**/predict', { timeout: 15_000 });
});
test('already-authenticated visit to / lands on /predict', async ({ page, context }) => {
await login(context);
await page.goto('/');
await page.waitForURL('**/predict', { timeout: 15_000 });
});