From 9f8657cdfeb85f384ea126e3ef6b034d3e61e240 Mon Sep 17 00:00:00 2001 From: jaytbarimbao-collab <300663773+jaytbarimbao-collab@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:08:26 -0400 Subject: [PATCH] test(selfhost): cover jobCoalesceKey missing-field fallbacks for 6 job types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #5850. jobCoalesceKey's '?? ""' arms — taken when a payload omits an optional field so the job still coalesces to a stable key instead of null — were untested for the backfill/refresh/rollup job types. Adds a case asserting the exact fallback key for backfill-registered-repos, backfill-repo-segment, backfill-pr-details, generate-review-recap, refresh-contributor-activity, and rollup-product-usage when their optional fields are absent. --- test/unit/selfhost-queue-common.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/unit/selfhost-queue-common.test.ts b/test/unit/selfhost-queue-common.test.ts index 5a67e7ffd1..1948e42a17 100644 --- a/test/unit/selfhost-queue-common.test.ts +++ b/test/unit/selfhost-queue-common.test.ts @@ -929,6 +929,18 @@ describe("self-host queue common helpers", () => { parse.mockRestore(); }); + it("uses each job type's missing-field fallback tokens when optional fields are absent (#5850)", () => { + // A payload carrying only `type` (no repo/mode/segment/cursor/login/day) must coalesce to the type's + // literal fallback key rather than null-ing or duplicating — the normalizers return null on a missing + // field, so the `?? ""` arm is taken. boolFlag(undefined) === "0". + expect(jobCoalesceKey(payload({ type: "backfill-registered-repos" }))).toBe("backfill-registered-repos:all:default:0"); + expect(jobCoalesceKey(payload({ type: "backfill-repo-segment" }))).toBe("backfill-repo-segment:unknown:unknown:default:0:start"); + expect(jobCoalesceKey(payload({ type: "backfill-pr-details" }))).toBe("backfill-pr-details:unknown:default:start"); + expect(jobCoalesceKey(payload({ type: "generate-review-recap" }))).toBe("generate-review-recap:all"); + expect(jobCoalesceKey(payload({ type: "refresh-contributor-activity" }))).toBe("refresh-contributor-activity:unknown:all"); + expect(jobCoalesceKey(payload({ type: "rollup-product-usage" }))).toBe("rollup-product-usage:latest:default"); + }); + it("coalesces CI-completion webhooks with sorted pull numbers", () => { expect(jobCoalesceKey(payload({ type: "agent-regate-pr", repoFullName: "JSONbored/Gittensory", prNumber: 7 }))).toBe("agent-regate-pr:jsonbored/gittensory#7"); expect(jobCoalesceKey(payload({ type: "agent-regate-pr", repoFullName: "JSONbored/Gittensory" }))).toBeNull();