diff --git a/tests/boundary/filesystem/ciPrHealth.test.ts b/tests/boundary/filesystem/ciPrHealth.test.ts index b36161525e3..15acb53a555 100644 --- a/tests/boundary/filesystem/ciPrHealth.test.ts +++ b/tests/boundary/filesystem/ciPrHealth.test.ts @@ -139,6 +139,12 @@ it("requires complete inventories, known mergeability, and immutable head identi it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous branch identities", () => { const pull = validPull(); + const matchSingleHead = (candidate: PrCiWorkflowRun) => + matchRunToPullRequest({ + run: candidate, + pull, + identityCounts: new Map([["73\u0000feature", 1]]), + }); const associatedMergeRun = run({ head_sha: mergeSha, pull_requests: [ @@ -148,23 +154,18 @@ it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous bran }, ], }); + expect(matchSingleHead(associatedMergeRun)).toEqual({ + kind: "match", + basis: "event_pr_number_and_head_sha", + }); expect( - matchRunToPullRequest({ - run: associatedMergeRun, - pull, - identityCounts: new Map([["73\u0000feature", 1]]), - }), - ).toEqual({ kind: "match", basis: "event_pr_number_and_head_sha" }); - expect( - matchRunToPullRequest({ - run: run({ + matchSingleHead( + run({ pull_requests: [ { number: pull.number!, head: { sha: "c".repeat(40) } }, ], }), - pull, - identityCounts: new Map([["73\u0000feature", 1]]), - }).kind, + ).kind, ).toBe("none"); const branchRun = run({ pull_requests: [] }); @@ -176,31 +177,19 @@ it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous bran inventoryComplete: false, }).kind, ).toBe("ambiguous"); - expect( - matchRunToPullRequest({ - run: branchRun, - pull, - identityCounts: new Map([["73\u0000feature", 1]]), - }), - ).toEqual({ + expect(matchSingleHead(branchRun)).toEqual({ kind: "match", basis: "event_unique_head_ref_and_repository_id", }); expect( - matchRunToPullRequest({ - run: run({ head_sha: mergeSha, pull_requests: [] }), - pull, - identityCounts: new Map([["73\u0000feature", 1]]), - }).kind, + matchSingleHead(run({ head_sha: mergeSha, pull_requests: [] })).kind, ).toBe("none"); expect( - matchRunToPullRequest({ - run: run({ + matchSingleHead( + run({ pull_requests: [{ number: pull.number!, head: { sha: headSha } }], }), - pull, - identityCounts: new Map([["73\u0000feature", 1]]), - }).kind, + ).kind, ).toBe("ambiguous"); expect( matchRunToPullRequest({ @@ -209,13 +198,9 @@ it("accepts event PR/head evidence for merge-SHA runs and refuses ambiguous bran identityCounts: new Map([["73\u0000feature", 2]]), }).kind, ).toBe("ambiguous"); - expect( - matchRunToPullRequest({ - run: run({ event: "workflow_dispatch" }), - pull, - identityCounts: new Map([["73\u0000feature", 1]]), - }).kind, - ).toBe("none"); + expect(matchSingleHead(run({ event: "workflow_dispatch" })).kind).toBe( + "none", + ); }); it("scans target-branch PRs through public gh GET requests and writes JSON and Markdown", async () => {