From e91ca8df8608be4af4c3975f1d82bc9ecbad6e02 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 05:49:46 +0200 Subject: [PATCH] test(scripts): route docs spellcheck config --- scripts/test-projects.test-support.mjs | 4 +++ test/scripts/docs-spellcheck.test.ts | 34 ++++++++++++++++++++++++++ test/scripts/test-projects.test.ts | 16 ++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 test/scripts/docs-spellcheck.test.ts diff --git a/scripts/test-projects.test-support.mjs b/scripts/test-projects.test-support.mjs index ce476ae6f3d5..f5f93379b9d8 100644 --- a/scripts/test-projects.test-support.mjs +++ b/scripts/test-projects.test-support.mjs @@ -1060,6 +1060,9 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([ ["scripts/run-with-env.mjs", ["test/scripts/run-with-env.test.ts"]], ["scripts/run-node.mjs", ["src/infra/run-node.test.ts"]], ["scripts/auth-monitor.sh", ["test/scripts/auth-monitor.test.ts"]], + ["scripts/codespell-dictionary.txt", ["test/scripts/docs-spellcheck.test.ts"]], + ["scripts/codespell-ignore.txt", ["test/scripts/docs-spellcheck.test.ts"]], + ["scripts/docs-spellcheck.sh", ["test/scripts/docs-spellcheck.test.ts"]], ["scripts/mobile-reauth.sh", ["test/scripts/auth-monitor.test.ts"]], ["scripts/committer", ["test/scripts/committer.test.ts"]], ["scripts/gh-read", ["test/scripts/gh-read.test.ts"]], @@ -1565,6 +1568,7 @@ const TOOLING_TEST_TARGETS = new Map([ ["test/scripts/ci-docker-pull-retry.test.ts", ["test/scripts/ci-docker-pull-retry.test.ts"]], ["test/scripts/control-ui-i18n.test.ts", ["test/scripts/control-ui-i18n.test.ts"]], ["test/scripts/docker-build-helper.test.ts", ["test/scripts/docker-build-helper.test.ts"]], + ["test/scripts/docs-spellcheck.test.ts", ["test/scripts/docs-spellcheck.test.ts"]], ["test/scripts/docker-e2e-helper-cli.test.ts", ["test/scripts/docker-e2e-helper-cli.test.ts"]], ["test/scripts/kova-ci-summary.test.ts", ["test/scripts/kova-ci-summary.test.ts"]], ["test/scripts/live-docker-stage.test.ts", ["test/scripts/live-docker-stage.test.ts"]], diff --git a/test/scripts/docs-spellcheck.test.ts b/test/scripts/docs-spellcheck.test.ts new file mode 100644 index 000000000000..6c65f79e7dcd --- /dev/null +++ b/test/scripts/docs-spellcheck.test.ts @@ -0,0 +1,34 @@ +// Docs spellcheck tests cover codespell wrapper configuration. +import { readFileSync } from "node:fs"; +import { describe, expect, it } from "vitest"; + +const SCRIPT_PATH = "scripts/docs-spellcheck.sh"; +const DICTIONARY_PATH = "scripts/codespell-dictionary.txt"; +const IGNORE_PATH = "scripts/codespell-ignore.txt"; + +function nonEmptyLines(path: string): string[] { + return readFileSync(path, "utf8").split("\n").filter(Boolean); +} + +describe("scripts/docs-spellcheck.sh", () => { + it("uses the repository dictionary and ignore files", () => { + const script = readFileSync(SCRIPT_PATH, "utf8"); + + expect(script).toContain("-D"); + expect(script).toContain("-"); + expect(script).toContain("-D\n scripts/codespell-dictionary.txt"); + expect(script).toContain("-I\n scripts/codespell-ignore.txt"); + }); + + it("keeps codespell config entries non-empty and unique", () => { + for (const path of [DICTIONARY_PATH, IGNORE_PATH]) { + const lines = nonEmptyLines(path); + + expect(lines.length).toBeGreaterThan(0); + expect(new Set(lines).size).toBe(lines.length); + for (const line of lines) { + expect(line).toBe(line.trim()); + } + } + }); +}); diff --git a/test/scripts/test-projects.test.ts b/test/scripts/test-projects.test.ts index e0fcb302656a..7d4a32992221 100644 --- a/test/scripts/test-projects.test.ts +++ b/test/scripts/test-projects.test.ts @@ -1395,6 +1395,22 @@ describe("scripts/test-projects changed-target routing", () => { } }); + it("keeps docs spellcheck config edits on owner tests", () => { + const expectedTargets = new Map([ + ["scripts/codespell-dictionary.txt", ["test/scripts/docs-spellcheck.test.ts"]], + ["scripts/codespell-ignore.txt", ["test/scripts/docs-spellcheck.test.ts"]], + ["scripts/docs-spellcheck.sh", ["test/scripts/docs-spellcheck.test.ts"]], + ["test/scripts/docs-spellcheck.test.ts", ["test/scripts/docs-spellcheck.test.ts"]], + ]); + + for (const [source, targets] of expectedTargets) { + expect(resolveChangedTestTargetPlan([source]), source).toEqual({ + mode: "targets", + targets, + }); + } + }); + it("keeps shared script library edits on owner tests", () => { const expectedTargets = new Map([ [