const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("./timeouts"); const { decodeDotenvQuotedValue, gotoOnion, normalizeBaseUrl, runAdminFlow, runBiberFlow, runGuestFlow } = require("./personas"); test.use({ ignoreHTTPSErrors: true }); const appBaseUrl = normalizeBaseUrl(process.env.APP_BASE_URL || ""); const canonicalDomain = decodeDotenvQuotedValue(process.env.CANONICAL_DOMAIN || ""); test.beforeEach(async ({ page }) => { expect(appBaseUrl, "APP_BASE_URL must be set").toBeTruthy(); expect(canonicalDomain, "CANONICAL_DOMAIN must be set").toBeTruthy(); await page.context().clearCookies(); }); test("Checkmk front surface is reachable under the canonical domain", async ({ page }) => { const response = await gotoOnion(page, `${appBaseUrl}/`); expect(response, "Expected a Checkmk front response").toBeTruthy(); expect(response.status(), "Expected the Checkmk front status to be < 500").toBeLessThan(500); }); test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { await runGuestFlow(page); }); test("biber: app → universal logout", async ({ page }) => { await runBiberFlow(page); }); test("administrator: app → admin surface → universal logout", async ({ page }) => { await runAdminFlow(page, { adminInteraction: async (interactivePage) => { const setup = interactivePage.getByRole("link", { name: /^setup$/i }).first(); if (await setup.isVisible().catch(() => false)) { await setup.click({ timeout: resolveTimeout(30_000) }).catch(() => {}); await interactivePage.waitForLoadState("domcontentloaded", { timeout: resolveTimeout(30_000) }).catch(() => {}); await expect(interactivePage.locator("body")).toContainText(/setup|hosts|services|checkmk/i, { timeout: resolveTimeout(30_000), }); } }, }); });