diff --git a/.github/scripts/pr-hygiene.cjs b/.github/scripts/pr-hygiene.cjs index a910be674..554d4851e 100644 --- a/.github/scripts/pr-hygiene.cjs +++ b/.github/scripts/pr-hygiene.cjs @@ -143,8 +143,10 @@ function assessHygiene({ files = [], labels = [] }) { const behaviorChanged = allPaths.some( (path) => isBehaviorPath(path) && !commentOnlyPaths.has(path), ); - // Deleted tests add no coverage and must not satisfy the regression gate. - const testsChanged = allPaths.some( + // Deleted or renamed-away tests add no coverage and must not satisfy the + // regression gate. Previous paths still classify behavior and generated + // files above, but only a current test path counts as regression coverage. + const testsChanged = filenames.some( (path) => isTestPath(path) && !removedFilenames.has(path), ); diff --git a/.github/scripts/pr-hygiene.test.cjs b/.github/scripts/pr-hygiene.test.cjs index 16f5f79a3..1a2565a7e 100644 --- a/.github/scripts/pr-hygiene.test.cjs +++ b/.github/scripts/pr-hygiene.test.cjs @@ -186,6 +186,19 @@ describe("assessHygiene", () => { assert.equal(failures[0].code, "missing_regression_test"); }); + it("does not count renamed-away tests as regression coverage", () => { + const failures = assessHygiene({ files: [ + { filename: "src/router.ts", patch: "+change" }, + { + filename: "docs/router.md", + previous_filename: "tests/router.test.ts", + status: "renamed", + patch: "", + }, + ] }); + assert.equal(failures[0].code, "missing_regression_test"); + }); + it("allows maintainer-approved narrow exceptions", () => { const failures = assessHygiene({ files: [