mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-08 00:02:20 +03:00
* feat(ci): G0 — quality rail (PR→release/**) ganha ratchets+segurança do trilho A O refactor de god-files do trilho 3.8.50→3.9.0 acontece em PRs→release/**, e esse trilho pulava o motor de ratchet, o CodeQL ratchet e todos os scanners de segurança — exatamente onde a rede era necessária (5 das 13 causas da reconciliação de 07-24 eram regressões reais shipadas por CI verde por-PR). Modo enxuto, jobs EXISTENTES (a .51 consolida lanes; nenhum job novo): - lint-guard: quality:collect + ratchet --allow-missing + require-tighten + check:codeql-ratchet. O job já escreve .artifacts/eslint-results.json, então o motor entra a custo ZERO de ESLint (um inventário, dois consumidores). Coverage ausente degrada gracioso (--allow-missing); autoridade de coverage segue no trilho A. + permissions security-events:read para o CodeQL ratchet. - fast-gates: check:cycles, check:lockfile, duplication, dead-code, type-coverage, compression-budget + install endurecido dos scanners (gh release download, zizmor PINADO 1.25.2 = mesmo auditor do ci.yml) + secrets/vuln/workflows/ openapi-breaking com --ratchet (self-skip sem binário; só regressão medida bloqueia). - Fora de propósito: bundle-size (self-skip sem build → configuração morta) e o run de coverage (fast-unit já roda a suíte cheia). Runners intocados: guard tests/unit/vps-runner-variable-scope.test.ts verde; teste novo tests/unit/quality-rail-gate-membership.test.ts pina a MEMBERSHIP dos gates no trilho B (red antes da edição, green depois). Validação no tip puro (nenhum base-red fabricado para a fila de PRs abertos): cycles OK · lockfile OK · duplication 4.26% (base 5.72%) · dead-code 226 (base 227) · type-coverage 94.13% (base 92.17%) · compression OK · secrets 0 (base 0) · vuln 5 (base 10) · codeql 0 (base 0) · oasdiff 0 (base 0) · zizmor 178 (base 190) · actionlint exit 0 no arquivo editado · quality-ratchet 56 métricas OK + require-tighten OK com --allow-missing. Refs #8084 * feat(.50): G13 golden-set, G14 import boundaries, gap34 deterministic, docs sync, R0.2 dead hooks Integra os itens restantes da 3.8.50: - G13: golden-set determinístico para combo.ts e chatCore.ts via seams públicas - G14: no-restricted-imports para localDb barrel fora de src/lib/db/ e executors em src/app/ - Gap34: teste determinístico de timeout DuckDuckGo sem rede real - Docs: golden path de contribuição + sincronização de números canônicos - R0.2: remoção dos 7 hooks mortos do BUILTIN_EVENTS + UI marketplace ajustada * fix(r0.2): remove marketplace tab remnants from plugins page — fixes dashboard typecheck regression * chore(r0.2): remove pluginWorker.ts, signing.ts, sandbox.ts — zero importers confirmed * fix(docs): remove OMNIROUTE_PLUGINS_ALLOW_EXEC reference — env var removed with pluginWorker.ts in R0.2 * fix(env): remove dead OMNIROUTE_PLUGINS_ALLOW_EXEC from .env.example — consumer removed in R0.2 * fix(test): update sidebar-visibility assertion for R0.2 marketplace removal --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
186 lines
6.2 KiB
TypeScript
186 lines
6.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
const sidebarVisibility = await import("../../src/shared/constants/sidebarVisibility.ts");
|
|
const repoRoot = join(import.meta.dirname, "../..");
|
|
|
|
function sectionItems(sectionId: string) {
|
|
const section = sidebarVisibility.SIDEBAR_SECTIONS.find(
|
|
(candidate) => candidate.id === sectionId
|
|
);
|
|
assert.ok(section, `expected ${sectionId} sidebar section to exist`);
|
|
return sidebarVisibility.getSectionItems(section);
|
|
}
|
|
|
|
test("system sidebar items: monitoring has activity at top then logs/audit/system groups", () => {
|
|
const items = sectionItems("monitoring");
|
|
assert.deepEqual(
|
|
items.map((item) => item.id),
|
|
[
|
|
"activity",
|
|
"logs",
|
|
"logs-proxy",
|
|
"logs-console",
|
|
"logs-timeline",
|
|
"audit",
|
|
"audit-mcp",
|
|
"audit-a2a",
|
|
"health",
|
|
"runtime",
|
|
]
|
|
);
|
|
});
|
|
|
|
test("primary sidebar items place limits after cache", () => {
|
|
const items = sectionItems("omni-proxy");
|
|
assert.deepEqual(
|
|
items.map((item) => item.id),
|
|
[
|
|
"endpoints",
|
|
"api-manager",
|
|
"providers",
|
|
"embedded-services",
|
|
"combos",
|
|
"combos-live",
|
|
"quota",
|
|
"costs-quota-share",
|
|
"context-settings",
|
|
"context-combos",
|
|
"context-caveman",
|
|
"context-rtk",
|
|
"context-headroom",
|
|
"context-session-dedup",
|
|
"context-ccr",
|
|
"context-llmlingua",
|
|
"context-lite",
|
|
"context-aggressive",
|
|
"context-ultra",
|
|
"context-omniglyph",
|
|
"compression-studio",
|
|
"compression-exclusions",
|
|
"cli-code",
|
|
"cli-agents",
|
|
"acp-agents",
|
|
"cloud-agents",
|
|
"agent-bridge",
|
|
"traffic-inspector",
|
|
"discovery",
|
|
"api-endpoints",
|
|
"webhooks",
|
|
"proxy",
|
|
]
|
|
);
|
|
});
|
|
|
|
test("context sidebar section sits between primary and cli", () => {
|
|
const sectionIds = sidebarVisibility.SIDEBAR_SECTIONS.map((section) => section.id);
|
|
assert.deepEqual(sectionIds.slice(0, 4), ["home", "omni-proxy", "analytics", "costs"]);
|
|
|
|
const items = sectionItems("omni-proxy");
|
|
assert.deepEqual(
|
|
items
|
|
.filter((item) => item.id.startsWith("context-"))
|
|
.map((item) => ({ id: item.id, href: item.href })),
|
|
[
|
|
{ id: "context-settings", href: "/dashboard/context/settings" },
|
|
{ id: "context-combos", href: "/dashboard/context/combos" },
|
|
{ id: "context-caveman", href: "/dashboard/context/caveman" },
|
|
{ id: "context-rtk", href: "/dashboard/context/rtk" },
|
|
{ id: "context-headroom", href: "/dashboard/context/headroom" },
|
|
{ id: "context-session-dedup", href: "/dashboard/context/session-dedup" },
|
|
{ id: "context-ccr", href: "/dashboard/context/ccr" },
|
|
{ id: "context-llmlingua", href: "/dashboard/context/llmlingua" },
|
|
{ id: "context-lite", href: "/dashboard/context/lite" },
|
|
{ id: "context-aggressive", href: "/dashboard/context/aggressive" },
|
|
{ id: "context-ultra", href: "/dashboard/context/ultra" },
|
|
{ id: "context-omniglyph", href: "/dashboard/context/omniglyph" },
|
|
]
|
|
);
|
|
});
|
|
|
|
test("sidebar visibility drops stale entries from saved settings", () => {
|
|
const allSidebarItemIds = sidebarVisibility.SIDEBAR_SECTIONS.flatMap((section) =>
|
|
sidebarVisibility.getSectionItems(section).map((item) => item.id)
|
|
);
|
|
|
|
assert.equal(
|
|
(sidebarVisibility.HIDEABLE_SIDEBAR_ITEM_IDS as readonly string[]).includes("auto-combo"),
|
|
false
|
|
);
|
|
assert.equal((allSidebarItemIds as string[]).includes("auto-combo"), false);
|
|
assert.equal(
|
|
(sidebarVisibility.HIDEABLE_SIDEBAR_ITEM_IDS as readonly string[]).includes("settings"),
|
|
false
|
|
);
|
|
assert.equal((allSidebarItemIds as string[]).includes("settings"), false);
|
|
assert.deepEqual(sidebarVisibility.normalizeHiddenSidebarItems(["auto-combo" as any, "logs"]), [
|
|
"logs",
|
|
]);
|
|
});
|
|
|
|
test("help sidebar exposes changelog after docs and issues", () => {
|
|
const items = sectionItems("help");
|
|
assert.deepEqual(
|
|
items.map((item) => ({
|
|
id: item.id,
|
|
href: item.href,
|
|
i18nKey: item.i18nKey,
|
|
})),
|
|
[
|
|
{ id: "docs", href: "/docs", i18nKey: "docs" },
|
|
{
|
|
id: "issues",
|
|
href: "https://github.com/diegosouzapw/OmniRoute/issues",
|
|
i18nKey: "issues",
|
|
},
|
|
{ id: "changelog", href: "/dashboard/changelog", i18nKey: "changelog" },
|
|
]
|
|
);
|
|
assert.equal(sidebarVisibility.HIDEABLE_SIDEBAR_ITEM_IDS.includes("changelog"), true);
|
|
});
|
|
|
|
test("plugins has a discoverable sidebar entry (#3656 follow-up)", async () => {
|
|
const items = sectionItems("agentic-features");
|
|
const plugins = items.find((item) => item.id === "plugins");
|
|
assert.ok(plugins, "expected a plugins item in the agentic-features section");
|
|
assert.equal(plugins.href, "/dashboard/plugins");
|
|
assert.equal(sidebarVisibility.HIDEABLE_SIDEBAR_ITEM_IDS.includes("plugins"), true);
|
|
|
|
// It must be a real page (plugin manager), not a legacy redirect stub.
|
|
const pluginsPage = await readFile(
|
|
join(repoRoot, "src/app/(dashboard)/dashboard/plugins/page.tsx"),
|
|
"utf8"
|
|
);
|
|
assert.doesNotMatch(pluginsPage, /^\s*redirect\(/m);
|
|
// R0.2: marketplace tab removed (dead code) — verify the page still has plugin management UI.
|
|
assert.match(pluginsPage, /scanForPlugins|installedTab|fetchPlugins/i);
|
|
});
|
|
|
|
test("legacy dashboard routes redirect to their consolidated surfaces", async () => {
|
|
const autoComboPage = await readFile(
|
|
join(repoRoot, "src/app/(dashboard)/dashboard/auto-combo/page.tsx"),
|
|
"utf8"
|
|
);
|
|
const usagePage = await readFile(
|
|
join(repoRoot, "src/app/(dashboard)/dashboard/usage/page.tsx"),
|
|
"utf8"
|
|
);
|
|
const settingsPage = await readFile(
|
|
join(repoRoot, "src/app/(dashboard)/dashboard/settings/page.tsx"),
|
|
"utf8"
|
|
);
|
|
|
|
assert.match(autoComboPage, /redirect\("\/dashboard\/combos\?filter=intelligent"\)/);
|
|
assert.match(usagePage, /redirect\("\/dashboard\/logs"\)/);
|
|
assert.match(settingsPage, /redirect\(resolveSettingsRoute\(tab\)\)/);
|
|
assert.match(settingsPage, /\/dashboard\/settings\/general/);
|
|
|
|
const compressionPage = await readFile(
|
|
join(repoRoot, "src/app/(dashboard)/dashboard/compression/page.tsx"),
|
|
"utf8"
|
|
);
|
|
assert.match(compressionPage, /redirect\("\/dashboard\/context\/caveman"\)/);
|
|
});
|