SPB Git
1.4 KB · 18 lines typescript
1import { expect, test } from "@playwright/test";2/** Admin flows run only when E2E_ADMIN_EMAIL / E2E_ADMIN_PASSWORD are provided (desktop project). */3const email = process.env.E2E_ADMIN_EMAIL, pw = process.env.E2E_ADMIN_PASSWORD;4test.describe("admin @desktop-only", () => {5  test("unauthenticated access is refused", async ({ request }) => {6    for (const p of ["/admin", "/admin/papers", "/admin/settings"]) { const r = await request.get(p, { maxRedirects: 0 }); expect([302, 307]).toContain(r.status()); expect(r.headers().location).toContain("/login"); }7    const u = await request.post("/api/admin/upload", { multipart: { paper_id: "x" } }); expect(u.status()).toBe(401);8  });9  test("login, dashboard, paper edit, audit", async ({ page }) => {10    test.skip(!email || !pw, "no admin credentials in env");11    await page.goto("/login"); await page.getByLabel("E-mail").fill(email!); await page.getByLabel("Password").fill(pw!); await page.getByRole("button", { name: "Sign in" }).click();12    await page.waitForURL(/\/admin/); await expect(page.getByRole("heading", { name: /Dashboard|Account/ })).toBeVisible();13    await page.goto("/admin/papers"); await expect(page.locator("table.data tbody tr").first()).toBeVisible();14    await page.goto("/admin/ingest"); await expect(page.getByRole("heading", { name: "Manuscript ingestion" })).toBeVisible();15    await page.goto("/admin/audit"); await expect(page.locator("table.data tbody tr").first()).toBeVisible();16  });17});18
Files · ba542514eac709a3e76ac3b3f88404c61356d594
Menu

Theme