- Playwright config for local browsers (Firefox by default) and Docker Chrome - docker-compose.chrome.yml for browserless/chrome container (arm64) - 4 connectivity smoke tests (home, contact, blog pages) - 3 auth tests (redirect, login, logout) with auth helpers - Custom fixtures with remote CDP connect support - Shell scripts for start/stop/full Docker Chrome workflow - Makefile targets: playwright, playwright-docker, playwright-full
33 lines
1019 B
TypeScript
33 lines
1019 B
TypeScript
import { test, expect } from "./fixtures";
|
|
import { loginAsTestUser } from "./auth-helpers";
|
|
|
|
test.describe("Authenticated pages", () => {
|
|
test("redirects unauthenticated users to login page", async ({ page }) => {
|
|
const response = await page.goto("/editor/dashboard");
|
|
// Should redirect to login
|
|
expect(response?.url()).toContain("/users/log-in");
|
|
});
|
|
|
|
test("can log in and access the editor dashboard", async ({ page }) => {
|
|
await loginAsTestUser(page);
|
|
|
|
// After login, we should be on the home page
|
|
await expect(page).toHaveURL("/");
|
|
await expect(page.locator("body")).not.toBeEmpty();
|
|
});
|
|
|
|
test("can log out", async ({ page }) => {
|
|
await loginAsTestUser(page);
|
|
|
|
// Now log out
|
|
await page.goto("/users/log-out");
|
|
|
|
// Should redirect to home
|
|
await expect(page).toHaveURL("/");
|
|
|
|
// Try accessing an authenticated page
|
|
await page.goto("/editor/dashboard");
|
|
// Should redirect to login
|
|
await expect(page).toHaveURL(/\/users\/log-in/);
|
|
});
|
|
}); |