From 761cda9cfce779eb9c80631b5ecfabb12910c89e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 31 Mar 2026 17:04:22 +0000 Subject: [PATCH] Fix leaked mockReturnValueOnce in scored-match test The new test only triggers one selectDistinct call (rows is empty so the max-game-number lookup is skipped). The second mockReturnValueOnce was never consumed, leaving a makeMaxGameChain value in the queue that was then picked up by the subsequent "uses leftJoin" test, causing it to fail with "leftJoin is not a function". https://claude.ai/code/session_01GMLmjN9mwoANfpgSciD7Bi --- app/models/__tests__/upcoming-calendar.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/__tests__/upcoming-calendar.test.ts b/app/models/__tests__/upcoming-calendar.test.ts index e6c970c..b8212fa 100644 --- a/app/models/__tests__/upcoming-calendar.test.ts +++ b/app/models/__tests__/upcoming-calendar.test.ts @@ -573,10 +573,10 @@ describe("getUpcomingEventsForDraftedParticipants — bracket misc", () => { // The DB mock returns rows only for matches the WHERE clause matches. // When a match is complete (isComplete=true) the DB should return no rows. // Simulate this by returning an empty result set. + // No second mockReturnValueOnce is needed: empty rows means eventIdsFromRows + // is empty so the max-game-number lookup is never called. const chain = makeSelectChain([]); - mockDb.selectDistinct - .mockReturnValueOnce(chain) - .mockReturnValueOnce(makeMaxGameChain([])); + mockDb.selectDistinct.mockReturnValueOnce(chain); const result = await getUpcomingEventsForDraftedParticipants( SPORTS_SEASON_ID, "playoff_bracket",