Test Status
Last updated: 2026-02-15
Overview
| Area | Test Files | Tests | Passing | Failing |
|---|---|---|---|---|
| Backend (workers/api) | 10 | 104 | 96 | 8 |
| Frontend (apps/web) | 4 | 51 | 44 | 7 |
| Total | 14 | 155 | 140 | 15 |
Pass rate: 90% (all 15 failures are mock/setup issues, not real code bugs)
Backend Tests (workers/api)
Passing (8 files, 96 tests)
| File | Tests | What it covers |
|---|---|---|
| auth.test.ts | 11 | Auth middleware, JWT validation, session handling |
| credits.test.ts | 14 | Credit balance, transactions, deductions, packages |
| diff-engine.test.ts | 8 | Version diffing, change detection between snapshots |
| extract.test.ts | 8 | Image upload, AI extraction triggering, status updates |
| share.test.ts | 10 | Share link creation, password protection, expiry, viewing |
| template-renderer.test.ts | 16 | All 8 HTML template outputs, accessibility attributes |
| vision-extractor.test.ts | 9 | AI vision parsing, hierarchy building, error handling |
| wcag-validator.test.ts | 15 | WCAG 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 foruser_idfiltering. - 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)
| File | Tests | What it covers |
|---|---|---|
| OrgDataTable.test.tsx | ~22 | Table rendering, inline editing, add/delete rows, manager dropdown |
| TemplatePicker.test.tsx | ~22 | Template 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
onAuthStateChangecallbacks, causing the AuthProvider to never finish loading. All tests time out at 5 seconds. - Fix: Update the mock to call the
onAuthStateChangecallback synchronously during setup with the expected session data.
api.test.ts (compilation error)
- Root cause:
ReferenceError: Cannot access 'mockGetSession' before initializationβ thevi.mock()hoisting interacts badly with the variable declaration order. - Fix: Move the mock variable declarations above the
vi.mock()call, or usevi.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
- orgcharts.test.ts β Fix Supabase mock to support chained
.eq().eq()calls - generate.test.ts β Add chart lookup mock before generate assertions
- auth-context.test.tsx β Fix
onAuthStateChangemock to trigger callback - 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 chartversions.tsβ Version creation, listing, restorestripe.tsβ Webhook handling, checkout session creationadmin.tsβ Admin-only endpointsexport.tsβ HTML/download generation endpoints
Estimated effort: ~4 hours
Priority 3: Backend service/utility tests
email.tsβ Email sending serviceextraction-validator.tsβ Validates extracted data qualityaxe-validator.tsβ axe-core integration for WCAG validationshare-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 testscripts configured