feat(test): M5.3 — Playwright e2e harness for the dev stack
playwright.config.ts + tests/e2e/{apex,tenant,health}.spec.ts. make e2e for local. CI e2e job opt-in via RUN_E2E repo variable. OIDC click-through deferred to when stage is up.
Refs: M5.3
This commit was merged in pull request #8.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// Apex tests don't need the OIDC dance — they just verify Next.js is
|
||||
// serving the right routes.
|
||||
|
||||
test.describe("apex landing", () => {
|
||||
test("renders the landing page @needs-stack", async ({ page }) => {
|
||||
const apex = test.info().config.metadata?.apexURL ?? "http://localhost:3000";
|
||||
await page.goto(apex);
|
||||
await expect(page.getByRole("heading", { name: "Breakpilot" })).toBeVisible();
|
||||
await expect(page.getByText(/Customer portals live at/)).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// Health checks — confirm the underlying services are reachable before the
|
||||
// stack-dependent tests run. Skips with a clear reason if anything is down,
|
||||
// so we don't waste 30s on a slow OIDC redirect when Keycloak isn't running.
|
||||
|
||||
test.describe("dev stack health @needs-stack", () => {
|
||||
test("portal /api/auth/providers responds", async ({ request }) => {
|
||||
const r = await request.get("/api/auth/providers");
|
||||
expect(r.status()).toBe(200);
|
||||
const data = await r.json();
|
||||
expect(data).toHaveProperty("keycloak");
|
||||
});
|
||||
|
||||
test("tenant-registry /healthz responds", async ({ request }) => {
|
||||
const url =
|
||||
process.env.PLAYWRIGHT_TENANT_REGISTRY_URL ?? "http://localhost:8090";
|
||||
const r = await request.get(`${url}/healthz`);
|
||||
expect(r.status()).toBe(200);
|
||||
expect(await r.json()).toMatchObject({ status: "ok" });
|
||||
});
|
||||
|
||||
test("keycloak realm metadata is exposed", async ({ request }) => {
|
||||
const url =
|
||||
process.env.PLAYWRIGHT_KEYCLOAK_URL ??
|
||||
"http://localhost:8080/realms/breakpilot-dev";
|
||||
const r = await request.get(`${url}/.well-known/openid-configuration`);
|
||||
expect(r.status()).toBe(200);
|
||||
const cfg = await r.json();
|
||||
expect(cfg.issuer).toContain("breakpilot-dev");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// Tenant subdomain tests — no OIDC click-through (Keycloak in headless mode
|
||||
// is flaky); we just assert the SIGNED-OUT view of each protected route
|
||||
// renders the expected gate. Once the realm grows a service-account flow
|
||||
// for testing (M5.x), we'll bolt on a signed-in suite.
|
||||
|
||||
test.describe("tenant subdomain @needs-stack", () => {
|
||||
test("acme dashboard renders the Sign-in button when signed out", async ({ page }) => {
|
||||
await page.goto("/dashboard");
|
||||
await expect(page.getByRole("heading", { name: /Sign in to acme/i })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /Sign in with Keycloak/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test("acme /products requires sign-in", async ({ page }) => {
|
||||
await page.goto("/products");
|
||||
// Either the user is sent to dashboard's sign-in form, or the page renders
|
||||
// the canSee=false branch (NotAuthorized) depending on session state.
|
||||
// Both are legitimate; the assertion is that we do NOT see the empty
|
||||
// product tile body without a session.
|
||||
const isSignedIn = await page.getByRole("heading", { name: /Products/i }).isVisible();
|
||||
if (!isSignedIn) {
|
||||
await expect(
|
||||
page.getByRole("button", { name: /Sign in with Keycloak/i }),
|
||||
).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test("unknown tenant slug 404s", async ({ page }) => {
|
||||
const resp = await page.goto("http://nope-nope.localhost:3000/dashboard");
|
||||
expect(resp?.status()).toBe(404);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user