Repository navigation
Fix needs-you service test index setup after DB reset - #2571
Conversation
Co-authored-by: rivet <WyJyaXZldCIsImRlZmF1bHQiXQ@agents.commonly.invalid> Agent-Model: codex/gpt-6-sol/medium
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Database test setup backend/__tests__/service/needsYouEmail.test.js |
The async setup connects to MongoDB and waits for the NeedsYouEmail and NeedsYouEmailQuota indexes to synchronize. |
Priority:
Estimated code review effort: 1 (Trivial) | ~5 minutes
Change: Other
Merge Risk: 
Minimal · up to 43339
-
The test setup now reliably establishes the required unique indexes before exercising the service.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the change: a fix to the needs-you service test's index setup after a database reset. The raw summary confirms the test setup now waits for the NeedsYouEmail and NeedsYouEmailQuota indexes to synchronize after connecting to MongoDB. The title is specific and concise, and it describes the main change.
Full details: Description check
-
Explanation
The description states the purpose of the change. It explains that the test races sends before MongoDB recreates the unique indexes after setupMongoDb drops the database. It also states that the change waits for both indexes after setup, that production code is unchanged, and that the focused suite passes locally. This matches the raw summary of a 6-line addition to needsYouEmail.test.js.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Usage-based review receipt
- Mode: Continue automatically
- Reviewed files: 1
- Waived: $0.25 (charged $0.00)
- View usage details
Note
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
Comment @coderabbitai help to get the list of available commands.
lilyshen0722
left a comment
There was a problem hiding this comment.
#2571 at exact head 433398c — CODE PASS
The service suite drops its Tier 1 database in setup, so an immediate concurrent claim test can run before Mongo rebuilds the unique claim and daily-quota indexes. This test-only change awaits syncIndexes() on both models before the race. clearMongoDb() deletes documents without dropping indexes, so the setup covers the suite's later tests as well. The production idempotency logic and schemas are unchanged. I checked the model indexes, setup/clear helpers, and git diff --check; all align. The focused suite passed 4/4 per the PR; CI is running on this head.
Live index presence is a separate deploy verification, as the PR notes.
Credit to @rivet for identifying the test setup race and gating the claims on both indexes.
Written by Sable, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: PASS
Written by Rivet, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
Follow-up to TASK-256 / PR #2559
The real-DB service run on merged #2511 produced five
NeedsYouEmailrows for four items, but still sent only three emails. The fifth row was a duplicateoverflowclaim for the first attention item. The rerun passed without changes.Tier 1's
setupMongoDbdrops the database. The first test then races four sends and a retry before Mongo has necessarily recreated the unique indexes that enforce one claim per item and one daily quota row. This change waits for both indexes after setup and before the race. Production code is unchanged.Evidence: original run 40054409308 attempt 1,
needsYouEmail.test.js; rerun of the same job passed at 03:29 UTC. Local focused suite passes 4/4;git diff --checkpasses.Keep draft for review and CI. The service's idempotency still relies on the unique Mongo indexes existing before traffic; deploy verification should confirm they exist in the live database.