forked from baron/baron-sso
31 lines
1021 B
TypeScript
31 lines
1021 B
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test.describe("Auth Flow", () => {
|
|
test("unauthenticated user is redirected to login", async ({ page }) => {
|
|
// Navigate to a protected route without setting localStorage
|
|
await page.goto("/");
|
|
|
|
// Check if it redirects to login
|
|
await expect(page).toHaveURL(/\/login$/);
|
|
|
|
// Verify login page content
|
|
await expect(page.getByText("Baron SSO")).toBeVisible();
|
|
await expect(page.getByText("관리자 로그인")).toBeVisible();
|
|
await expect(
|
|
page.getByRole("button", { name: "SSO 계정으로 로그인" }),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("authenticated user can access dashboard", async ({ page }) => {
|
|
// Inject mock session
|
|
await page.addInitScript(() => {
|
|
window.localStorage.setItem("admin_session", "playwright-admin-session");
|
|
});
|
|
|
|
await page.goto("/");
|
|
|
|
// Should stay on dashboard (or another protected route) and not redirect to login
|
|
await expect(page).not.toHaveURL(/\/login$/);
|
|
});
|
|
});
|