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 });
|
2025-01-26 00:31:40 +00:00
|
|
|
await expect(page).toHaveTitle("Graham's Filebrowser - Files - playwright-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 });
|
2025-01-26 00:31:40 +00:00
|
|
|
await expect(page).toHaveTitle("Graham's Filebrowser - Login");
|
2025-01-13 00:50:22 +00:00
|
|
|
cookies = await context.cookies();
|
|
|
|
expect(cookies.find((c) => c.name == "auth")?.value).toBeUndefined();
|
2024-08-24 22:02:33 +00:00
|
|
|
});
|