Skip to content

Test Status

Last updated: 2026-02-15

Overview

AreaTest FilesTestsPassingFailing
Backend (workers/api)10104968
Frontend (apps/web)451447
Total1415514015

Pass rate: 90% (all 15 failures are mock/setup issues, not real code bugs)

Backend Tests (workers/api)

Passing (8 files, 96 tests)

FileTestsWhat it covers
auth.test.ts11Auth middleware, JWT validation, session handling
credits.test.ts14Credit balance, transactions, deductions, packages
diff-engine.test.ts8Version diffing, change detection between snapshots
extract.test.ts8Image upload, AI extraction triggering, status updates
share.test.ts10Share link creation, password protection, expiry, viewing
template-renderer.test.ts16All 8 HTML template outputs, accessibility attributes
vision-extractor.test.ts9AI vision parsing, hierarchy building, error handling
wcag-validator.test.ts15WCAG 2.1 AA rule checks, contrast, ARIA, headings

Failing (2 files, 8 tests)

orgcharts.test.ts (4 failures)

  • Root cause: Supabase mock chain is incomplete. The mock for .from().select().eq() doesn’t support a second .eq() call that the route handler chains for user_id filtering.
  • Fix: Update the mock factory to return chainable .eq() methods that accumulate filters and return the expected data.

generate.test.ts (4 failures)

  • Root cause: The generate route expects the org chart to be fetched first (returning 404 when the mock doesn’t set up the chart lookup), and the outputs list mock returns empty instead of the expected seeded data.
  • Fix: Add proper chart lookup mocking before the generate/outputs assertions.

Frontend Tests (apps/web)

Passing (2 files, 44 tests)

FileTestsWhat it covers
OrgDataTable.test.tsx~22Table rendering, inline editing, add/delete rows, manager dropdown
TemplatePicker.test.tsx~22Template selection, radio group semantics, category filtering

Failing (2 files, 7 tests)

auth-context.test.tsx (7 failures)

  • Root cause: Supabase auth mock doesn’t trigger onAuthStateChange callbacks, causing the AuthProvider to never finish loading. All tests time out at 5 seconds.
  • Fix: Update the mock to call the onAuthStateChange callback synchronously during setup with the expected session data.

api.test.ts (compilation error)

  • Root cause: ReferenceError: Cannot access 'mockGetSession' before initialization β€” the vi.mock() hoisting interacts badly with the variable declaration order.
  • Fix: Move the mock variable declarations above the vi.mock() call, or use vi.hoisted() to ensure proper initialization order.

Source File Coverage

Backend (38 source files)

Covered by tests (10/38 = 26%):

  • Routes: auth, credits, extract, generate, orgcharts, share
  • Services: vision-extractor, wcag-validator, diff-engine
  • Templates: template renderer (covers all 8 templates)

Not covered (28 files):

  • Routes: stripe, versions, people, admin, export
  • Services: email, extraction-validator, wcag-reporter, axe-validator, share-tokens
  • Middleware: auth, storage
  • Utils: crypto, response, html, supabase, color
  • Types, index

Frontend (34 source files)

Covered by tests (4/34 = 12%):

  • Components: OrgDataTable, TemplatePicker
  • Lib: api, auth-context

Not covered (30 files):

  • All 11 pages (dashboard, editor, preview, share, settings, admin, admin/docs, login, callback, marketing, root)
  • Components: Header, LoginPrompt, ServiceBanner, BulkImportModal, DropZone, PersonForm, VersionHistory, OrgChartPreview, TemplatePreview, generate/TemplatePicker
  • Hooks: useUpload, useOrgChart
  • Lib: utils, supabase, use-is-admin
  • Data: admin-docs
  • Types: index

What Needs to Be Done

Priority 1: Fix the 15 failing tests

  1. orgcharts.test.ts β€” Fix Supabase mock to support chained .eq().eq() calls
  2. generate.test.ts β€” Add chart lookup mock before generate assertions
  3. auth-context.test.tsx β€” Fix onAuthStateChange mock to trigger callback
  4. api.test.ts β€” Fix mock hoisting order with vi.hoisted()

Estimated effort: ~2 hours

Priority 2: Backend route tests

Add tests for the 5 uncovered route files:

  • people.ts β€” CRUD operations for people in an org chart
  • versions.ts β€” Version creation, listing, restore
  • stripe.ts β€” Webhook handling, checkout session creation
  • admin.ts β€” Admin-only endpoints
  • export.ts β€” HTML/download generation endpoints

Estimated effort: ~4 hours

Priority 3: Backend service/utility tests

  • email.ts β€” Email sending service
  • extraction-validator.ts β€” Validates extracted data quality
  • axe-validator.ts β€” axe-core integration for WCAG validation
  • share-tokens.ts β€” Token generation and validation
  • Utils: crypto, response, html, color

Estimated effort: ~3 hours

Priority 4: Frontend component tests

  • Header (navigation, user menu, mobile responsive)
  • DropZone (file upload, drag & drop, validation)
  • PersonForm (form validation, submit handling)
  • BulkImportModal (CSV parsing, import flow)
  • VersionHistory (version list, restore action)

Estimated effort: ~4 hours

Priority 5: Frontend page integration tests

  • Dashboard (chart listing, upload flow, delete)
  • Editor (data table editing, template selection, generation)
  • Preview (output display, template switching, share/download)
  • Login (Google OAuth, magic link flow)
  • Settings (credit display, package purchase)

Estimated effort: ~6 hours

Test Infrastructure Notes

  • Test framework: Vitest 2.x
  • Backend environment: Node
  • Frontend environment: jsdom with @vitejs/plugin-react
  • Coverage provider: @vitest/coverage-v8
  • Frontend setup file: apps/web/src/__tests__/setup.ts
  • Both packages have npm test scripts configured