Files
OmniRoute/tests/unit/cli-catalog-counts.test.ts
Xiangzhe c2df757610 fix(tests): drain base-red cluster from 2026-08-23 merges (#9985)
Drain the unit-shard reds the 2026-08-23 merge wave left on
release/v3.8.50, each discriminated as stale-test (contract moved
intentionally, test aligned) vs real bug (fixed in code/messages):

1. check-deps 6A.8 allowlist — #11224 added @testing-library/dom and
   @testing-library/user-event to package.json without the gate
   allowlist. Both are legitimate: @testing-library/dom is a required
   peer of @testing-library/react v16, and user-event is the official
   companion for UI tests. Fix: allowlist entries with a justification
   note referencing #11224/#9985.

2. search-route 400-vs-fallback — #11097 intentionally changed the
   zero-credential /v1/search contract: instead of returning 400 it
   promotes the fallback-only duckduckgo-free provider so out-of-the-box
   search works. The test pinned the OLD 400 contract. Fix (contract
   alignment): the test now pins the new fallback contract — 200,
   provider duckduckgo-free, DuckDuckGo lite endpoint called, results
   parsed from lite HTML.

3. codex catalog token limits (4 named reds + 2 sibling sweeps) —
   #11179 raised GPT_5_6_CODEX_CAPABILITIES from the 272K pricing tier
   to the real usable 872K window (live evidence: 390K served past
   272K with HTTP 200) and updated codex-gpt56-catalog.test.ts but
   missed the sibling pins. Stale tests aligned: models-catalog-combo-
   metadata (max_input_tokens now clamps to min(872000, 500000 override)
   = 500000), vscode-token-routes x3 (872000), and two more found in the
   sibling sweep: vscode-token-routes-gpt56 and provider-models-route-
   codex (conservative merge semantics unchanged: pinned 872000 < live
   999999 still wins).

4. CLI catalog counts (3 reds) — #11166 added prime-agent (agent
   category) without the cardinality pins: EXPECTED_AGENT_COUNT 8->9,
   total 34->35, D15 agent list + prime-agent, cli-tools-schema id list.
   Also added the missing English/Vietnamese cliTools descriptions for
   prime-agent (cli-catalog-display-contract) and corrected the stale
   CLI-TOOLS.md agent count (8->9).

5. setup-qwen container guard — since #10057 the container guard exits 2
   on ephemeral runtimes; the two tests exercising the merge/write path
   were environment-sensitive (red on container devboxes). Fix: pass
   allowContainerWrite so the tests are hermetic everywhere; the guard
   keeps its own dedicated coverage.

6. i18n health verdict namespace (real bug, fixed in messages) — #11224
   added the verdict/diagnostics strings to the `sidebar` namespace but
   health/page.tsx reads them via useTranslations("health"), so the page
   rendered raw keys in every locale and the "direct translation calls
   have English messages" gate went red. Fix: keys moved sidebar->health
   in en.json + vi.json (the only locales that had them), plus
   health.healthSubtitle added. The sidebar never referenced them
   (verified: no usage), and sidebar.healthSubtitle (its real sidebar
   key) is untouched.

