Files
openclaw/src/docs/config-path-docs.test.ts
Peter Steinberger 1b313dc4d4 chore(tooling): enforce indexed access in core tests (#105375)
* test(tooling): enforce indexed access in core tests

* test(tui): constrain theme environment overrides

* test(doctor): enforce indexed access in migration fixtures
2026-07-12 14:29:52 +01:00

43 lines
1.3 KiB
TypeScript

// Config path docs tests validate documented config path references.
import fs from "node:fs/promises";
import path from "node:path";
import { expectDefined } from "@openclaw/normalization-core";
import { describe, expect, it } from "vitest";
const DOCS_WITH_CONFIG_PATH_EXAMPLES = [
"docs/cli/config.md",
"docs/tools/exec.md",
"docs/nodes/index.md",
];
function findUnquotedBracketPathExamples(markdown: string, docPath: string): string[] {
const failures: string[] = [];
for (const [index, line] of markdown.split(/\r?\n/).entries()) {
const match = line.match(/\bopenclaw\s+config\s+(?:get|set|unset)\s+(\S+)/);
if (!match) {
continue;
}
const pathArg = expectDefined(match[1], "match[1] test invariant");
if (pathArg.includes("[") && !pathArg.startsWith("'") && !pathArg.startsWith('"')) {
failures.push(`${docPath}:${index + 1}: ${pathArg}`);
}
}
return failures;
}
describe("config path docs", () => {
it("quotes bracket-notation config paths in shell examples", async () => {
const failures: string[] = [];
for (const docPath of DOCS_WITH_CONFIG_PATH_EXAMPLES) {
const markdown = await fs.readFile(path.join(process.cwd(), docPath), "utf8");
failures.push(...findUnquotedBracketPathExamples(markdown, docPath));
}
expect(failures).toEqual([]);
});
});