Files
OmniRoute/tests/unit/cli-catalog-schema.test.ts
diegosouzapw 193bf1a766 feat(cli-tools): extend catalog with category/vendor/acpSpawnable/baseUrlSupport + new entries (plan 14 F1)
- Add CliCatalogEntrySchema (Zod) + CliCatalogEntry type + CliCatalogSchema in src/shared/schemas/cliCatalog.ts
- Add ToolBatchStatus + ToolBatchStatusMap interfaces in src/shared/types/cliBatchStatus.ts
- Re-export cliBatchStatus from src/shared/types/index.ts
- Extend all CLI_TOOLS entries with 4 new fields: category, vendor, acpSpawnable, baseUrlSupport
- Add 13 new entries: roo, jcode, deepseek-tui, smelt, pi (code), aider, forge,
  gemini-cli, cursor-cli (code), goose, interpreter, warp, agent-deck (agent)
- Remove windsurf and amp (MITM backlog plan 11, D17)
- Result: 19 visible code entries + 6 agent entries (D15 cardinality)
- Add 5 new unit tests: cli-catalog-schema, cli-catalog-counts, cli-catalog-newentries,
  cli-catalog-removed, cli-catalog-acpspawnable
- Update existing tests to align with removed entries
2026-05-27 19:50:38 -03:00

88 lines
2.9 KiB
TypeScript

/**
* F1: cli-catalog-schema.test.ts
* Round-trip each CLI_TOOLS entry through CliCatalogEntrySchema;
* verify ZodError on invalid payloads.
*/
import test from "node:test";
import assert from "node:assert/strict";
import { z } from "zod";
const { CLI_TOOLS } = await import("../../src/shared/constants/cliTools.ts");
const { CliCatalogEntrySchema, CliCatalogSchema } = await import(
"../../src/shared/schemas/cliCatalog.ts"
);
test("Every CLI_TOOLS entry passes CliCatalogEntrySchema.parse() without error", () => {
for (const [key, tool] of Object.entries(CLI_TOOLS)) {
const result = CliCatalogEntrySchema.safeParse(tool);
assert.equal(
result.success,
true,
`Entry '${key}' failed schema validation: ${!result.success ? JSON.stringify(result.error.issues) : ""}`
);
}
});
test("CliCatalogSchema.parse() accepts the full CLI_TOOLS record", () => {
const result = CliCatalogSchema.safeParse(CLI_TOOLS);
assert.equal(
result.success,
true,
result.success ? "" : `CliCatalogSchema failed: ${JSON.stringify(result.error.issues)}`
);
});
test("CliCatalogEntrySchema throws ZodError for invalid category value", () => {
const base = { ...CLI_TOOLS["claude"] };
// @ts-expect-error — intentional invalid value for testing
const invalid = { ...base, category: "invalid" };
assert.throws(
() => CliCatalogEntrySchema.parse(invalid),
(err) => err instanceof z.ZodError
);
});
test("CliCatalogEntrySchema throws ZodError for invalid color (not #RRGGBB)", () => {
const base = { ...CLI_TOOLS["codex"] };
const invalid = { ...base, color: "xyz" };
assert.throws(
() => CliCatalogEntrySchema.parse(invalid),
(err) => err instanceof z.ZodError
);
});
test("CliCatalogEntrySchema throws ZodError for invalid baseUrlSupport value", () => {
const base = { ...CLI_TOOLS["cline"] };
// @ts-expect-error — intentional invalid value for testing
const invalid = { ...base, baseUrlSupport: "maybe" };
assert.throws(
() => CliCatalogEntrySchema.parse(invalid),
(err) => err instanceof z.ZodError
);
});
test("CliCatalogEntrySchema throws ZodError when required string fields are empty", () => {
const base = { ...CLI_TOOLS["qwen"] };
const invalid = { ...base, vendor: "" };
assert.throws(
() => CliCatalogEntrySchema.parse(invalid),
(err) => err instanceof z.ZodError
);
});
test("CliCatalogEntrySchema throws ZodError for invalid configType value", () => {
const base = { ...CLI_TOOLS["custom"] };
// @ts-expect-error — intentional invalid value for testing
const invalid = { ...base, configType: "unknown-type" };
assert.throws(
() => CliCatalogEntrySchema.parse(invalid),
(err) => err instanceof z.ZodError
);
});
test("Optional fields absent from entry still parse successfully", () => {
// 'codex' has no guideSteps, no envVars, no notes — minimal entry
const result = CliCatalogEntrySchema.safeParse(CLI_TOOLS["codex"]);
assert.equal(result.success, true);
});