Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

test(docs): isolate README facts from CLI catalog imports

morluto767fe0f0ccba
diff --git a/scripts/lib/development-tests.mjs b/scripts/lib/development-tests.mjs
index 6aaf10768..ee256414c 100644
--- a/scripts/lib/development-tests.mjs
+++ b/scripts/lib/development-tests.mjs
@@ -43,6 +43,7 @@ const artifactConsumers = {
"tests/boundary/mcp/toolSchemaValidity.test.ts",
],
"artifacts:product-catalog": [
+ "tests/boundary/filesystem/documentationFacts.test.ts",
"tests/boundary/filesystem/productCatalog.test.ts",
],
"artifacts:managed-evidence": [
diff --git a/tests/boundary/filesystem/documentationFacts.test.ts b/tests/boundary/filesystem/documentationFacts.test.ts
new file mode 100644
index 000000000..64e19fe38
--- /dev/null
+++ b/tests/boundary/filesystem/documentationFacts.test.ts
@@ -0,0 +1,91 @@
+import { copyFile, mkdir, readFile, rm, writeFile } from "node:fs/promises";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+import { afterEach, describe, expect, it } from "vitest";
+
+import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
+
+import { documentationFactIssues } from "../../../scripts/lib/docs-facts.mjs";
+import type { ProductCatalog } from "../../../scripts/lib/product-catalog.mjs";
+
+const root = fileURLToPath(new URL("../../..", import.meta.url));
+const temporaryRoots: string[] = [];
+
+const README_FACT_FIXTURE_PATHS = [
+ "README.md",
+ "docs/readme/README_zh.md",
+ "docs/readme/README_ja.md",
+ "docs/readme/README_ko.md",
+ "docs/readme/README_ar.md",
+ "website/locales/languages.json",
+ "docs/installation.md",
+ "AGENTS.md",
+ ".github/pull_request_template.md",
+] as const;
+
+const README_LINK_DRIFT_MUTATIONS = [
+ [
+ "(../installation.md#supported-agents)",
+ "(../installation.md#missing-agents)",
+ ],
+ ["https://rea.tools/zh-CN/guides/", "https://rea.tools/zh-CN/missing/"],
+ ["https://rea.tools/zh-CN/guides/", "https://rea.tools/zh-TW/guides/"],
+ [
+ "https://rea.tools/zh-CN/guides/",
+ "https://rea.tools/zh-CN/guides/?other=1",
+ ],
+ [
+ 'src="../assets/rea-hopper-analysis.png"',
+ 'src="../assets/missing-hopper.png"',
+ ],
+ ['href="https://discord.gg/GkcryMnJDM"', 'href="https://discord.gg/missing"'],
+] as const;
+
+const seedReadmeFactFixture = async (directory: string) => {
+ for (const path of README_FACT_FIXTURE_PATHS) {
+ const destination = join(directory, path);
+ await mkdir(dirname(destination), { recursive: true });
+ await copyFile(join(root, path), destination);
+ }
+ await mkdir(join(directory, "skills/reverse-engineer-anything"), {
+ recursive: true,
+ });
+};
+
+afterEach(async () => {
+ await Promise.all(
+ temporaryRoots
+ .splice(0)
+ .map((path) => rm(path, { recursive: true, force: true })),
+ );
+});
+
+describe("translated README facts", () => {
+ it("keeps translated readmes linked to canonical setup and tool details", async () => {
+ const directory = await createTestTempDirectory("rea-readme-facts-");
+ temporaryRoots.push(directory);
+ await seedReadmeFactFixture(directory);
+ const translatedPath = join(directory, "docs/readme/README_zh.md");
+ const translated = await readFile(translatedPath, "utf8");
+ const catalog: ProductCatalog = JSON.parse(
+ await readFile(join(root, "docs/public/product-catalog.json"), "utf8"),
+ );
+ await expect(documentationFactIssues(directory, catalog)).resolves.toEqual(
+ [],
+ );
+ for (const [original, changed] of README_LINK_DRIFT_MUTATIONS) {
+ expect(translated).toContain(original);
+ await writeFile(
+ translatedPath,
+ translated.replace(original, changed),
+ "utf8",
+ );
+ await expect(
+ documentationFactIssues(directory, catalog),
+ ).resolves.toEqual([
+ "docs/readme/README_zh.md: documentation links differ from README.md",
+ ]);
+ }
+ });
+});
diff --git a/tests/boundary/filesystem/productCatalog.test.ts b/tests/boundary/filesystem/productCatalog.test.ts
index ecdf5e512..ade073ba8 100644
--- a/tests/boundary/filesystem/productCatalog.test.ts
+++ b/tests/boundary/filesystem/productCatalog.test.ts
@@ -1,5 +1,5 @@
-import { copyFile, mkdir, readFile, rm, writeFile } from "node:fs/promises";
-import { dirname, join } from "node:path";
+import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
+import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
@@ -40,54 +40,6 @@ import {
const root = fileURLToPath(new URL("../../..", import.meta.url));
const temporaryRoots: string[] = [];
-const README_FACT_FIXTURE_PATHS = [
- "README.md",
- "docs/readme/README_zh.md",
- "docs/readme/README_ja.md",
- "docs/readme/README_ko.md",
- "docs/readme/README_ar.md",
- "website/locales/languages.json",
- "docs/installation.md",
- "AGENTS.md",
- ".github/pull_request_template.md",
-] as const;
-
-const README_LINK_DRIFT_MUTATIONS = [
- [
- "(../installation.md#supported-agents)",
- "(../installation.md#missing-agents)",
- ],
- ["(../native-investigation.md)", "(../missing-investigation.md)"],
- [
- "https://rea.tools/zh-CN/showcase/dx-ball/",
- "https://rea.tools/zh-CN/missing/",
- ],
- [
- "https://rea.tools/zh-CN/showcase/dx-ball/",
- "https://rea.tools/zh-TW/showcase/dx-ball/",
- ],
- [
- "https://rea.tools/zh-CN/showcase/dx-ball/",
- "https://rea.tools/zh-CN/showcase/dx-ball/?other=1",
- ],
- [
- 'src="../assets/rea-hopper-analysis.png"',
- 'src="../assets/missing-hopper.png"',
- ],
- ['href="https://discord.gg/GkcryMnJDM"', 'href="https://discord.gg/missing"'],
-] as const;
-
-const seedReadmeFactFixture = async (directory: string) => {
- for (const path of README_FACT_FIXTURE_PATHS) {
- const destination = join(directory, path);
- await mkdir(dirname(destination), { recursive: true });
- await copyFile(join(root, path), destination);
- }
- await mkdir(join(directory, "skills/reverse-engineer-anything"), {
- recursive: true,
- });
-};
-
afterEach(async () => {
await Promise.all(
temporaryRoots
@@ -234,30 +186,6 @@ describe("canonical product catalog drift", () => {
expect(issues).not.toContain("README.md: missing Future Client");
});
- it("keeps translated readmes linked to canonical setup and tool details", async () => {
- const directory = await createTestTempDirectory("rea-readme-facts-");
- temporaryRoots.push(directory);
- await seedReadmeFactFixture(directory);
- const translatedPath = join(directory, "docs/readme/README_zh.md");
- const translated = await readFile(translatedPath, "utf8");
- const catalog = await createProductCatalog(root);
- await expect(documentationFactIssues(directory, catalog)).resolves.toEqual(
- [],
- );
- for (const [original, changed] of README_LINK_DRIFT_MUTATIONS) {
- expect(translated).toContain(original);
- await writeFile(
- translatedPath,
- translated.replace(original, changed),
- "utf8",
- );
- await expect(
- documentationFactIssues(directory, catalog),
- ).resolves.toEqual([
- "docs/readme/README_zh.md: documentation links differ from README.md",
- ]);
- }
- });
it("fails check mode without rewriting a stale generated artifact", async () => {
const directory = await createTestTempDirectory("rea-generated-check-");
temporaryRoots.push(directory);