Services

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.tsisMockMode() returns true only when VITE_USE_MOCK_API === "true".
  • packages/saas-api/src/auth.ts — exports mockAuthApi instead of the real auth client when mock mode is enabled.
  • apps/manager/.env.example — documents VITE_USE_MOCK_API=false as the default env example.
  • .mise.tomlmise run dev and mise run dev:manager set VITE_USE_MOCK_API=true for local mock-backed manager development.

Available mock login users#

Source of truth: packages/saas-api/src/mock.ts.

UserRoleEmailPasswordNotes
John Doecustomerjohn@example.comcustomer123Active, verified customer.
Jane Smithadminjane@example.comadmin123Active, verified admin.

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:

  • admin signs in to /admin.
  • customer signs 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 /dashboard when a session is stored, otherwise to /login.

Focused verification#

Commands verified on 2026-04-30:

bash
1
mise exec -- pnpm --filter @assistance/saas-api typecheck
2
mise exec -- pnpm --filter @assistance/saas-api test
3
mise exec -- pnpm --filter manager typecheck
4
mise exec -- pnpm --filter manager test
5
mise exec -- pnpm --filter manager build

Observed passing results:

  • @assistance/saas-api typecheck passed.
  • @assistance/saas-api tests passed: 1 test file, 17 tests.
  • manager typecheck passed.
  • manager tests passed: 10 test files, 47 tests.
  • manager build passed with Vite.

Playwright E2E#

Focused E2E verification on 2026-04-30:

bash
1
mise exec -- pnpm e2e:manager
2
mise exec -- pnpm --filter manager typecheck
3
timeout 5s mise exec -- pnpm e2e:manager:report

Observed results:

  • pnpm e2e:manager passed: 14 manager Playwright tests passed in Chromium.
  • pnpm --filter manager typecheck passed with tsc --noEmit.
  • pnpm e2e:manager:report found the generated HTML report and served it at http://localhost:9323; the worker stopped it with timeout to avoid leaving a long-lived report server running.

Run these commands from the repo root:

bash
1
mise exec -- pnpm e2e:manager # dev mode: Vite dev server on :3045
2
mise exec -- pnpm e2e:manager:ui # open Playwright UI mode for manager specs
3
mise 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:

bash
1
mise exec -- env E2E_WEB_SERVER=prod pnpm e2e:manager

The 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.