Skip to content

feat: add comprehensive test suite with Vitest and Playwright#16

Merged
kasvith merged 2 commits intomainfrom
feat/tests
Jan 19, 2026
Merged

feat: add comprehensive test suite with Vitest and Playwright#16
kasvith merged 2 commits intomainfrom
feat/tests

Conversation

@kasvith
Copy link
Contributor

@kasvith kasvith commented Jan 19, 2026

Summary

  • Add testing infrastructure with Vitest for unit/integration tests and Playwright for E2E tests
  • Configure separate Vitest configs for main process (node) and renderer process (jsdom)
  • Create test setup files with mocks for Electron APIs
  • Add 98 passing renderer tests covering hooks, contexts, and components
  • Update CI workflow to run tests before build

Test Coverage

Renderer Tests (98 tests):

  • Hooks: useDebounce (7), useKeyboardEvent (11), useKeyboardShortcuts (13)
  • Contexts: SettingsContext (4), ThemeContext (14), UpdateContext (13), BreadcrumbContext (6)
  • Components: DataTable (15), NewPatientForm (14)

Main Process Tests (structure only):

  • Repository tests for patient, doctor, surgery, surgery-template, app-settings, activity, dashboard
  • Backup tests

Integration Tests (structure only):

  • Patient-surgery workflow
  • FTS search
  • Template workflow

E2E Tests (skipped by default):

  • Patient flow, surgery flow, settings, search, onboarding

Notes

Main process and integration tests cannot run with regular Node.js due to better-sqlite3 being compiled for Electron's Node version. These tests are structurally correct but require an Electron test environment to execute.

Test plan

  • pnpm test:run passes (98 tests)
  • pnpm lint passes
  • pnpm typecheck passes
  • CI workflow runs tests successfully

Add testing infrastructure for the application:

- Configure Vitest with separate configs for main and renderer processes
- Add React Testing Library for component testing
- Set up Playwright for E2E testing
- Create test setup files with mocks for Electron APIs

Test coverage includes:
- Renderer hooks: useDebounce, useKeyboardEvent, useKeyboardShortcuts
- Contexts: Settings, Theme, Update, Breadcrumb
- Components: DataTable, NewPatientForm
- Main process: repository tests (structure only, requires Electron env)
- Integration tests (structure only, requires Electron env)
- E2E tests with Playwright (skipped by default)

Update CI workflow to run tests before build.
- Fix activity.test.ts: use camelCase properties (entityType, surgeryId) and
  correct action types ('created'/'updated' instead of 'create'/'update')
- Fix patient.test.ts: use correct schema (phn, birth_year, gender)
- Fix dashboard.test.ts: use correct patient/surgery schema
- Fix surgery.test.ts: use correct schema (title, bht, ward instead of procedure)
- Fix surgery-template.test.ts: use title instead of name
- Fix app-settings.test.ts: handle possibly undefined results
- Fix backup.test.ts: add type annotation for array
- Fix NewPatientForm.test.tsx: use Date objects for created_at/updated_at
- Fix renderer-setup.ts: import beforeEach from vitest
- Update tsconfig.web.json: add jest-dom types
- Update CI workflow: run tests after lint and typecheck
@kasvith kasvith merged commit 1e020a5 into main Jan 19, 2026
2 checks passed
@kasvith kasvith deleted the feat/tests branch January 19, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant