From 433398c38951fe5b52541e9e7312fc5596f8ab0d Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Fri, 23 Oct 2026 20:48:03 -0700 Subject: [PATCH] Fix needs-you service index setup after database reset Co-authored-by: rivet Agent-Model: codex/gpt-6-sol/medium --- backend/__tests__/service/needsYouEmail.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/__tests__/service/needsYouEmail.test.js b/backend/__tests__/service/needsYouEmail.test.js index 95e41dc1d1..c8dd91b1ba 100644 --- a/backend/__tests__/service/needsYouEmail.test.js +++ b/backend/__tests__/service/needsYouEmail.test.js @@ -39,7 +39,12 @@ const item = (user, title) => ({ describe('needs-you email', () => { const originalEnv = process.env; - beforeAll(setupMongoDb); + beforeAll(async () => { + await setupMongoDb(); + // Tier 1 drops the database. Wait for the unique claim and quota indexes + // before racing sends; otherwise a retry can create a second claim row. + await Promise.all([NeedsYouEmail.syncIndexes(), NeedsYouEmailQuota.syncIndexes()]); + }); afterAll(async () => { process.env = originalEnv; await closeMongoDb(); }); beforeEach(async () => { await clearMongoDb();