import { expect, test } from "./utils/test"; import { expectNoCriticalA11yViolations } from "./utils/axe"; import { getTenantCredentials, loginAsTenantUser } from "./utils/auth"; import { skipIfUnavailable } from "./utils/navigation"; import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness"; /** * CRM interim-UI smoke (R-P6, AD-28, DoD D.19): Login -> /contacts open -> * the interim list screen from ~/ui renders -> main action: follow the * "new contact" button into the inline create dialog -> the contact fields * and guarded submit action are reachable. * * The module is connector-gated (`tenantHasModule('crm-basic')`). Without the * entitlement the loader returns a locked View-Model that renders * `ui.crm.list.locked` instead of the table; without the route the shell * answers 404. Local runs skip those fixture gaps; required readiness fails * closed. */ const credentials = getTenantCredentials(); const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH ?? "/app/dashboard"; const crmPath = process.env.E2E_TENANT_CRM_PATH ?? dashboardPath.replace(/\/dashboard\/?$/u, "/contacts"); test.describe("crm interim screen (R-P6)", () => { test("renders the contact list and reaches the create form", async ({ page }) => { skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD"], "Skipping authenticated CRM smoke"); await loginAsTenantUser(page, credentials!); const response = await page.goto(crmPath, { waitUntil: "domcontentloaded" }); await skipIfUnavailable(page, response, "CRM module is not reachable in this environment"); if (!page.url().includes("/contacts")) { skipOrFailWhenE2eFixtureMissing("CRM route is not available for the test tenant"); } // The interim list shell always renders; a locked entitlement swaps the // table for the locked empty-state. Local runs skip; readiness fails closed. await expect(page.locator('[data-ui-id="ui.crm.list"]')).toBeVisible(); const locked = page.locator('[data-ui-id="ui.crm.list.locked"]'); if (await locked.isVisible()) { skipOrFailWhenE2eFixtureMissing("CRM connector (crm-basic) is not enabled for the test tenant"); } // Main action: open the inline create dialog without leaving the list. const newButton = page.locator('[data-ui-id="ui.crm.list.new"]'); await expect(newButton).toBeVisible(); await newButton.click(); // Expected result: the inline form is usable and the submit remains guarded // until a contact identity is present. const createDialog = page.locator('[data-ui-id="ui.crm.new.dialog"]'); const firstName = createDialog.locator('[data-ui-id="ui.crm.new.dialog.vorname"]'); const submit = createDialog.locator('[data-ui-id="ui.crm.new.dialog.submit"]'); await expect(createDialog).toBeVisible(); await expect(firstName).toBeEditable(); await expect(submit).toBeDisabled(); await firstName.fill("Pilot"); await expect(submit).toBeEnabled(); // No horizontal page overflow on the interim screen. const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); expect(overflow).toBeLessThanOrEqual(1); await expectNoCriticalA11yViolations(page); }); });