import { expect, test } from "@playwright/test"; import { expectApiAuthRequired, expectPageRedirectsToLogin, } from "../helpers/auth-assertions.ts"; test.describe("RBAC & Route Guards", () => { test("protected UI routes redirect guests to login", async ({ request }) => { await expectPageRedirectsToLogin(request, "/landlord/dashboard"); await expectPageRedirectsToLogin(request, "/tenant/dashboard"); await expectPageRedirectsToLogin(request, "/admin"); await expectPageRedirectsToLogin(request, "/calendar/every-income"); await expectPageRedirectsToLogin(request, "/user-profile"); }); test("protected API routes return auth-required payload", async ({ request }) => { await expectApiAuthRequired(request, "/api/retrieve/messages"); await expectApiAuthRequired(request, "/api/retrieve/payment_transactions"); }); test("unauthorized info page is publicly reachable", async ({ page }) => { await page.goto("/unauthorized"); await expect(page.getByRole("heading", { name: "Access Restricted" })) .toBeVisible(); }); });