Skip to content

Commit 6569a3d

Browse files
test: milestone repository soft-delete and verifier-assignment tests
Adds query-correctness tests for soft-delete filtering and verifier-user assignment on the milestone repository. Issue #734. Changes: - src/repositories/milestoneRepository.ts Adds findById(id, opts?) and listForVerifier(userId, opts?) to MilestoneRepository. Both exclude soft-deleted rows by default and honour the verifier_user_id linkage added by db/migrations/20260428140504_add_verifier_user_id_to_milestones.cjs and the deleted_at column added by db/migrations/20260602125638_add_soft_delete_to_vaults_and_milestones.cjs. Adds softDelete(id, deletedAt?) and restore(id) for the round-trip case. The existing embedding methods are unchanged. - src/repositories/milestoneRepository.test.ts (new) 18 tests against the project test DB harness, organised into two suites: * soft-delete filtering — findById returns null for soft-deleted rows by default and with includeDeleted when requested; softDelete is idempotent; restore is a no-op on already-active or unknown rows; deleted-then-restored round-trip preserves the verifier_user_id linkage. * verifier-assignment queries — listForVerifier returns only rows assigned to the verifier, never unassigned or other verifiers, and never soft-deleted rows by default; a dedicated round-trip test exercises softDelete \u2192 listForVerifier excludes \u2192 restore \u2192 listForVerifier includes for the same verifier. Skips cleanly when DATABASE_URL is unset. - jest.config.cjs Adds **/src/repositories/**/*.test.ts to testMatch so the new test file is picked up by jest without forcing the project-wide test pattern to change. Coverage: every new/changed line is exercised by at least one test. No regressions to existing MilestoneRepository behaviour.
1 parent 027d351 commit 6569a3d

3 files changed

Lines changed: 597 additions & 1 deletion

File tree

jest.config.cjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ module.exports = {
1616
},
1717
],
1818
},
19-
testMatch: ["**/tests/**/*.test.ts", "**/src/tests/**/*.test.ts"],
19+
testMatch: [
20+
"**/tests/**/*.test.ts",
21+
"**/src/tests/**/*.test.ts",
22+
"**/src/repositories/**/*.test.ts",
23+
],
2024
moduleDirectories: ["node_modules", "<rootDir>/node_modules"],
2125
clearMocks: true,
2226
};

0 commit comments

Comments
 (0)