diff --git a/scripts/test-projects.test-support.mjs b/scripts/test-projects.test-support.mjs index f9a5d65f4da2..5527ec731961 100644 --- a/scripts/test-projects.test-support.mjs +++ b/scripts/test-projects.test-support.mjs @@ -1061,6 +1061,10 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([ ["scripts/run-node.mjs", ["src/infra/run-node.test.ts"]], ["scripts/committer", ["test/scripts/committer.test.ts"]], ["scripts/gh-read", ["test/scripts/gh-read.test.ts"]], + ["scripts/pr", ["test/scripts/pr-wrappers.test.ts"]], + ["scripts/pr-merge", ["test/scripts/pr-wrappers.test.ts"]], + ["scripts/pr-prepare", ["test/scripts/pr-wrappers.test.ts"]], + ["scripts/pr-review", ["test/scripts/pr-wrappers.test.ts"]], ["scripts/setup-auth-system.sh", ["test/scripts/test-projects.test.ts"]], ["scripts/ci-run-timings.mjs", ["test/scripts/ci-run-timings.test.ts"]], ["scripts/docker-e2e.mjs", ["test/scripts/docker-e2e-helper-cli.test.ts"]], @@ -1574,6 +1578,7 @@ const TOOLING_TEST_TARGETS = new Map([ "test/scripts/plugin-prerelease-test-plan.test.ts", ["test/scripts/plugin-prerelease-test-plan.test.ts"], ], + ["test/scripts/pr-wrappers.test.ts", ["test/scripts/pr-wrappers.test.ts"]], ["test/scripts/test-projects.test.ts", ["test/scripts/test-projects.test.ts"]], [ "test/scripts/vitest-local-scheduling.test.ts", diff --git a/test/scripts/pr-wrappers.test.ts b/test/scripts/pr-wrappers.test.ts new file mode 100644 index 000000000000..44b0104fea07 --- /dev/null +++ b/test/scripts/pr-wrappers.test.ts @@ -0,0 +1,52 @@ +// PR wrapper tests cover maintainer helper command delegation. +import { readFileSync } from "node:fs"; +import { describe, expect, it } from "vitest"; + +function readScript(path: string): string { + return readFileSync(path, "utf8"); +} + +describe("scripts/pr wrappers", () => { + it("keeps the main PR helper usage and command table aligned", () => { + const script = readScript("scripts/pr"); + + expect(script).toContain("export NO_COLOR=1"); + expect(script).toContain("unset COLORTERM"); + expect(script).toContain("scripts/pr review-init "); + expect(script).toContain("scripts/pr prepare-run "); + expect(script).toContain("scripts/pr merge-run "); + expect(script).toContain('review_init "$pr"'); + expect(script).toContain('prepare_run "$pr"'); + expect(script).toContain('merge_run "$pr"'); + }); + + it("keeps merge wrapper modes delegated to the main PR helper", () => { + const script = readScript("scripts/pr-merge"); + + expect(script).toContain("scripts/pr-merge "); + expect(script).toContain('exec "$base" merge-verify "$1"'); + expect(script).toContain('exec "$base" merge-verify "$pr"'); + expect(script).toContain('exec "$base" merge-run "$pr"'); + }); + + it("keeps prepare wrapper modes delegated to the main PR helper", () => { + const script = readScript("scripts/pr-prepare"); + + expect(script).toContain("scripts/pr-prepare "); + for (const mode of ["init", "validate-commit", "gates", "push", "run"]) { + expect(script).toContain(`${mode})`); + } + expect(script).toContain('exec "$base" prepare-init "$pr"'); + expect(script).toContain('exec "$base" prepare-validate-commit "$pr"'); + expect(script).toContain('exec "$base" prepare-gates "$pr"'); + expect(script).toContain('exec "$base" prepare-push "$pr"'); + expect(script).toContain('exec "$base" prepare-run "$pr"'); + }); + + it("keeps review wrapper delegated to review-init", () => { + const script = readScript("scripts/pr-review"); + + expect(script).toContain('base="$script_dir/pr"'); + expect(script).toContain('exec "$base" review-init "$@"'); + }); +}); diff --git a/test/scripts/test-projects.test.ts b/test/scripts/test-projects.test.ts index 5ef6cd20b98a..1501db5da1d4 100644 --- a/test/scripts/test-projects.test.ts +++ b/test/scripts/test-projects.test.ts @@ -1361,6 +1361,10 @@ describe("scripts/test-projects changed-target routing", () => { const expectedTargets = new Map([ ["scripts/committer", ["test/scripts/committer.test.ts"]], ["scripts/gh-read", ["test/scripts/gh-read.test.ts"]], + ["scripts/pr", ["test/scripts/pr-wrappers.test.ts"]], + ["scripts/pr-merge", ["test/scripts/pr-wrappers.test.ts"]], + ["scripts/pr-prepare", ["test/scripts/pr-wrappers.test.ts"]], + ["scripts/pr-review", ["test/scripts/pr-wrappers.test.ts"]], ]); for (const [source, targets] of expectedTargets) {