Files
portal/tests/e2e/tenant.spec.ts
T
sharang 7b33516686
ci / shared (pull_request) Successful in 4s
ci / test (pull_request) Successful in 28s
ci / e2e (pull_request) Has been skipped
ci / image (pull_request) Has been skipped
feat(test): M5.3 — Playwright e2e harness for the dev stack
Adds the M5.3 deliverable scoped to local-dev (stage doesn't exist yet,
so the CI e2e job is gated behind the repo variable RUN_E2E='true' —
defaults off).

Layout:
  playwright.config.ts   chromium project; baseURL defaults to
                         http://acme.localhost:3000 (subdomain routing
                         fires). PLAYWRIGHT_BASE_URL / APEX_URL / etc.
                         env vars override for stage.
  tests/e2e/apex.spec.ts        landing page renders
  tests/e2e/tenant.spec.ts      signed-out dashboard shows Sign in
                                button; unknown slug returns 404
  tests/e2e/health.spec.ts      every dev-stack endpoint reachable
                                (portal /api/auth/providers, tenant-
                                registry /healthz, KC realm metadata)

Run locally with the full dev stack up:

  cd platform/orca-platform && make dev-up
  cd platform/tenant-registry && make dev
  cd platform/portal && make dev
  cd platform/portal && make e2e

OIDC click-through not asserted yet — Keycloak in headless mode is
flaky and depends on a stable test-user password. The current gate
(Sign-in button visible) catches the more common 'auth completely
broken' regression; the deeper smoke lands when stage has its own
test fixture.

tsconfig now excludes tests/e2e so vitest + tsc don't fight over
Playwright type imports.

Refs: M5.3
2026-05-19 16:51:55 +02:00

34 lines
1.5 KiB
TypeScript

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);
});
});