test(scripts): route docs i18n module changes

This commit is contained in:
Vincent Koc
2026-06-21 04:08:30 +02:00
parent c2de9d0822
commit cbbb466852
3 changed files with 36 additions and 0 deletions

View File

@@ -2677,6 +2677,13 @@ function resolveDocsI18nBehaviorTargets(changedPath) {
return ["test/scripts/docs-i18n-behavior.test.ts"];
}
function resolveDocsI18nGoTargets(changedPath) {
if (!/^scripts\/docs-i18n\/(?:go\.(?:mod|sum)|[^/]+\.go)$/u.test(changedPath)) {
return null;
}
return ["test/scripts/docs-i18n.test.ts"];
}
function resolveK8sManifestTargets(changedPath) {
if (!/^scripts\/k8s\/manifests\/[^/]+\.yaml$/u.test(changedPath)) {
return null;
@@ -2714,6 +2721,7 @@ function resolveToolingTestTargets(changedPath, cwd = process.cwd()) {
TOOLING_TEST_TARGETS.get(changedPath) ??
resolveUpgradeSurvivorConfigRecipeTargets(changedPath) ??
resolveDocsI18nBehaviorTargets(changedPath) ??
resolveDocsI18nGoTargets(changedPath) ??
resolveK8sManifestTargets(changedPath) ??
resolveParallelsToolingTestTargets(changedPath);
const conventionalTargets = resolveConventionalToolingTestTargets(changedPath, cwd);

View File

@@ -0,0 +1,15 @@
// Docs i18n tests cover the Go module backing docs translation.
import { spawnSync } from "node:child_process";
import { describe, expect, it } from "vitest";
describe("docs-i18n Go module", () => {
it("passes Go tests", () => {
const result = spawnSync("go", ["test", "./...", "-count=1"], {
cwd: "scripts/docs-i18n",
encoding: "utf8",
});
expect(result.error).toBeUndefined();
expect(result.status, result.stderr || result.stdout).toBe(0);
});
});

View File

@@ -1084,6 +1084,19 @@ describe("scripts/test-projects changed-target routing", () => {
}
});
it("keeps docs i18n Go module edits on Go module tests", () => {
for (const modulePath of [
"scripts/docs-i18n/main.go",
"scripts/docs-i18n/main_test.go",
"scripts/docs-i18n/go.mod",
]) {
expect(resolveChangedTestTargetPlan([modulePath]), modulePath).toEqual({
mode: "targets",
targets: ["test/scripts/docs-i18n.test.ts"],
});
}
});
it("keeps k8s manifest edits on manifest tests", () => {
expect(resolveChangedTestTargetPlan(["scripts/k8s/manifests/configmap.yaml"])).toEqual({
mode: "targets",