import { expect, test, type Locator, type Page } from "./utils/test"; import { expectNoCriticalA11yViolations } from "./utils/axe"; import { getTenantCredentials, loginAsTenantUser } from "./utils/auth"; import { expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile"; import { escapeRegExp, failOnStripeNetworkRequests, skipIfUnavailable } from "./utils/navigation"; import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness"; const credentials = getTenantCredentials(); const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH; const subscriptionPath = process.env.E2E_TENANT_SUBSCRIPTION_PATH; const pluginSettingsPath = process.env.E2E_PLUGIN_SETTINGS_PATH; const workflowBuilderPath = process.env.E2E_WORKFLOW_BUILDER_PATH; const workflowRunManualPath = process.env.E2E_WORKFLOW_RUN_MANUAL_PATH; test.describe("readiness golden path mobile a11y", () => { test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true }); test.beforeEach(async ({ page }) => { await failOnStripeNetworkRequests(page); }); test("navigates authenticated mobile readiness surfaces without mutations", async ({ page }) => { skipOrFailWhenE2eInputsMissing( [ "E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH", "E2E_TENANT_SUBSCRIPTION_PATH", "E2E_PLUGIN_SETTINGS_PATH", "E2E_WORKFLOW_BUILDER_PATH", "E2E_WORKFLOW_RUN_MANUAL_PATH", ], "Readiness golden path inputs not configured" ); await loginAsTenantUser(page, credentials!); const dashboardResponse = await page.goto(dashboardPath!, { waitUntil: "domcontentloaded" }); await skipIfUnavailable(page, dashboardResponse, `Tenant dashboard path ${dashboardPath}`); await expect(page).toHaveURL(pathPattern(dashboardPath!)); await expect(page.locator('[data-ui-id="ui.action.shell.sidebarTrigger"]').first()).toBeVisible(); await expectReadinessPage(page); const mobileSidebar = page.locator('[data-ui-id="ui.surface.app.sidebar.mobile"], [data-mobile="true"]').first(); await expect(mobileSidebar).toBeHidden(); await page.locator('[data-ui-id="ui.action.shell.sidebarTrigger"]').first().click(); await expect(mobileSidebar).toBeVisible(); await clickAndExpectPath(mobileSidebar.locator('[data-ui-id="ui.nav.app.settings"]').first(), page, /\/settings\/profile(?:[?#].*)?$/u); await expect(mobileSidebar).toBeHidden(); await expectReadinessPage(page); await clickVisibleLinkToPath(page, subscriptionPath!, "Subscription settings link"); await expect(page.locator('[data-ui-id="ui.subscription.page"]').first()).toBeVisible({ timeout: 10_000 }); await expectReadinessPage(page); const checkoutLink = page.locator('[data-ui-id="ui.subscription.checkout.link"]').first(); if (!(await isVisible(checkoutLink))) { skipOrFailWhenE2eFixtureMissing("No checkout catalog link rendered for this fixture"); } await clickAndExpectPath(checkoutLink, page, /\/subscribe\/[^/?#]+(?:[?#].*)?$/u); await expect(page.locator('[data-ui-id="ui.subscription.checkout.page"]').first()).toBeVisible({ timeout: 10_000 }); await expectReadinessPage(page); await clickVisibleLinkToPath(page, subscriptionPath!, "Checkout back-to-subscription link"); await expect(page.locator('[data-ui-id="ui.subscription.page"]').first()).toBeVisible({ timeout: 10_000 }); await clickVisibleLinkToPath(page, pluginSettingsPath!, "Plugin settings link"); await expect(page.locator('[data-ui-id="ui.plugins.page"]').first()).toBeVisible({ timeout: 10_000 }); await expectReadinessPage(page); await page.locator('[data-ui-id="ui.action.shell.sidebarTrigger"]').first().click(); await expect(mobileSidebar).toBeVisible(); await clickAndExpectPath(mobileSidebar.locator('[data-ui-id="ui.nav.app.workflowEngine"]').first(), page, /\/workflow-engine(?:[?#].*)?$/u); await expect(mobileSidebar).toBeHidden(); await clickVisibleLinkToPath(page, workflowListPathFromBuilderPath(workflowBuilderPath!), "Workflow list link"); await clickVisibleLinkToPath(page, workflowBuilderPath!, "Workflow builder link"); await expect(page.locator('[data-ui-id="ui.workflows.builder.canvas"]').first()).toBeVisible({ timeout: 10_000 }); await expectReadinessPage(page); const runTrigger = page.locator('[data-ui-id="ui.workflows.run.dropdown.trigger"]').first(); if (!(await isVisible(runTrigger))) { skipOrFailWhenE2eFixtureMissing("Workflow builder did not render a run dropdown trigger"); } const runTriggerButton = runTrigger.locator("xpath=ancestor::button[1]"); if (!(await runTriggerButton.isEnabled())) { skipOrFailWhenE2eFixtureMissing("Workflow run dropdown is disabled; provide a live deterministic workflow path"); } await runTrigger.click(); const manualRunOption = page.locator('[data-ui-id="ui.workflows.run.dropdown.manual"]').first(); await expect(manualRunOption).toBeVisible(); await clickAndExpectPath(manualRunOption, page, pathPattern(workflowRunManualPath!)); await expect(page.locator('[data-ui-id="ui.workflows.run.manual.form"]').first()).toBeVisible({ timeout: 10_000 }); await expectReadinessPage(page); }); }); async function expectReadinessPage(page: Page): Promise { await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); } async function clickVisibleLinkToPath(page: Page, path: string, label: string): Promise { if (await tryClickVisibleLinkToPath(page, path)) { return; } // On mobile the account/settings shortcuts (e.g. the subscription link) collapse // into the shell "more" overflow popover, which mounts its links in a portal on // open. Open it and retry before declaring the link missing. const moreMenu = page.locator('[data-ui-id="ui.action.shell.more"]').first(); if (await isVisible(moreMenu)) { await moreMenu.click(); await page .locator(`a[href="${path}"]`) .first() .waitFor({ state: "visible", timeout: 3000 }) .catch(() => undefined); if (await tryClickVisibleLinkToPath(page, path)) { return; } await page.keyboard.press("Escape").catch(() => undefined); } // On mobile the settings sub-nav (Profile/Subscription/Plugins/…) collapses into a // section