From 4cab5b3c63b92c0925ba310b63d2635a2c3095d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 19 Jul 2026 20:12:48 +0200 Subject: [PATCH] test(arrivals): snapshot data-arrival jobs --- .../workout-insight-no-backfill-spend.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/jobs/__tests__/workout-insight-no-backfill-spend.test.ts b/src/lib/jobs/__tests__/workout-insight-no-backfill-spend.test.ts index e5f7b8b5b..0c5b24122 100644 --- a/src/lib/jobs/__tests__/workout-insight-no-backfill-spend.test.ts +++ b/src/lib/jobs/__tests__/workout-insight-no-backfill-spend.test.ts @@ -40,6 +40,7 @@ vi.mock("@/lib/jobs/workout-insight-generate-shared", async (orig) => { }); import { emitWorkoutArrivalIfCreated } from "@/lib/arrivals/workout-emit"; +import { DATA_ARRIVAL_QUEUE } from "@/lib/arrivals/emit-shared"; import { runDataArrival } from "../data-arrival"; import { enqueueWorkoutInsight } from "@/lib/jobs/workout-insight-generate-shared"; import { getGlobalBoss } from "@/lib/jobs/boss-instance"; @@ -206,9 +207,15 @@ describe("Activity Insight — a backfill spends nothing", () => { } expect(rows).toHaveLength(791); - expect(sent).toHaveLength(1); + const arrivalJobs = sent.filter( + ({ queue }) => queue === DATA_ARRIVAL_QUEUE, + ); + expect(arrivalJobs).toHaveLength(1); - for (const job of sent) { + // Snapshot only the spine jobs. Processing one appends downstream + // reaction-line work to `sent`; iterating that live, growing array would + // feed a different queue's payload back into this worker forever. + for (const job of arrivalJobs) { await runDataArrival(claimingPrisma(), job.payload); } expect(enqueueWorkoutInsight).toHaveBeenCalledTimes(1);