Manager Mock Auth
Manager mock auth workflow
This note documents the current mock-auth path for apps/manager. It is intentionally narrow: it covers the manager Vite app and @assistance/saas-api mock client only.
Mock mode control#
Mock mode is controlled by VITE_USE_MOCK_API=true. Manager Playwright E2E tests run with this value in both dev and production-style server modes.
Durable control points:
packages/saas-api/src/client.ts—isMockMode()returns true only whenVITE_USE_MOCK_API === "true".packages/saas-api/src/auth.ts— exportsmockAuthApiinstead of the real auth client when mock mode is enabled.apps/manager/.env.example— documentsVITE_USE_MOCK_API=falseas the default env example..mise.toml—mise run devandmise run dev:managersetVITE_USE_MOCK_API=truefor local mock-backed manager development.
Available mock login users#
Source of truth: packages/saas-api/src/mock.ts.
Bob Wilson exists in mock user data as an active unverified customer, but has no login credential in mockCredentials; he is not a selectable login option.
Expected routes by role#
The login page renders mock user shortcuts when mock mode is active (apps/manager/src/routes/_auth/login.tsx). After successful login:
adminsigns in to/admin.customersigns in to/dashboard.
Route guards live in apps/manager/src/lib/auth-guards.ts and apps/manager/src/router.tsx:
- Dashboard routes require any stored session and redirect unauthenticated users to
/login. - Admin routes require a privileged role and redirect non-admin users to
/dashboard. /redirects to/dashboardwhen a session is stored, otherwise to/login.
Focused verification#
Commands verified on 2026-04-30:
1mise exec -- pnpm --filter @assistance/saas-api typecheck2mise exec -- pnpm --filter @assistance/saas-api test3mise exec -- pnpm --filter manager typecheck4mise exec -- pnpm --filter manager test5mise exec -- pnpm --filter manager buildObserved passing results:
@assistance/saas-apitypecheck passed.@assistance/saas-apitests passed: 1 test file, 17 tests.managertypecheck passed.managertests passed: 10 test files, 47 tests.managerbuild passed with Vite.
Playwright E2E#
Focused E2E verification on 2026-04-30:
1mise exec -- pnpm e2e:manager2mise exec -- pnpm --filter manager typecheck3timeout 5s mise exec -- pnpm e2e:manager:reportObserved results:
pnpm e2e:managerpassed: 14 manager Playwright tests passed in Chromium.pnpm --filter manager typecheckpassed withtsc --noEmit.pnpm e2e:manager:reportfound the generated HTML report and served it athttp://localhost:9323; the worker stopped it withtimeoutto avoid leaving a long-lived report server running.
Run these commands from the repo root:
1mise exec -- pnpm e2e:manager # dev mode: Vite dev server on :30452mise exec -- pnpm e2e:manager:ui # open Playwright UI mode for manager specs3mise exec -- pnpm e2e:manager:report # open the latest HTML report from playwright-report/Production-style E2E mode builds the manager app, then serves it with vite preview on the same port:
1mise exec -- env E2E_WEB_SERVER=prod pnpm e2e:managerThe HTML report is written to playwright-report/. The report viewer is intentionally a long-lived local server; use mise exec -- pnpm e2e:manager:report manually when you want to inspect the report in a browser, then stop it with Ctrl+C. Failure artifacts and trace zips are under test-results/; open a trace with mise exec -- pnpm exec playwright show-trace <path-to-trace.zip>.
Related mock-data workflow details, route coverage, and latest focused verification evidence are documented in docs/product/manager-mock-data.md.