Files
OmniRoute/tests/unit/settings-ui-layout-static.test.ts
Diego Rodrigues de Sa e Souza cbe2ec1244 feat(dashboard): add tool-source diagnostics settings toggle (#5978)
* feat(dashboard): add tool-source diagnostics settings toggle

Adds a Settings > Advanced card (cloned from DebugModeCard) that lets
operators flip the existing `logToolSources` flag from the UI instead
of editing the DB row directly. The backend gate (chatCore.ts) and DB
default were already present but had no toggle. Also adds
`logToolSources` to the /api/settings Zod PATCH schema (it is `.strict()`,
so the key was previously rejected) and en-only i18n strings.

Co-authored-by: DuyPrX <93126969+DuyPrX@users.noreply.github.com>
Inspired-by: https://github.com/decolua/9router/pull/1825

* chore(changelog): restore release entries + add tool-source toggle bullet

---------

Co-authored-by: DuyPrX <93126969+DuyPrX@users.noreply.github.com>
2026-07-03 00:14:32 -03:00

120 lines
4.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
function readSrc(path: string): string {
return readFileSync(join(ROOT, path), "utf8");
}
function assertInOrder(source: string, labels: string[]) {
let lastIndex = -1;
for (const label of labels) {
const index = source.indexOf(label);
assert.notEqual(index, -1, `Expected to find ${label}`);
assert.ok(index > lastIndex, `Expected ${label} to appear after previous marker`);
lastIndex = index;
}
}
test("Appearance page keeps theme color above branding and removes sidebar item controls", () => {
const source = readSrc("src/app/(dashboard)/dashboard/settings/components/AppearanceTab.tsx");
assert.doesNotMatch(source, /SidebarVisibilitySetting/);
assertInOrder(source, ['t("themeAccent")', 't("whitelabeling")']);
});
test("Usage Token Buffer lives in AI settings instead of General storage", () => {
const aiPage = readSrc("src/app/(dashboard)/dashboard/settings/ai/page.tsx");
const generalStorage = readSrc(
"src/app/(dashboard)/dashboard/settings/components/SystemStorageTab.tsx"
);
assert.match(aiPage, /UsageTokenBufferTab/);
assert.doesNotMatch(generalStorage, /storageUsageTokenBuffer/);
});
test("Storage settings page uses the requested section order", () => {
const source = readSrc("src/app/(dashboard)/dashboard/settings/components/SystemStorageTab.tsx");
assertInOrder(source, [
't("databasePath")',
"{renderDatabaseStatistics()}",
't("export")',
't("maintenance")',
't("lastBackup")',
"{renderRetentionSettings()}",
"{renderOptimizationSettings()}",
"{renderCompressionAggregationSettings()}",
]);
assert.doesNotMatch(source, /debugToggle/);
});
test("Debug mode moved to the top of Advanced settings", () => {
const advancedPage = readSrc("src/app/(dashboard)/dashboard/settings/advanced/page.tsx");
assertInOrder(advancedPage, ["<DebugModeCard", "<PayloadRulesTab"]);
});
test("Log Tool Sources toggle is mounted in Advanced settings next to Debug mode", () => {
const advancedPage = readSrc("src/app/(dashboard)/dashboard/settings/advanced/page.tsx");
assertInOrder(advancedPage, ["<DebugModeCard", "<LogToolSourcesCard", "<PayloadRulesTab"]);
const card = readSrc(
"src/app/(dashboard)/dashboard/settings/components/LogToolSourcesCard.tsx"
);
assert.match(card, /t\("logToolSourcesToggle"\)/);
assert.match(card, /t\("logToolSourcesDescription"\)/);
assert.match(card, /logToolSources: value/);
const schema = readSrc("src/shared/validation/settingsSchemas.ts");
assert.match(schema, /logToolSources: z\.boolean\(\)\.optional\(\)/);
const en = readSrc("src/i18n/messages/en.json");
assert.match(en, /"logToolSourcesToggle": "Log Tool Sources"/);
});
test("Proxy Logs table uses the same blue row hover emphasis as Logs", () => {
const proxyLogger = readSrc("src/shared/components/ProxyLogger.tsx");
const requestLogger = readSrc("src/shared/components/RequestLoggerV2.tsx");
assert.match(proxyLogger, /hover:bg-sky-500\/10 dark:hover:bg-sky-400\/10/);
assert.match(requestLogger, /hover:bg-sky-500\/10 dark:hover:bg-sky-400\/10/);
assert.doesNotMatch(proxyLogger, /hover:bg-primary\/5/);
});
test("General settings navigation is labeled Storage in English", () => {
const en = readSrc("src/i18n/messages/en.json");
assert.match(en, /"settingsGeneral": "Storage"/);
assert.match(en, /"systemStorage": "Storage"/);
});
test("Global Routing page renders top-level modules in the requested order", () => {
const page = readSrc("src/app/(dashboard)/dashboard/settings/routing/page.tsx");
const routingTab = readSrc("src/app/(dashboard)/dashboard/settings/components/RoutingTab.tsx");
assertInOrder(page, [
"<ComboDefaultsTab",
"<ModelAliasesUnified",
"<FallbackChainsEditor",
"<ModelRoutingSection",
"<RoutingTab",
"<BackgroundDegradationTab",
]);
assertInOrder(routingTab, [
't("routingZeroConfigTitle")',
't("systemTransforms")',
't("cliFingerprint")',
't("routingClientCacheControlTitle")',
't("routingAntigravitySignatureTitle")',
't("lkgpToggleTitle")',
't("adaptiveVolumeRouting")',
]);
});