test(scripts): route pr wrapper scripts

This commit is contained in:
Vincent Koc
2026-06-21 05:24:31 +02:00
parent 862ef1cec1
commit dec76bb5eb
3 changed files with 61 additions and 0 deletions

View File

@@ -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",

View File

@@ -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 <PR>");
expect(script).toContain("scripts/pr prepare-run <PR>");
expect(script).toContain("scripts/pr merge-run <PR>");
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 <PR>");
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 <init|validate-commit|gates|push|run> <PR>");
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 "$@"');
});
});

View File

@@ -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) {