From 90523d6c18f9e2b116a8a382655d00d997d32d9e Mon Sep 17 00:00:00 2001 From: galuis116 Date: Fri, 24 Jul 2026 09:53:52 -0300 Subject: [PATCH] test(signals): cover decidePublicSurface's oss_maintainer not_checked label fallback (#8324) decidePublicSurface in src/signals/settings-preview.ts is the single source of truth for the GitHub App's public surface, shared by the live webhook processor and the maintainer dry-run preview. Its willLabel has an inline fallback disjunct -- oss_maintainer + not_checked + autoLabelEnabled + (comment_and_label | label_only) -- that governs whether a PR is labelled before the official Gittensor miner lookup completes. It had no coverage (grep not_checked in the test file returned nothing). Because shouldApplyPrLabel returns false for an oss_maintainer repo whose miner status is not "confirmed", this inline condition is the only thing that can set willLabel for a not_checked PR, so these tests isolate it exactly. Adds a describe covering the four arms of that disjunct: comment_and_label and label_only surfaces label; comment_only does not (the disjunct's own publicSurface check); and autoLabelEnabled=false does not. Test-only, no production change. --- test/unit/settings-preview.test.ts | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/unit/settings-preview.test.ts b/test/unit/settings-preview.test.ts index 2e1648aee..7014d0a3d 100644 --- a/test/unit/settings-preview.test.ts +++ b/test/unit/settings-preview.test.ts @@ -134,6 +134,41 @@ describe("decidePublicSurface", () => { expect(decision).toMatchObject({ skipped: false, willComment: false, willLabel: false, willCheckRun: false, actions: ["none"] }); expect(decision.summary).toMatch(/no surface action is enabled/); }); + + // #8324: the willLabel oss_maintainer + not_checked fallback disjunct. shouldApplyPrLabel returns false for + // an oss_maintainer repo whose miner status isn't "confirmed", so this inline condition is the only thing + // that can set willLabel for a not_checked PR -- it governs whether the live webhook processor labels a PR + // before the official Gittensor miner lookup completes. + describe("oss_maintainer + not_checked auto-label fallback", () => { + const decide = (over: Partial) => + decidePublicSurface({ + settings: settings({ publicAudienceMode: "oss_maintainer", autoLabelEnabled: true, ...over }), + authorLogin: "contributor", + authorType: "User", + authorAssociation: "NONE", + minerStatus: "not_checked", + }); + + it("labels a comment_and_label surface (shouldApplyPrLabel is false here, so the fallback is what fires)", () => { + const decision = decide({ publicSurface: "comment_and_label" }); + expect(decision.willLabel).toBe(true); + expect(decision.actions).toContain("label"); + }); + + it("labels a label_only surface", () => { + expect(decide({ publicSurface: "label_only" }).willLabel).toBe(true); + }); + + it("does NOT label a comment_only surface (the disjunct's own publicSurface check excludes it)", () => { + const decision = decide({ publicSurface: "comment_only" }); + expect(decision.willLabel).toBe(false); + expect(decision.actions).not.toContain("label"); + }); + + it("does NOT label when autoLabelEnabled is false, even on a labelling surface", () => { + expect(decide({ publicSurface: "comment_and_label", autoLabelEnabled: false }).willLabel).toBe(false); + }); + }); }); describe("buildRepoSettingsPreview", () => {