Skip to content

test(db): add integration tests for projectsRepository#907

Merged
aaight merged 1 commit intodevfrom
feature/integration-tests-projects-repository
Mar 16, 2026
Merged

test(db): add integration tests for projectsRepository#907
aaight merged 1 commit intodevfrom
feature/integration-tests-projects-repository

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 16, 2026

Summary

  • Adds tests/integration/db/projectsRepository.test.ts — a dedicated integration test suite for the direct projectsRepository functions
  • Covers full CRUD, org scoping, engine settings normalization, optional field persistence, and cross-org listing with 39 test cases
  • Closes coverage gap not addressed by repositories-edge-cases.test.ts (which only tests via settingsRepository wrappers)

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 list
  • listAllProjects — cross-org listing vs. org-scoped listing
  • getProjectFull — happy path, wrong orgId returns null, non-existent project, cross-org isolation
  • updateProject — 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 project
  • Engine settings normalization — JSONB round-trips via create and update; normalizeEngineSettings behavior verified (empty sub-objects collapse to null, partial non-empty entries preserved)
  • Optional fields round-trip — all nullable fields persist and read back correctly (including numeric(5,1) format for progressIntervalMinutes)
  • Multi-org isolation — scoped and cross-org listing, getProjectFull cross-org boundary

Key decisions

  • projects_pkey is a global primary key on id (not per-org), so tests use unique IDs across all orgs rather than testing "same ID in different orgs" (which violates the DB constraint)
  • progressIntervalMinutes is numeric(5,1) — DB returns '3.0' for input '3', so tests assert the normalized decimal string form
  • normalizeEngineSettings({engine: {}}) returns undefined, 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 test

Test plan

  • 39 new integration tests all pass
  • Full integration suite: 400 tests pass (19 test files)
  • Full unit suite: 5415 tests pass (289 test files)
  • Lint: zero errors
  • Typecheck: zero errors

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@aaight aaight merged commit 5604640 into dev Mar 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants