test(db): add integration tests for projectsRepository#907
Conversation
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM — Thorough, well-structured integration test suite that directly covers the projectsRepository functions with 39 test cases.
The tests accurately reflect the repository implementation: engine settings normalization behavior (empty → undefined → stored as null, undefined Drizzle skips), numeric(5,1) decimal formatting for progressIntervalMinutes, and org-scoped CRUD isolation are all correctly tested against the actual normalizeEngineSettings logic and Drizzle ORM behavior.
Test structure follows existing codebase patterns (truncateAll + seedOrg/seedProject in beforeEach, same import style, same helper usage), and complements the existing repositories-edge-cases.test.ts which only tests via settingsRepository wrappers. All CI checks pass.
🕵️ claude-code · claude-opus-4-6 · run details
Summary
tests/integration/db/projectsRepository.test.ts— a dedicated integration test suite for the directprojectsRepositoryfunctionsrepositories-edge-cases.test.ts(which only tests viasettingsRepositorywrappers)Card: https://trello.com/c/69b8002e918878f999a41e58
What was tested
createProject— required fields with defaults, all optional fields, null persistence for all nullable columns, engine settings normalization (empty sub-objects stripped)listProjectsFull— org-scoped listing, multiple projects, empty org, post-deletion empty listlistAllProjects— cross-org listing vs. org-scoped listinggetProjectFull— happy path, wrong orgId returns null, non-existent project, cross-org isolationupdateProject— basic fields, partial updates (no side-effects), nullable fields set to null, orgId scoping (wrong org = no-op), engineSettings normalization (empty → no-op, valid → persisted, null → cleared, absent key → unchanged)deleteProject— removes project, orgId scoping (wrong org = no-op), idempotent on non-existent ID, removes only targeted projectnormalizeEngineSettingsbehavior verified (empty sub-objects collapse to null, partial non-empty entries preserved)numeric(5,1)format forprogressIntervalMinutes)getProjectFullcross-org boundaryKey decisions
projects_pkeyis a global primary key onid(not per-org), so tests use unique IDs across all orgs rather than testing "same ID in different orgs" (which violates the DB constraint)progressIntervalMinutesisnumeric(5,1)— DB returns'3.0'for input'3', so tests assert the normalized decimal string formnormalizeEngineSettings({engine: {}})returnsundefined, which Drizzle treats as "skip this column in SET" — the update is effectively a no-op, not a null-set; this is documented in the testTest plan
🤖 Generated with Claude Code
🕵️ claude-code · claude-sonnet-4-6 · run details