7. i18n pt-BR drift (22 keys) — the 08-23 wave (#11224/#11228/#11215/
   #11204/#11195) added English keys never translated: common.batch*,
   endpoint.*, cliCommon.concept.acp.warning, resilienceConnections.*,
   plus the moved health.* keys and the prime-agent cliTools
   description. Fix: pt-BR translations added — 0 missing keys vs en;
   vi strict parity re-verified (0 missing, 0 extra).

Validation: every touched test file RED->GREEN individually
(node --import tsx/esm --test), typecheck:core clean, docs-counts-sync
soft-pass, cli-i18n gate PASS, 8/8 unit shards re-run on the branch.

Refs #9985
2026-08-23 14:45:05 -03:00

122 lines
3.7 KiB
TypeScript

/**
* F1: cli-catalog-counts.test.ts
* Assert catalog cardinality per plan 14 D15 / §3.1-§3.2.
*/
import test from "node:test";
import assert from "node:assert/strict";
const { CLI_TOOLS } = await import("../../src/shared/constants/cliTools.ts");
const { EXPECTED_CODE_COUNT, EXPECTED_AGENT_COUNT } =
await import("../../src/shared/schemas/cliCatalog.ts");
const all = Object.values(CLI_TOOLS);
const codeAll = all.filter((t) => t.category === "code");
const agentAll = all.filter((t) => t.category === "agent");
const codeVisible = codeAll.filter((t) => t.baseUrlSupport !== "none");
test(`CLI_TOOLS has exactly ${EXPECTED_CODE_COUNT} code entries with baseUrlSupport !== 'none'`, () => {
assert.equal(
codeVisible.length,
EXPECTED_CODE_COUNT,
`Expected ${EXPECTED_CODE_COUNT} visible code entries, got ${codeVisible.length}: ${codeVisible.map((t) => t.id).join(", ")}`
);
});
test(`CLI_TOOLS has exactly ${EXPECTED_AGENT_COUNT} agent entries`, () => {
assert.equal(
agentAll.length,
EXPECTED_AGENT_COUNT,
`Expected ${EXPECTED_AGENT_COUNT} agent entries, got ${agentAll.length}: ${agentAll.map((t) => t.id).join(", ")}`
);
});
test("CLI_TOOLS total code entries (including none) equals 26 (21 visible + 5 none)", () => {
// code-none entries: antigravity, kiro, cursor (app), hermes, and zcode.
const codeNone = codeAll.filter((t) => t.baseUrlSupport === "none");
assert.equal(
codeNone.length,
5,
`Expected 5 code entries with baseUrlSupport='none', got ${codeNone.length}: ${codeNone.map((t) => t.id).join(", ")}`
);
assert.equal(codeAll.length, 26, `Expected 26 total code entries, got ${codeAll.length}`);
});
test("CLI_TOOLS total (code + agent) = 35", () => {
assert.equal(all.length, 35, `Expected 35 total entries, got ${all.length}`);
});
test("All code-none entries have configType mitm OR are legacy excluded entries", () => {
const codeNone = codeAll.filter((t) => t.baseUrlSupport === "none");
const allowedIds = new Set(["antigravity", "kiro", "cursor", "hermes", "zcode"]);
for (const entry of codeNone) {
assert.ok(
allowedIds.has(entry.id),
`Unexpected code entry with baseUrlSupport='none': ${entry.id}`
);
}
});
test("All agent entries have baseUrlSupport 'full' or 'partial' (no agent is 'none')", () => {
for (const entry of agentAll) {
assert.notEqual(
entry.baseUrlSupport,
"none",
`Agent entry '${entry.id}' has unexpected baseUrlSupport='none'`
);
}
});
test("The 21 visible code entries include Qwen Code's rebuilt integration", () => {
const d15List = new Set([
"claude",
"codex",
"cline",
"kilo",
"roo",
"continue",
"aider",
"forge",
"jcode",
"deepseek-tui",
"codewhale",
"opencode",
"droid",
"copilot",
"cursor-cli",
"smelt",
"pi",
"custom",
"crush",
"grok-build",
"qwen",
]);
const visibleIds = new Set(codeVisible.map((t) => t.id));
for (const id of d15List) {
assert.ok(visibleIds.has(id), `D15 entry '${id}' not found in visible code list`);
}
for (const id of visibleIds) {
assert.ok(d15List.has(id), `Visible code entry '${id}' not in D15 list`);
}
});
test("The 9 agent entries match D15 list exactly (+ omp + letta #6318, + prime-agent #11166)", () => {
const d15Agents = new Set([
"hermes-agent",
"openclaw",
"goose",
"interpreter",
"warp",
"agent-deck",
"omp",
"letta",
"prime-agent",
]);
const agentIds = new Set(agentAll.map((t) => t.id));
for (const id of d15Agents) {
assert.ok(agentIds.has(id), `D15 agent '${id}' not found in agent entries`);
}
for (const id of agentIds) {
assert.ok(d15Agents.has(id), `Agent entry '${id}' not in D15 agent list`);
}
});