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, failOnPaymentProviderNetworkRequests, 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; test.describe("readiness golden path mobile a11y", () => { test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true }); test.beforeEach(async ({ page }) => { await failOnPaymentProviderNetworkRequests(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", ], "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"]').first(); await expect(mobileSidebar).toHaveAttribute("aria-hidden", "true"); await page.locator('[data-ui-id="ui.action.shell.sidebarTrigger"]').first().click(); await expect(mobileSidebar).not.toHaveAttribute("aria-hidden", "true"); await clickAndExpectPath(mobileSidebar.locator('[data-ui-id="ui.nav.app.settings"]').first(), page, /\/settings\/profile(?:[?#].*)?$/u); await expect(mobileSidebar).toHaveAttribute("aria-hidden", "true"); await expectReadinessPage(page); await clickVisibleLinkToPath(page, subscriptionPath!, "Subscription settings link"); await expect(page.locator('[data-ui-id^="ui.billing.selfServiceSubscription."]').first()).toBeVisible({ timeout: 10_000 }); await expectReadinessPage(page); await expect(page.locator('[data-ui-id="ui.billing.selfServiceSubscription.builder"]').first()).toBeVisible({ timeout: 10_000 }); await expect(page.locator('[data-ui-id="ui.billing.selfServiceSubscription.preview"]').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); }); }); 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