import { expect, test } from "./utils/test"; import { expectNoCriticalA11yViolations } from "./utils/axe"; import { expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile"; const authRoutes = ["/login", "/forgot-password", "/reset", "/auth/magic-link", "/register"] as const; // Use the seeded tenant slug: an unauthenticated deep link only redirects to // /login (with redirectTo) for an existing tenant. A non-existent slug resolves // before auth and redirects home instead. Falls back to the default-seed "acme". const tenantSlug = process.env.E2E_TENANT_ACCOUNT_SLUG ?? "acme"; const tenantProtectedRoutes = [ `/${tenantSlug}/settings/integrations/plugins`, `/${tenantSlug}/settings/billing`, `/${tenantSlug}/workflow-engine`, `/${tenantSlug}/workflow-engine/workflows/example/run/manual`, ]; const emailInputSelector = 'input[type="email"], input[name="email"], input#email'; const passwordInputSelector = 'input[type="password"], input[name="password"], input#password'; test.describe("mobile auth locale", () => { test.use({ locale: "de-DE", viewport: narrowMobileViewport, isMobile: true, hasTouch: true }); test("mobile auth pages resolve German locale without overflow", async ({ page }) => { for (const route of authRoutes) { await page.goto(route, { waitUntil: "domcontentloaded" }); await expect(page.locator("html")).toHaveAttribute("lang", "de"); await expect(page.locator("html")).toHaveAttribute("dir", "ltr"); await expect(page.locator("body")).toBeVisible(); const emailInput = page.locator(emailInputSelector).first(); if ((await emailInput.count()) > 0) { await expect(emailInput).toBeVisible(); } const passwordInput = page.locator(passwordInputSelector).first(); if ((await passwordInput.count()) > 0) { await expect(passwordInput).toBeVisible(); } await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); } }); test("mobile auth pages resolve English locale without overflow", async ({ browser }) => { const context = await browser.newContext({ locale: "en-US", viewport: narrowMobileViewport, isMobile: true, hasTouch: true }); const page = await context.newPage(); try { for (const route of authRoutes) { await page.goto(route, { waitUntil: "domcontentloaded" }); await expect(page.locator("html")).toHaveAttribute("lang", "en"); await expect(page.locator("html")).toHaveAttribute("dir", "ltr"); await expect(page.locator("body")).toBeVisible(); await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); } } finally { await context.close(); } }); test("tenant protected deep links preserve redirectTo under mobile German locale", async ({ page }) => { for (const protectedRoute of tenantProtectedRoutes) { await page.goto(protectedRoute, { waitUntil: "domcontentloaded" }); await expect(page.locator("html")).toHaveAttribute("lang", "de"); await expect(page.locator("html")).toHaveAttribute("dir", "ltr"); const currentUrl = new URL(page.url()); expect(currentUrl.pathname).toBe("/login"); expect(currentUrl.searchParams.get("redirectTo")).toBe(protectedRoute); await expect(page.locator(emailInputSelector).first()).toBeVisible(); await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); } }); });