test: add unit and integration test suites

- Extract evaluateCondition + rule types into src/lib/rules.ts for testability
- 48 unit tests for evaluateCondition (all fields/operators) and formatCategory
- 21 integration tests for getTransactions filters and getParticipantBalances
- Vitest configs for unit (vitest.config.ts) and integration (vitest.integration.config.ts)
- setup-test-db.sh creates personal_test DB from production schema via pg_dump
- Use vi.doMock + dynamic import pattern to isolate test DB from Prisma singleton
This commit is contained in:
2026-04-01 19:59:29 +11:00
parent 7491e70a15
commit 1296555f17
12 changed files with 2036 additions and 74 deletions
+10 -2
View File
@@ -6,7 +6,12 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
"lint": "eslint",
"test": "vitest run --config vitest.config.ts",
"test:watch": "vitest --config vitest.config.ts",
"test:setup": "bash scripts/setup-test-db.sh",
"test:integration": "vitest run --config vitest.integration.config.ts",
"test:all": "npm test && npm run test:integration"
},
"dependencies": {
"@prisma/adapter-pg": "^7.4.2",
@@ -25,9 +30,12 @@
"@types/pg": "^8.18.0",
"@types/react": "^19",
"@types/react-dom": "^19",
"@vitest/coverage-v8": "^4.1.2",
"eslint": "^9",
"eslint-config-next": "16.1.6",
"tailwindcss": "^4",
"typescript": "^5"
"typescript": "^5",
"vite-tsconfig-paths": "^6.1.1",
"vitest": "^4.1.2"
}
}