From 32d7a62ad08c4bb2fa8d6649895bf577ddecdc89 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 10 May 2026 11:51:10 +0200 Subject: [PATCH] test(playwright): hard-fail on missing role spec; seed 27 minimal specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make `tests/lint/.../test_has_spec.py` raise instead of warn when a roles/web-app-* role has no `files/playwright.spec.js`, then ship the 27 minimal specs needed to satisfy the new floor. Each new spec follows `roles/web-app-mig` (TLS + canonical-domain baseline, HTML content-type, three persona flows) with role-specific admin-interaction labels seeded from app domain knowledge. The bodies are intentionally static — `templates/playwright.env.j2` is not shipped per role yet, so the specs do not run end-to-end on deploy; detail tightening per role is follow-up work. Also fix `_body_contains_stub_marker` in `test_no_stub_tests.py`: it substring-matched `TODO` against `body.upper()`, which flagged `masTODOn` inside the mastodon spec's body regex. Switched to word-boundary matching so genuine `// TODO:` markers still trip the lint while embedded substrings in app names or regex alternations do not. Co-Authored-By: Claude Opus 4.7 (1M context) --- roles/web-app-chess/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-espocrm/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ roles/web-app-gitlab/files/playwright.spec.js | 82 +++++++++++++++++++ roles/web-app-jira/files/playwright.spec.js | 82 +++++++++++++++++++ roles/web-app-lam/files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-listmonk/files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-littlejs/files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-magento/files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-mastodon/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-mini-qr/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-pgadmin/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ roles/web-app-pretix/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-shopware/files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-snipe-it/files/playwright.spec.js | 82 +++++++++++++++++++ .../files/playwright.spec.js | 82 +++++++++++++++++++ .../web-app-suitecrm/files/playwright.spec.js | 82 +++++++++++++++++++ roles/web-app-xwiki/files/playwright.spec.js | 82 +++++++++++++++++++ .../roles/web-app/playwright/test_has_spec.py | 26 +++--- .../web-app/playwright/test_no_stub_tests.py | 11 ++- 29 files changed, 2232 insertions(+), 19 deletions(-) create mode 100644 roles/web-app-chess/files/playwright.spec.js create mode 100644 roles/web-app-confluence/files/playwright.spec.js create mode 100644 roles/web-app-espocrm/files/playwright.spec.js create mode 100644 roles/web-app-funkwhale/files/playwright.spec.js create mode 100644 roles/web-app-gitlab/files/playwright.spec.js create mode 100644 roles/web-app-jira/files/playwright.spec.js create mode 100644 roles/web-app-lam/files/playwright.spec.js create mode 100644 roles/web-app-listmonk/files/playwright.spec.js create mode 100644 roles/web-app-littlejs/files/playwright.spec.js create mode 100644 roles/web-app-magento/files/playwright.spec.js create mode 100644 roles/web-app-mastodon/files/playwright.spec.js create mode 100644 roles/web-app-mediawiki/files/playwright.spec.js create mode 100644 roles/web-app-mini-qr/files/playwright.spec.js create mode 100644 roles/web-app-mobilizon/files/playwright.spec.js create mode 100644 roles/web-app-navigator/files/playwright.spec.js create mode 100644 roles/web-app-oauth2-proxy/files/playwright.spec.js create mode 100644 roles/web-app-openproject/files/playwright.spec.js create mode 100644 roles/web-app-pgadmin/files/playwright.spec.js create mode 100644 roles/web-app-phpldapadmin/files/playwright.spec.js create mode 100644 roles/web-app-phpmyadmin/files/playwright.spec.js create mode 100644 roles/web-app-pretix/files/playwright.spec.js create mode 100644 roles/web-app-roulette-wheel/files/playwright.spec.js create mode 100644 roles/web-app-shopware/files/playwright.spec.js create mode 100644 roles/web-app-snipe-it/files/playwright.spec.js create mode 100644 roles/web-app-socialhome/files/playwright.spec.js create mode 100644 roles/web-app-suitecrm/files/playwright.spec.js create mode 100644 roles/web-app-xwiki/files/playwright.spec.js diff --git a/roles/web-app-chess/files/playwright.spec.js b/roles/web-app-chess/files/playwright.spec.js new file mode 100644 index 0000000000..24ff3f281e --- /dev/null +++ b/roles/web-app-chess/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("chess front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected chess response").toBeTruthy(); + expect(response.status(), "Expected chess front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the chess URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "chess must emit HSTS").toBeTruthy(); +}); + +test("chess returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected chess front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-chess admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(play|board|profile|admin|tournament)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /chess|game|board|move|tournament/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-confluence/files/playwright.spec.js b/roles/web-app-confluence/files/playwright.spec.js new file mode 100644 index 0000000000..a6832564b2 --- /dev/null +++ b/roles/web-app-confluence/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Confluence front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Confluence response").toBeTruthy(); + expect(response.status(), "Expected Confluence front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Confluence URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Confluence must emit HSTS").toBeTruthy(); +}); + +test("Confluence returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Confluence front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-confluence admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(spaces|create|admin|settings)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /space|page|wiki|content|administration|confluence/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-espocrm/files/playwright.spec.js b/roles/web-app-espocrm/files/playwright.spec.js new file mode 100644 index 0000000000..d07881e17b --- /dev/null +++ b/roles/web-app-espocrm/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("EspoCRM front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected EspoCRM response").toBeTruthy(); + expect(response.status(), "Expected EspoCRM front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the EspoCRM URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "EspoCRM must emit HSTS").toBeTruthy(); +}); + +test("EspoCRM returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected EspoCRM front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-espocrm admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(admin|leads|accounts|contacts)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /lead|account|contact|opportunity|crm|administration/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-funkwhale/files/playwright.spec.js b/roles/web-app-funkwhale/files/playwright.spec.js new file mode 100644 index 0000000000..21e8f2bf36 --- /dev/null +++ b/roles/web-app-funkwhale/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Funkwhale front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Funkwhale response").toBeTruthy(); + expect(response.status(), "Expected Funkwhale front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Funkwhale URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Funkwhale must emit HSTS").toBeTruthy(); +}); + +test("Funkwhale returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Funkwhale front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-funkwhale admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(library|favorites|playlists|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /library|track|album|artist|playlist|funkwhale/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-gitlab/files/playwright.spec.js b/roles/web-app-gitlab/files/playwright.spec.js new file mode 100644 index 0000000000..a44195cdf2 --- /dev/null +++ b/roles/web-app-gitlab/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("GitLab front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected GitLab response").toBeTruthy(); + expect(response.status(), "Expected GitLab front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the GitLab URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "GitLab must emit HSTS").toBeTruthy(); +}); + +test("GitLab returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected GitLab front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-gitlab admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(projects|groups|admin|settings)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /project|group|merge request|issue|admin area|gitlab/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-jira/files/playwright.spec.js b/roles/web-app-jira/files/playwright.spec.js new file mode 100644 index 0000000000..c7fff2c09c --- /dev/null +++ b/roles/web-app-jira/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Jira front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Jira response").toBeTruthy(); + expect(response.status(), "Expected Jira front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Jira URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Jira must emit HSTS").toBeTruthy(); +}); + +test("Jira returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Jira front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-jira admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(issues|projects|boards|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /issue|project|board|backlog|jira/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-lam/files/playwright.spec.js b/roles/web-app-lam/files/playwright.spec.js new file mode 100644 index 0000000000..88d5ab1eef --- /dev/null +++ b/roles/web-app-lam/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("LAM front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected LAM response").toBeTruthy(); + expect(response.status(), "Expected LAM front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the LAM URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "LAM must emit HSTS").toBeTruthy(); +}); + +test("LAM returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected LAM front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-lam admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(users|groups|tools|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /user|group|tools|configuration|ldap|account/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-listmonk/files/playwright.spec.js b/roles/web-app-listmonk/files/playwright.spec.js new file mode 100644 index 0000000000..d2ddfc7a2c --- /dev/null +++ b/roles/web-app-listmonk/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Listmonk front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Listmonk response").toBeTruthy(); + expect(response.status(), "Expected Listmonk front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Listmonk URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Listmonk must emit HSTS").toBeTruthy(); +}); + +test("Listmonk returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Listmonk front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-listmonk admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(campaigns|subscribers|lists|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /campaign|subscriber|list|template|listmonk/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-littlejs/files/playwright.spec.js b/roles/web-app-littlejs/files/playwright.spec.js new file mode 100644 index 0000000000..2dfa317260 --- /dev/null +++ b/roles/web-app-littlejs/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("LittleJS front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected LittleJS response").toBeTruthy(); + expect(response.status(), "Expected LittleJS front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the LittleJS URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "LittleJS must emit HSTS").toBeTruthy(); +}); + +test("LittleJS returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected LittleJS front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-littlejs admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(play|game|demo)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /littlejs|game|engine|canvas|play/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-magento/files/playwright.spec.js b/roles/web-app-magento/files/playwright.spec.js new file mode 100644 index 0000000000..af16323cff --- /dev/null +++ b/roles/web-app-magento/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Magento front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Magento response").toBeTruthy(); + expect(response.status(), "Expected Magento front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Magento URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Magento must emit HSTS").toBeTruthy(); +}); + +test("Magento returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Magento front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-magento admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(catalog|customers|sales|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /catalog|customer|sales|order|magento/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-mastodon/files/playwright.spec.js b/roles/web-app-mastodon/files/playwright.spec.js new file mode 100644 index 0000000000..8e4ad733c7 --- /dev/null +++ b/roles/web-app-mastodon/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Mastodon front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Mastodon response").toBeTruthy(); + expect(response.status(), "Expected Mastodon front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Mastodon URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Mastodon must emit HSTS").toBeTruthy(); +}); + +test("Mastodon returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Mastodon front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-mastodon admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(notifications|profile|admin|federation)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /notification|profile|federation|mastodon|administration/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-mediawiki/files/playwright.spec.js b/roles/web-app-mediawiki/files/playwright.spec.js new file mode 100644 index 0000000000..665a806866 --- /dev/null +++ b/roles/web-app-mediawiki/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("MediaWiki front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected MediaWiki response").toBeTruthy(); + expect(response.status(), "Expected MediaWiki front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the MediaWiki URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "MediaWiki must emit HSTS").toBeTruthy(); +}); + +test("MediaWiki returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected MediaWiki front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-mediawiki admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(edit|view source|talk|history|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /wiki|edit|page|main page|history|mediawiki/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-mini-qr/files/playwright.spec.js b/roles/web-app-mini-qr/files/playwright.spec.js new file mode 100644 index 0000000000..6394ef7bc4 --- /dev/null +++ b/roles/web-app-mini-qr/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("MiniQR front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected MiniQR response").toBeTruthy(); + expect(response.status(), "Expected MiniQR front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the MiniQR URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "MiniQR must emit HSTS").toBeTruthy(); +}); + +test("MiniQR returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected MiniQR front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-mini-qr admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(generate|qr|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /qr|code|generator/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-mobilizon/files/playwright.spec.js b/roles/web-app-mobilizon/files/playwright.spec.js new file mode 100644 index 0000000000..5c71d56927 --- /dev/null +++ b/roles/web-app-mobilizon/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Mobilizon front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Mobilizon response").toBeTruthy(); + expect(response.status(), "Expected Mobilizon front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Mobilizon URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Mobilizon must emit HSTS").toBeTruthy(); +}); + +test("Mobilizon returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Mobilizon front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-mobilizon admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(events|groups|profile|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /event|group|profile|mobilizon/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-navigator/files/playwright.spec.js b/roles/web-app-navigator/files/playwright.spec.js new file mode 100644 index 0000000000..f1881d177d --- /dev/null +++ b/roles/web-app-navigator/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Navigator front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Navigator response").toBeTruthy(); + expect(response.status(), "Expected Navigator front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Navigator URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Navigator must emit HSTS").toBeTruthy(); +}); + +test("Navigator returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Navigator front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-navigator admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(tiles|navigation|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /tile|navigation|services|navigator/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-oauth2-proxy/files/playwright.spec.js b/roles/web-app-oauth2-proxy/files/playwright.spec.js new file mode 100644 index 0000000000..3f20dcfca8 --- /dev/null +++ b/roles/web-app-oauth2-proxy/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("oauth2-proxy front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected oauth2-proxy response").toBeTruthy(); + expect(response.status(), "Expected oauth2-proxy front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the oauth2-proxy URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "oauth2-proxy must emit HSTS").toBeTruthy(); +}); + +test("oauth2-proxy returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected oauth2-proxy front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-oauth2-proxy admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(auth|sign in|profile)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /oauth2|sign in|authentication|provider/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-openproject/files/playwright.spec.js b/roles/web-app-openproject/files/playwright.spec.js new file mode 100644 index 0000000000..05d8a971a8 --- /dev/null +++ b/roles/web-app-openproject/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("OpenProject front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected OpenProject response").toBeTruthy(); + expect(response.status(), "Expected OpenProject front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the OpenProject URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "OpenProject must emit HSTS").toBeTruthy(); +}); + +test("OpenProject returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected OpenProject front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-openproject admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(projects|work packages|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /project|work package|backlog|openproject/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-pgadmin/files/playwright.spec.js b/roles/web-app-pgadmin/files/playwright.spec.js new file mode 100644 index 0000000000..a0c95dad07 --- /dev/null +++ b/roles/web-app-pgadmin/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("pgAdmin front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected pgAdmin response").toBeTruthy(); + expect(response.status(), "Expected pgAdmin front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the pgAdmin URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "pgAdmin must emit HSTS").toBeTruthy(); +}); + +test("pgAdmin returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected pgAdmin front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-pgadmin admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(dashboard|browser|sql|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /database|server|query|pgadmin/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-phpldapadmin/files/playwright.spec.js b/roles/web-app-phpldapadmin/files/playwright.spec.js new file mode 100644 index 0000000000..71f4b6beba --- /dev/null +++ b/roles/web-app-phpldapadmin/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("phpLDAPadmin front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected phpLDAPadmin response").toBeTruthy(); + expect(response.status(), "Expected phpLDAPadmin front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the phpLDAPadmin URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "phpLDAPadmin must emit HSTS").toBeTruthy(); +}); + +test("phpLDAPadmin returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected phpLDAPadmin front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-phpldapadmin admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(tree|create|search|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /ldap|tree|create|search|object/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-phpmyadmin/files/playwright.spec.js b/roles/web-app-phpmyadmin/files/playwright.spec.js new file mode 100644 index 0000000000..df518fd9ff --- /dev/null +++ b/roles/web-app-phpmyadmin/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("phpMyAdmin front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected phpMyAdmin response").toBeTruthy(); + expect(response.status(), "Expected phpMyAdmin front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the phpMyAdmin URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "phpMyAdmin must emit HSTS").toBeTruthy(); +}); + +test("phpMyAdmin returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected phpMyAdmin front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-phpmyadmin admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(databases|sql|export|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /database|sql|table|export|phpmyadmin/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-pretix/files/playwright.spec.js b/roles/web-app-pretix/files/playwright.spec.js new file mode 100644 index 0000000000..d89a5b4d67 --- /dev/null +++ b/roles/web-app-pretix/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Pretix front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Pretix response").toBeTruthy(); + expect(response.status(), "Expected Pretix front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Pretix URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Pretix must emit HSTS").toBeTruthy(); +}); + +test("Pretix returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Pretix front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-pretix admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(events|orders|control|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /event|order|ticket|control|pretix/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-roulette-wheel/files/playwright.spec.js b/roles/web-app-roulette-wheel/files/playwright.spec.js new file mode 100644 index 0000000000..8d83ba16e2 --- /dev/null +++ b/roles/web-app-roulette-wheel/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Roulette Wheel front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Roulette Wheel response").toBeTruthy(); + expect(response.status(), "Expected Roulette Wheel front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Roulette Wheel URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Roulette Wheel must emit HSTS").toBeTruthy(); +}); + +test("Roulette Wheel returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Roulette Wheel front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-roulette-wheel admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(play|spin|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /roulette|spin|wheel|game/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-shopware/files/playwright.spec.js b/roles/web-app-shopware/files/playwright.spec.js new file mode 100644 index 0000000000..cab74dcb1a --- /dev/null +++ b/roles/web-app-shopware/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Shopware front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Shopware response").toBeTruthy(); + expect(response.status(), "Expected Shopware front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Shopware URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Shopware must emit HSTS").toBeTruthy(); +}); + +test("Shopware returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Shopware front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-shopware admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(catalogues|orders|content|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /catalogue|order|content|product|shopware/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-snipe-it/files/playwright.spec.js b/roles/web-app-snipe-it/files/playwright.spec.js new file mode 100644 index 0000000000..0bc46687e3 --- /dev/null +++ b/roles/web-app-snipe-it/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Snipe-IT front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Snipe-IT response").toBeTruthy(); + expect(response.status(), "Expected Snipe-IT front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Snipe-IT URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Snipe-IT must emit HSTS").toBeTruthy(); +}); + +test("Snipe-IT returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Snipe-IT front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-snipe-it admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(assets|users|reports|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /asset|user|report|category|snipe/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-socialhome/files/playwright.spec.js b/roles/web-app-socialhome/files/playwright.spec.js new file mode 100644 index 0000000000..8763e33f6c --- /dev/null +++ b/roles/web-app-socialhome/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("Socialhome front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected Socialhome response").toBeTruthy(); + expect(response.status(), "Expected Socialhome front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the Socialhome URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "Socialhome must emit HSTS").toBeTruthy(); +}); + +test("Socialhome returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected Socialhome front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-socialhome admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(stream|profile|admin|federation)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /stream|profile|federation|content|socialhome/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-suitecrm/files/playwright.spec.js b/roles/web-app-suitecrm/files/playwright.spec.js new file mode 100644 index 0000000000..a8c290fb61 --- /dev/null +++ b/roles/web-app-suitecrm/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("SuiteCRM front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected SuiteCRM response").toBeTruthy(); + expect(response.status(), "Expected SuiteCRM front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the SuiteCRM URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "SuiteCRM must emit HSTS").toBeTruthy(); +}); + +test("SuiteCRM returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected SuiteCRM front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-suitecrm admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(leads|accounts|contacts|admin)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /lead|account|contact|opportunity|suitecrm|crm/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/roles/web-app-xwiki/files/playwright.spec.js b/roles/web-app-xwiki/files/playwright.spec.js new file mode 100644 index 0000000000..3f21d0b0b5 --- /dev/null +++ b/roles/web-app-xwiki/files/playwright.spec.js @@ -0,0 +1,82 @@ +const { test, expect } = require("@playwright/test"); + +const { skipUnlessServiceEnabled, isServiceEnabled } = require("./service-gating"); +const { runGuestFlow, runBiberFlow, runAdminFlow } = require("./personas"); +test.use({ ignoreHTTPSErrors: true }); + +function decodeDotenvQuotedValue(value) { + if (typeof value !== "string" || value.length < 2) return value; + if (!(value.startsWith('"') && value.endsWith('"'))) return value; + const encoded = value.slice(1, -1); + try { + return JSON.parse(`"${encoded}"`).replace(/\$\$/g, "$"); + } catch { + return encoded.replace(/\$\$/g, "$"); + } +} + +function normalizeBaseUrl(value) { + return decodeDotenvQuotedValue(value || "").replace(/\/$/, ""); +} + +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("XWiki front page is served under canonical domain with TLS", async ({ page }) => { + const response = await page.goto(`${appBaseUrl}/`); + expect(response, "Expected XWiki response").toBeTruthy(); + expect(response.status(), "Expected XWiki front page status < 400").toBeLessThan(400); + expect( + response.url().includes(canonicalDomain), + `Expected canonical domain "${canonicalDomain}" to back the XWiki URL` + ).toBe(true); + const headers = response.headers(); + expect(headers["strict-transport-security"], "XWiki must emit HSTS").toBeTruthy(); +}); + +test("XWiki returns HTML content under canonical domain", async ({ request }) => { + const response = await request.get(`${appBaseUrl}/`); + expect(response.status(), "Expected XWiki front page status < 400").toBeLessThan(400); + const contentType = response.headers()["content-type"] || ""; + expect( + contentType.includes("text/html"), + `Expected HTML content-type, got "${contentType}"` + ).toBe(true); +}); + +// Persona scenarios (req 019 Rule 3). +// Bodies live in the shared helper roles/test-e2e-playwright/files/personas +// so every role's persona flow stays consistent. + +test("guest: public-landing → auth chain → never authenticated", async ({ page }) => { + await runGuestFlow(page); +}); + +test("biber: dashboard → app → universal logout", async ({ page }) => { + await runBiberFlow(page); +}); + +test("administrator: dashboard → prometheus → app → universal logout", async ({ page }) => { + await runAdminFlow(page, { + adminInteraction: async (interactivePage) => { + // web-app-xwiki admin-only interaction: open a management surface. + const link = interactivePage + .getByRole("link", { name: /^(edit|admin|wiki)$/i }) + .first(); + if (await link.isVisible({ timeout: 10_000 }).catch(() => false)) { + await link.click().catch(() => {}); + await interactivePage.waitForLoadState("domcontentloaded", { timeout: 30_000 }).catch(() => {}); + await expect(interactivePage.locator("body")).toContainText( + /wiki|edit|page|administration|xwiki/i, + { timeout: 30_000 }, + ); + } + }, + }); +}); diff --git a/tests/lint/ansible/roles/web-app/playwright/test_has_spec.py b/tests/lint/ansible/roles/web-app/playwright/test_has_spec.py index 1505d38d81..5a279e0cae 100644 --- a/tests/lint/ansible/roles/web-app/playwright/test_has_spec.py +++ b/tests/lint/ansible/roles/web-app/playwright/test_has_spec.py @@ -1,23 +1,15 @@ import unittest -from pathlib import Path - -from utils.annotations.message import warning from . import PROJECT_ROOT -def _emit_missing_playwright_spec_warning(repo_root: Path, role_path: Path) -> None: - spec_file = role_path / "files" / "playwright.spec.js" - relative_spec_path = spec_file.relative_to(repo_root).as_posix() - message = f"{role_path.name} has no files/playwright.spec.js (non-blocking)" - warning(message, title="Missing Playwright Spec", file=relative_spec_path) - - class TestWebAppRolesHavePlaywrightSpec(unittest.TestCase): - def test_web_app_roles_playwright_spec_warn_only(self): + def test_web_app_roles_have_playwright_spec(self): """ - Check all roles/web-app-* for files/playwright.spec.js. - Missing specs are reported as warnings but do not fail the test. + Every roles/web-app-* role MUST ship a files/playwright.spec.js. + A missing spec is a hard error so the meta/services.yml registry + and the per-role auth + persona contract are never silently + absent from the deploy capstone. """ root = PROJECT_ROOT roles_dir = root / "roles" @@ -25,7 +17,7 @@ class TestWebAppRolesHavePlaywrightSpec(unittest.TestCase): roles_dir.is_dir(), f"'roles' directory not found at: {roles_dir}" ) - missing = [] + missing: list[str] = [] for role_path in sorted(roles_dir.iterdir()): if not (role_path.is_dir() and role_path.name.startswith("web-app-")): continue @@ -33,9 +25,11 @@ class TestWebAppRolesHavePlaywrightSpec(unittest.TestCase): spec_file = role_path / "files" / "playwright.spec.js" if not spec_file.is_file(): missing.append(role_path.name) - _emit_missing_playwright_spec_warning(root, role_path) - self.assertTrue(True) + if missing: + self.fail( + "Missing files/playwright.spec.js in:\n - " + "\n - ".join(missing) + ) if __name__ == "__main__": diff --git a/tests/lint/ansible/roles/web-app/playwright/test_no_stub_tests.py b/tests/lint/ansible/roles/web-app/playwright/test_no_stub_tests.py index 98b2e6c12b..743c9b3fb7 100644 --- a/tests/lint/ansible/roles/web-app/playwright/test_no_stub_tests.py +++ b/tests/lint/ansible/roles/web-app/playwright/test_no_stub_tests.py @@ -56,8 +56,14 @@ _REAL_FLOW_TOKENS = ( "isServiceDisabledReason(", ) -# Keywords that mark a body as a deferred stub. +# Keywords that mark a body as a deferred stub. Matched as standalone +# words (`\bTODO\b`) so substrings like ``masTODOn`` in a regex +# alternation or an app name do NOT trip the lint. _STUB_MARKERS = ("TODO", "STUB", "FIXME", "XXX") +_STUB_MARKER_RE = re.compile( + r"\b(?:" + "|".join(_STUB_MARKERS) + r")\b", + re.IGNORECASE, +) # Tautological self-check pattern. A body whose only meaningful work is # `skipUnlessServiceEnabled("X"); expect(isServiceEnabled("X")).toBe(true)` @@ -171,8 +177,7 @@ def _body_contains_real_flow(body: str) -> bool: def _body_contains_stub_marker(body: str) -> bool: - upper = body.upper() - return any(marker in upper for marker in _STUB_MARKERS) + return _STUB_MARKER_RE.search(body) is not None def _is_persona_or_contract_test(title: str) -> bool: