← back to Homesonspec
tests/end-to-end/admin.spec.ts
23 lines
import { expect, test } from "@playwright/test";
const ADMIN = "http://localhost:3101";
// Credentials come from the env (same BASIC_AUTH the admin app reads) — no hardcoded
// default. Set BASIC_AUTH in the test env to run the authenticated case.
const AUTH = "Basic " + Buffer.from(process.env.BASIC_AUTH ?? "admin:set-BASIC_AUTH-to-run").toString("base64");
test("admin challenges without credentials (401)", async ({ request }) => {
const response = await request.get(ADMIN, { failOnStatusCode: false });
expect(response.status()).toBe(401);
expect(response.headers()["www-authenticate"]).toContain("Basic");
});
test("admin dashboard renders with credentials; cards show created chips", async ({ browser }) => {
const context = await browser.newContext({ extraHTTPHeaders: { Authorization: AUTH } });
const page = await context.newPage();
await page.goto(`${ADMIN}/sources`);
await expect(page.getByTestId("source-card").first()).toBeVisible({ timeout: 15_000 });
// Standing rule: every admin card shows a created date+time chip.
await expect(page.getByTestId("source-card").first().getByText("🕓")).toBeVisible();
await context.close();
});