47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
import { expect, test } from "@playwright/test";
|
|
import { mockApi } from "./support/network.js";
|
|
|
|
const AUTH_ENTRY_TIMEOUT = 60_000;
|
|
|
|
test.describe("Auth entry smoke", () => {
|
|
test.describe.configure({ timeout: 90_000 });
|
|
|
|
test("@smoke @pr protected routes redirect to login without token", async ({ page }) => {
|
|
await mockApi(page);
|
|
await page.goto("/user");
|
|
await expect(page).toHaveURL(/\/login/, { timeout: AUTH_ENTRY_TIMEOUT });
|
|
await expect(page.getByTestId("login-submit")).toBeVisible({ timeout: AUTH_ENTRY_TIMEOUT });
|
|
});
|
|
|
|
test("@smoke login route renders credential controls", async ({ page }) => {
|
|
await mockApi(page, { authenticated: false });
|
|
await page.goto("/login");
|
|
|
|
await expect(page.getByTestId("login-customer-number")).toBeVisible({ timeout: AUTH_ENTRY_TIMEOUT });
|
|
await expect(page.getByTestId("login-password")).toBeVisible({ timeout: AUTH_ENTRY_TIMEOUT });
|
|
await expect(page.getByTestId("login-submit")).toBeVisible({ timeout: AUTH_ENTRY_TIMEOUT });
|
|
});
|
|
|
|
test("@smoke qr login route renders without QR bootstrap import errors", async ({ page }) => {
|
|
const pageErrors = [];
|
|
const consoleErrors = [];
|
|
page.on("pageerror", (error) => {
|
|
pageErrors.push(error.message);
|
|
});
|
|
page.on("console", (message) => {
|
|
if (message.type() === "error") {
|
|
consoleErrors.push(message.text());
|
|
}
|
|
});
|
|
|
|
await mockApi(page, { authenticated: false });
|
|
await page.goto("/login/qr", { waitUntil: "domcontentloaded" });
|
|
await page.waitForTimeout(1000);
|
|
|
|
await expect(page).toHaveURL(/\/login\/qr/);
|
|
const bootstrapErrors = [...pageErrors, ...consoleErrors].join("\n");
|
|
expect(bootstrapErrors).not.toContain("/node_modules/qrcode/lib/browser.js");
|
|
expect(bootstrapErrors).not.toContain("at useQRCode.mjs");
|
|
});
|
|
});
|