2026-04-06 19:15:22 +03:00
|
|
|
/**
|
|
|
|
|
* Auth and cross-cutting tests -- HIGH tier.
|
|
|
|
|
*
|
2026-04-06 19:54:09 +03:00
|
|
|
* Tests protected route access for admin/viewer roles,
|
|
|
|
|
* redirect behavior, and all routes smoke test.
|
2026-04-06 19:15:22 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { test, expect } from "../fixtures/frigate-test";
|
|
|
|
|
import { viewerProfile } from "../fixtures/mock-data/profile";
|
|
|
|
|
|
2026-04-06 19:54:09 +03:00
|
|
|
test.describe("Auth - Admin Access @high", () => {
|
|
|
|
|
test("admin can access /system and it renders", async ({ frigateApp }) => {
|
2026-04-06 19:15:22 +03:00
|
|
|
await frigateApp.goto("/system");
|
|
|
|
|
await expect(frigateApp.page.locator("#pageRoot")).toBeVisible();
|
2026-04-06 19:54:09 +03:00
|
|
|
// Wait for lazy-loaded system content
|
|
|
|
|
await frigateApp.page.waitForTimeout(3000);
|
|
|
|
|
await expect(frigateApp.page.locator("#pageRoot")).toBeVisible();
|
2026-04-06 19:15:22 +03:00
|
|
|
});
|
|
|
|
|
|
2026-04-06 19:54:09 +03:00
|
|
|
test("admin can access /config and editor loads", async ({ frigateApp }) => {
|
2026-04-06 19:15:22 +03:00
|
|
|
await frigateApp.goto("/config");
|
|
|
|
|
await frigateApp.page.waitForTimeout(3000);
|
2026-04-06 19:54:09 +03:00
|
|
|
// Monaco editor or at least page content should render
|
2026-04-06 19:15:22 +03:00
|
|
|
await expect(frigateApp.page.locator("body")).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-06 19:54:09 +03:00
|
|
|
test("admin can access /logs and service tabs render", async ({
|
|
|
|
|
frigateApp,
|
|
|
|
|
}) => {
|
2026-04-06 19:15:22 +03:00
|
|
|
await frigateApp.goto("/logs");
|
|
|
|
|
await expect(frigateApp.page.locator("#pageRoot")).toBeVisible();
|
2026-04-06 19:54:09 +03:00
|
|
|
// Should have service toggle group
|
|
|
|
|
const toggleGroup = frigateApp.page.locator('[role="group"]');
|
|
|
|
|
await expect(toggleGroup.first()).toBeVisible({ timeout: 5_000 });
|
2026-04-06 19:15:22 +03:00
|
|
|
});
|
2026-04-06 19:54:09 +03:00
|
|
|
});
|
2026-04-06 19:15:22 +03:00
|
|
|
|
2026-04-06 19:54:09 +03:00
|
|
|
test.describe("Auth - Viewer Restrictions @high", () => {
|
|
|
|
|
test("viewer is denied access to /system", async ({ frigateApp, page }) => {
|
|
|
|
|
await frigateApp.installDefaults({ profile: viewerProfile() });
|
2026-04-06 19:15:22 +03:00
|
|
|
await page.goto("/system");
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
const bodyText = await page.textContent("body");
|
2026-04-06 19:54:09 +03:00
|
|
|
expect(
|
2026-04-06 19:15:22 +03:00
|
|
|
bodyText?.includes("Access Denied") ||
|
2026-04-06 19:54:09 +03:00
|
|
|
bodyText?.includes("permission") ||
|
|
|
|
|
page.url().includes("unauthorized"),
|
|
|
|
|
).toBeTruthy();
|
2026-04-06 19:15:22 +03:00
|
|
|
});
|
|
|
|
|
|
2026-04-06 19:54:09 +03:00
|
|
|
test("viewer is denied access to /config", async ({ frigateApp, page }) => {
|
|
|
|
|
await frigateApp.installDefaults({ profile: viewerProfile() });
|
|
|
|
|
await page.goto("/config");
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
const bodyText = await page.textContent("body");
|
|
|
|
|
expect(
|
|
|
|
|
bodyText?.includes("Access Denied") ||
|
|
|
|
|
bodyText?.includes("permission") ||
|
|
|
|
|
page.url().includes("unauthorized"),
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("viewer is denied access to /logs", async ({ frigateApp, page }) => {
|
|
|
|
|
await frigateApp.installDefaults({ profile: viewerProfile() });
|
|
|
|
|
await page.goto("/logs");
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
const bodyText = await page.textContent("body");
|
|
|
|
|
expect(
|
|
|
|
|
bodyText?.includes("Access Denied") ||
|
|
|
|
|
bodyText?.includes("permission") ||
|
|
|
|
|
page.url().includes("unauthorized"),
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("viewer can access all main user routes", async ({
|
|
|
|
|
frigateApp,
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
await frigateApp.installDefaults({ profile: viewerProfile() });
|
|
|
|
|
const routes = ["/", "/review", "/explore", "/export", "/settings"];
|
|
|
|
|
for (const route of routes) {
|
|
|
|
|
await page.goto(route);
|
|
|
|
|
await page.waitForSelector("#pageRoot", { timeout: 10_000 });
|
|
|
|
|
await expect(page.locator("#pageRoot")).toBeVisible();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe("Auth - All Routes Smoke @high", () => {
|
|
|
|
|
test("all user routes render without crash", async ({ frigateApp }) => {
|
2026-04-06 19:15:22 +03:00
|
|
|
const routes = ["/", "/review", "/explore", "/export", "/settings"];
|
|
|
|
|
for (const route of routes) {
|
|
|
|
|
await frigateApp.goto(route);
|
|
|
|
|
await expect(frigateApp.page.locator("#pageRoot")).toBeVisible({
|
|
|
|
|
timeout: 10_000,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-06 19:54:09 +03:00
|
|
|
test("all admin routes render without crash", async ({ frigateApp }) => {
|
2026-04-06 19:15:22 +03:00
|
|
|
const routes = ["/system", "/logs"];
|
|
|
|
|
for (const route of routes) {
|
|
|
|
|
await frigateApp.goto(route);
|
|
|
|
|
await expect(frigateApp.page.locator("#pageRoot")).toBeVisible({
|
|
|
|
|
timeout: 10_000,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|