- pnpm workspace with apps/api (Hono/Drizzle) and apps/pwa (Vite/React 19) - Pinned versions per RESEARCH: hono@4.12.23, drizzle-orm@0.45.2, mysql2@3.22.4, tsdav@2.2.2, ical.js@2.2.1, zod@^3.25.0, node-cron@^4.2.1 - docker-compose.yml with mariadb:11 healthcheck, api depends_on service_healthy, redis stub - docker-compose.dev.yml overrides for local dev (bind mounts, exposed ports) - .env.example lists all env vars (DB_*, OIDC_*, APP_PASSWORD_ENCRYPTION_KEY) - .gitignore excludes .env (never commit secrets) - apps/api/vitest.config.ts with environment: node - Wave 0 test stubs: health, auth/user, broker/crypto, broker/sync, broker/poller
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
/**
|
|
* Test DB fixture helpers.
|
|
*
|
|
* For unit tests (Tasks 1-2 scope): provides mock/stub helpers so tests can run
|
|
* without a real MariaDB connection. Plan 02/03 will fill in integration-style
|
|
* fixtures that hit the Docker MariaDB (DB_HOST=127.0.0.1 from the dev compose override).
|
|
*/
|
|
|
|
// Re-export vi for convenience in test files
|
|
export { vi } from 'vitest'
|
|
|
|
/**
|
|
* Creates a minimal mock for the Drizzle `db` singleton.
|
|
* Replace individual methods per test as needed.
|
|
*
|
|
* Plan 02 (auth) will extend this with a real test-schema fixture.
|
|
* Plan 03 (broker) will extend with event-fixture helpers.
|
|
*/
|
|
export function createMockDb() {
|
|
return {
|
|
select: vi.fn().mockReturnThis(),
|
|
from: vi.fn().mockReturnThis(),
|
|
where: vi.fn().mockReturnThis(),
|
|
limit: vi.fn().mockResolvedValue([]),
|
|
insert: vi.fn().mockReturnThis(),
|
|
values: vi.fn().mockReturnThis(),
|
|
onDuplicateKeyUpdate: vi.fn().mockResolvedValue([{ id: 1 }]),
|
|
$returningId: vi.fn().mockResolvedValue([{ id: 1 }]),
|
|
execute: vi.fn().mockResolvedValue([]),
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sample VEVENT string for broker tests — a timed event (Plan 03).
|
|
*/
|
|
export const SAMPLE_VEVENT_TIMED = `BEGIN:VCALENDAR
|
|
VERSION:2.0
|
|
PRODID:-//FamilySync//Test//EN
|
|
BEGIN:VEVENT
|
|
UID:test-timed-event-001@familysync
|
|
DTSTART:20260615T100000Z
|
|
DTEND:20260615T110000Z
|
|
SUMMARY:Test Timed Event
|
|
END:VEVENT
|
|
END:VCALENDAR`
|
|
|
|
/**
|
|
* Sample VEVENT string for broker tests — an all-day event (Plan 03).
|
|
*/
|
|
export const SAMPLE_VEVENT_ALLDAY = `BEGIN:VCALENDAR
|
|
VERSION:2.0
|
|
PRODID:-//FamilySync//Test//EN
|
|
BEGIN:VEVENT
|
|
UID:test-allday-event-001@familysync
|
|
DTSTART;VALUE=DATE:20260615
|
|
DTEND;VALUE=DATE:20260616
|
|
SUMMARY:Test All-Day Event
|
|
END:VEVENT
|
|
END:VCALENDAR`
|