69 lines
3.4 KiB
TypeScript
69 lines
3.4 KiB
TypeScript
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";
|
|
|
|
/**
|
|
* Lead-inbox interim-UI smoke (R-P7, AD-28, DoD D.19): Login -> /leads open ->
|
|
* the interim triage inbox from ~/ui renders -> main action: follow the
|
|
* "new lead" button into the inline manual-entry dialog -> the identity fields
|
|
* and guarded submit control are reachable.
|
|
*
|
|
* The module is connector-gated (`tenantHasModule('leads')`). Without the
|
|
* entitlement the loader returns a locked View-Model that renders the locked
|
|
* empty-state (no filter bar) instead of the triage 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 leadsPath = process.env.E2E_TENANT_LEADS_PATH ?? dashboardPath.replace(/\/dashboard\/?$/u, "/leads");
|
|
|
|
test.describe("lead inbox interim screen (R-P7)", () => {
|
|
test("renders the triage inbox and reaches the manual-entry form", async ({ page }) => {
|
|
skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD"], "Skipping authenticated lead-inbox smoke");
|
|
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const response = await page.goto(leadsPath, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, response, "Leads module is not reachable in this environment");
|
|
if (!page.url().includes("/leads")) {
|
|
skipOrFailWhenE2eFixtureMissing("Leads route is not available for the test tenant");
|
|
}
|
|
|
|
// The interim inbox shell always renders; a locked entitlement swaps the
|
|
// filter bar + table for the locked empty-state. Local runs skip; readiness
|
|
// fails closed.
|
|
await expect(page.locator('[data-ui-id="ui.leads.list"]')).toBeVisible();
|
|
const filterBar = page.locator('[data-ui-id="ui.leads.list.filter"]');
|
|
if (!(await filterBar.isVisible())) {
|
|
skipOrFailWhenE2eFixtureMissing("Leads connector (leads) is not enabled for the test tenant");
|
|
}
|
|
|
|
// Main action: open the inline manual-entry dialog without leaving the inbox.
|
|
const newButton = page.locator('[data-ui-id="ui.leads.list.new"]');
|
|
if (!(await newButton.isVisible())) {
|
|
skipOrFailWhenE2eFixtureMissing("Test tenant lacks leads.write - create action not rendered");
|
|
}
|
|
await newButton.click();
|
|
|
|
// Expected result: identity fields are usable and submit stays guarded until
|
|
// at least one identifying value is present.
|
|
const createDialog = page.locator('[data-ui-id="ui.leads.new.dialog"]');
|
|
const email = createDialog.locator('[data-ui-id="ui.leads.new.dialog.email"]');
|
|
const submit = createDialog.locator('[data-ui-id="ui.leads.new.dialog.submit"]');
|
|
await expect(createDialog).toBeVisible();
|
|
await expect(email).toBeEditable();
|
|
await expect(submit).toBeDisabled();
|
|
await email.fill("pilot@example.test");
|
|
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);
|
|
});
|
|
});
|