filebrowser/frontend/tests/auth.spec.ts

25 lines
977 B
TypeScript
Raw Normal View History

2025-01-13 00:50:22 +00:00
import { test, expect } from "@playwright/test";
test("redirect to login", async ({ page, context }) => {
await context.clearCookies();
2024-08-24 22:02:33 +00:00
await page.goto("/");
await expect(page).toHaveURL(/\/login/);
await page.goto("/files/");
await expect(page).toHaveURL(/\/login\?redirect=\/files\//);
});
2025-01-13 00:50:22 +00:00
test("logout", async ({ page, context }) => {
await page.goto('/');
await expect(page.locator("div.wrong")).toBeHidden();
await page.waitForURL("**/files/", { timeout: 100 });
await expect(page).toHaveTitle('playwright-files - FileBrowser Quantum - Files');
2024-08-24 22:02:33 +00:00
let cookies = await context.cookies();
expect(cookies.find((c) => c.name == "auth")?.value).toBeDefined();
2025-01-13 00:50:22 +00:00
await page.locator('div.inner-card.logout-button').click();
await page.waitForURL("**/login", { timeout: 100 });
await expect(page).toHaveTitle('FileBrowser Quantum - Login');
cookies = await context.cookies();
expect(cookies.find((c) => c.name == "auth")?.value).toBeUndefined();
2024-08-24 22:02:33 +00:00
});