test(apps/app): set up Vitest harness — closes TECH-APP-VITEST (WS-6)

Mirrors apps/portal's Vitest setup so the SPA can take frontend
unit + component tests. Required prerequisite for WS-6 sessie 3b's
admin UI work — apps/portal had 113+ tests, apps/app had zero, and
launching WS-6's organizer UI uncovered while the portal SPA is
well-tested would be asymmetric quality.

Setup:
- vitest, happy-dom, @vue/test-utils, @testing-library/vue installed
- vitest.config.ts mirrors portal config: trimmed auto-imports
  (no pinia/vue-router/vue-i18n/@vueuse/math) so tests run fast
  in happy-dom without loading the full Vuexy bundle
- AutoImport's dts:false prevents the trimmed test-only set from
  clobbering the dev-server's full auto-imports.d.ts (apps/app's
  auto-import surface is bigger than the portal's)
- tests/setup.ts mocks vue-router by default; tests that exercise
  the real router can override per-suite
- Sample sanity test confirms the harness works end-to-end

Adds `pnpm test` and `pnpm test:watch` scripts to package.json.

Refs: BACKLOG TECH-APP-VITEST, WS-6 sessie 3b prerequisite

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-28 21:34:27 +02:00
parent 8a4682ab35
commit d95e68423d
5 changed files with 718 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest'
/**
* Harness sanity check — confirms Vitest + happy-dom + auto-imports
* are wired correctly. If this passes, real tests under
* src/**\/__tests__/ can run without per-suite plumbing.
*
* Tracked: BACKLOG TECH-APP-VITEST closed by WS-6 sessie 3b.
*/
describe('vitest harness', () => {
it('runs in happy-dom with globals', () => {
expect(typeof window).toBe('object')
expect(typeof document).toBe('object')
})
it('truth holds', () => {
expect(true).toBe(true)
})
})

8
apps/app/tests/setup.ts Normal file
View File

@@ -0,0 +1,8 @@
import { vi } from 'vitest'
// Default vue-router mock — individual tests can override with their own mock.
// Page-level tests that exercise the actual router should not import this.
vi.mock('vue-router', () => ({
useRoute: () => ({ params: {}, query: {} }),
useRouter: () => ({ push: vi.fn(), replace: vi.fn() }),
}))