Files
OmniRoute/tests/unit/cli-expanded-commands.test.ts
diegosouzapw fe6cffb54b feat(cli): fase 8.5/8.7 — completion dinâmico e expansão de comandos
- 8.5: completion reescrito com subcomandos install/refresh e scripts zsh/bash/fish dinâmicos
       com cache TTL 1h em ~/.omniroute/completion-cache.json
- 8.7: logs novas flags (--request-id --api-key --combo --status --duration-min/max --export)
- 8.7: health.watch (live dashboard) + health.components + --alerts-only
- 8.7: update --apply (npm install -g) + --check (exit 1 se outdated) + --changelog
- 8.7: keys regenerate/revoke/reveal/usage (gestão de management keys)
- en.json/pt-BR.json: chaves completion e logs adicionadas
2026-05-15 03:24:50 -03:00

50 lines
2.0 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
test("logs.mjs pode ser importado com novas flags", async () => {
const mod = await import("../../bin/cli/commands/logs.mjs");
assert.equal(typeof mod.registerLogs, "function");
assert.equal(typeof mod.runLogsCommand, "function");
});
test("health.mjs exporta runHealthComponentsCommand", async () => {
const mod = await import("../../bin/cli/commands/health.mjs");
assert.equal(typeof mod.registerHealth, "function");
assert.equal(typeof mod.runHealthCommand, "function");
assert.equal(typeof mod.runHealthComponentsCommand, "function");
});
test("update.mjs exporta runUpdateCommand", async () => {
const mod = await import("../../bin/cli/commands/update.mjs");
assert.equal(typeof mod.registerUpdate, "function");
assert.equal(typeof mod.runUpdateCommand, "function");
});
test("keys.mjs exporta novos comandos", async () => {
const mod = await import("../../bin/cli/commands/keys.mjs");
assert.equal(typeof mod.registerKeys, "function");
assert.equal(typeof mod.runKeysRegenerateCommand, "function");
assert.equal(typeof mod.runKeysRevokeCommand, "function");
assert.equal(typeof mod.runKeysRevealCommand, "function");
assert.equal(typeof mod.runKeysUsageCommand, "function");
});
test("health components com alertsOnly=true não lança", async () => {
// Server não está rodando — função deve retornar 1 sem throw.
const { runHealthComponentsCommand } = await import("../../bin/cli/commands/health.mjs");
const code = await runHealthComponentsCommand({ alertsOnly: true });
assert.ok(code === 0 || code === 1, "should return 0 or 1");
});
test("update --check com versão atual não lança", async () => {
const { runUpdateCommand } = await import("../../bin/cli/commands/update.mjs");
// Sem servidor npm disponível pode retornar erro — só garante que não throw.
let code = 0;
try {
code = await runUpdateCommand({ check: true, yes: true });
} catch {
code = 1;
}
assert.ok(code === 0 || code === 1);
});