From e31514a6e36384b2f122d42026c7a1ca32afc6aa Mon Sep 17 00:00:00 2001 From: Jeff <158072326+jeffrey701@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:18:36 +0200 Subject: [PATCH] test(scoring): cover pending-pr helpers' ghost-login exclusion and case-insensitive matching --- test/unit/pending-pr-scenarios.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit/pending-pr-scenarios.test.ts b/test/unit/pending-pr-scenarios.test.ts index 7c0f16da0b..22bef48435 100644 --- a/test/unit/pending-pr-scenarios.test.ts +++ b/test/unit/pending-pr-scenarios.test.ts @@ -461,4 +461,22 @@ describe("pending PR scenario detection", () => { expect(records.pullRequestChecks).toHaveLength(0); vi.restoreAllMocks(); }); + + // #8329: exercise both branches of sameLogin's `value &&` short-circuit and the case-insensitive matching of + // sameRepoFullName/sameLogin — a ghost/deleted account (null/undefined authorLogin) must be excluded, while a + // repoFullName or login that differs only in letter case must still match. + it("excludes null/undefined authorLogin and matches case-insensitively on repo and login", async () => { + const env = {} as Env; + vi.spyOn(repositories, "listPullRequestReviews").mockImplementation(async (_env, _repo, pullNumber) => [approvedReview(pullNumber)]); + vi.spyOn(repositories, "listCheckSummaries").mockResolvedValue([]); + const records = await loadContributorRepoOpenPrSignalRecords(env, "entrius/allways-ui", "miner-a", [ + pr({ number: 80, authorLogin: null }), // ghost account → sameLogin short-circuits to excluded + pr({ number: 81, authorLogin: undefined }), // deleted account → excluded + pr({ number: 82, repoFullName: "Entrius/Allways-UI" }), // repo differs only in case → still matches + pr({ number: 83, authorLogin: "Miner-A" }), // login differs only in case → still matches + ]); + // Only the two case-differing (but genuinely matching) PRs are counted; both ghost-account PRs are excluded. + expect(records.pullRequestReviews.map((review) => review.pullNumber).sort((a, b) => a - b)).toEqual([82, 83]); + vi.restoreAllMocks(); + }); });