Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

test(sidebar): cover Monitoring reorg, Costs section, back-compat (B/F3)

diegosouzapw88899971d19b
diff --git a/tests/unit/sidebar-back-compat.test.ts b/tests/unit/sidebar-back-compat.test.ts
new file mode 100644
index 0000000000..b3c387f5a0
--- /dev/null
+++ b/tests/unit/sidebar-back-compat.test.ts
@@ -0,0 +1,67 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+
+const sidebarVisibility = await import("../../src/shared/constants/sidebarVisibility.ts");
+
+test("HIDEABLE_SIDEBAR_ITEM_IDS contains activity (new)", () => {
+ assert.ok(
+ (sidebarVisibility.HIDEABLE_SIDEBAR_ITEM_IDS as readonly string[]).includes("activity"),
+ "activity must be in HIDEABLE_SIDEBAR_ITEM_IDS",
+ );
+});
+
+test("HIDEABLE_SIDEBAR_ITEM_IDS still contains logs-activity (B11 back-compat)", () => {
+ assert.ok(
+ (sidebarVisibility.HIDEABLE_SIDEBAR_ITEM_IDS as readonly string[]).includes("logs-activity"),
+ "logs-activity must remain in HIDEABLE_SIDEBAR_ITEM_IDS for back-compat",
+ );
+});
+
+test("admin preset shows activity (not logs-activity) as visible", () => {
+ const adminPreset = sidebarVisibility.SIDEBAR_PRESETS.find((p) => p.id === "admin");
+ assert.ok(adminPreset, "admin preset must exist");
+
+ // activity must NOT be in hiddenItems (i.e., it's visible in admin preset)
+ assert.equal(
+ (adminPreset.hiddenItems as string[]).includes("activity"),
+ false,
+ "activity must be visible (not hidden) in admin preset",
+ );
+
+ // logs-activity must be hidden in admin preset (B30: was replaced by activity)
+ assert.ok(
+ (adminPreset.hiddenItems as string[]).includes("logs-activity"),
+ "logs-activity must be hidden in admin preset (replaced by activity, B30)",
+ );
+});
+
+test("admin preset shows costs, costs-pricing, costs-budget, costs-quota-share", () => {
+ const adminPreset = sidebarVisibility.SIDEBAR_PRESETS.find((p) => p.id === "admin");
+ assert.ok(adminPreset, "admin preset must exist");
+
+ for (const id of ["costs", "costs-pricing", "costs-budget", "costs-quota-share"]) {
+ assert.equal(
+ (adminPreset.hiddenItems as string[]).includes(id),
+ false,
+ `${id} must be visible (not hidden) in admin preset`,
+ );
+ }
+});
+
+test("all preset has no hidden items", () => {
+ const allPreset = sidebarVisibility.SIDEBAR_PRESETS.find((p) => p.id === "all");
+ assert.ok(allPreset, "all preset must exist");
+ assert.deepEqual(allPreset.hiddenItems, []);
+});
+
+test("logs-activity is absent from SIDEBAR_SECTIONS item definitions (removed from navigation)", () => {
+ const allSectionItemIds = sidebarVisibility.SIDEBAR_SECTIONS.flatMap((section) =>
+ sidebarVisibility.getSectionItems(section).map((item) => item.id),
+ );
+
+ assert.equal(
+ (allSectionItemIds as string[]).includes("logs-activity"),
+ false,
+ "logs-activity must not appear in any section's item definitions (navigation-level removal)",
+ );
+});
diff --git a/tests/unit/sidebar-costs-section.test.ts b/tests/unit/sidebar-costs-section.test.ts
new file mode 100644
index 0000000000..fb5156fa17
--- /dev/null
+++ b/tests/unit/sidebar-costs-section.test.ts
@@ -0,0 +1,90 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+
+const sidebarVisibility = await import("../../src/shared/constants/sidebarVisibility.ts");
+
+function findSection(id: string) {
+ return sidebarVisibility.SIDEBAR_SECTIONS.find((s) => s.id === id);
+}
+
+test("costs section exists in SIDEBAR_SECTIONS", () => {
+ const section = findSection("costs");
+ assert.ok(section, "costs section must exist");
+});
+
+test("costs section has exactly 4 items in the correct order", () => {
+ const section = findSection("costs");
+ assert.ok(section, "costs section must exist");
+
+ const items = sidebarVisibility.getSectionItems(section);
+ assert.equal(items.length, 4, "costs section must have 4 items");
+
+ const itemIds = items.map((i) => i.id);
+ assert.deepEqual(itemIds, ["costs", "costs-pricing", "costs-budget", "costs-quota-share"]);
+});
+
+test("costs section items have correct hrefs", () => {
+ const section = findSection("costs");
+ assert.ok(section, "costs section must exist");
+
+ const items = sidebarVisibility.getSectionItems(section);
+ const hrefs = items.map((i) => ({ id: i.id, href: i.href }));
+
+ assert.deepEqual(hrefs, [
+ { id: "costs", href: "/dashboard/costs" },
+ { id: "costs-pricing", href: "/dashboard/costs/pricing" },
+ { id: "costs-budget", href: "/dashboard/costs/budget" },
+ { id: "costs-quota-share", href: "/dashboard/costs/quota-share" },
+ ]);
+});
+
+test("costs item uses costsOverview i18nKey (not costs)", () => {
+ const section = findSection("costs");
+ assert.ok(section, "costs section must exist");
+
+ const costsItem = sidebarVisibility.getSectionItems(section).find((i) => i.id === "costs");
+ assert.ok(costsItem, "costs item must exist in costs section");
+ assert.equal(costsItem.i18nKey, "costsOverview");
+ assert.equal(costsItem.subtitleKey, "costsOverviewSubtitle");
+});
+
+test("costs item was removed from analytics section", () => {
+ const analyticsSection = findSection("analytics");
+ assert.ok(analyticsSection, "analytics section must exist");
+
+ const analyticsItems = sidebarVisibility.getSectionItems(analyticsSection);
+ const analyticsItemIds = analyticsItems.map((i) => i.id);
+
+ assert.equal(
+ analyticsItemIds.includes("costs" as sidebarVisibility.HideableSidebarItemId),
+ false,
+ "costs item must not be in analytics section",
+ );
+});
+
+test("costs section is positioned between analytics and monitoring", () => {
+ const sectionIds = sidebarVisibility.SIDEBAR_SECTIONS.map((s) => s.id);
+ const analyticsIdx = sectionIds.indexOf("analytics");
+ const costsIdx = sectionIds.indexOf("costs");
+ const monitoringIdx = sectionIds.indexOf("monitoring");
+
+ assert.ok(analyticsIdx !== -1, "analytics section must exist");
+ assert.ok(costsIdx !== -1, "costs section must exist");
+ assert.ok(monitoringIdx !== -1, "monitoring section must exist");
+
+ assert.ok(
+ analyticsIdx < costsIdx,
+ `analytics (${analyticsIdx}) must come before costs (${costsIdx})`,
+ );
+ assert.ok(
+ costsIdx < monitoringIdx,
+ `costs (${costsIdx}) must come before monitoring (${monitoringIdx})`,
+ );
+});
+
+test("costs section titleKey is costsSection", () => {
+ const section = findSection("costs");
+ assert.ok(section, "costs section must exist");
+ assert.equal(section.titleKey, "costsSection");
+ assert.equal(section.titleFallback, "Costs");
+});
diff --git a/tests/unit/sidebar-monitoring-reorg.test.ts b/tests/unit/sidebar-monitoring-reorg.test.ts
new file mode 100644
index 0000000000..2a2e7e71d6
--- /dev/null
+++ b/tests/unit/sidebar-monitoring-reorg.test.ts
@@ -0,0 +1,104 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+
+const sidebarVisibility = await import("../../src/shared/constants/sidebarVisibility.ts");
+
+function findSection(id: string) {
+ return sidebarVisibility.SIDEBAR_SECTIONS.find((s) => s.id === id);
+}
+
+test("monitoring section exists", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+});
+
+test("monitoring section has exactly 4 children: 1 item (activity) + 3 groups (logs, audit, system)", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+
+ const children = section.children;
+ assert.equal(children.length, 4, "monitoring must have 4 children");
+
+ // First child is the activity item (not a group)
+ const first = children[0] as sidebarVisibility.SidebarItemDefinition;
+ assert.ok(!("type" in first) || first.type !== "group", "first child must not be a group");
+ assert.equal((first as sidebarVisibility.SidebarItemDefinition).id, "activity", "first child must be activity item");
+
+ // Remaining 3 children are groups
+ const groups = children.slice(1);
+ for (const g of groups) {
+ assert.ok("type" in g && g.type === "group", "children[1..3] must all be groups");
+ }
+
+ const groupIds = groups.map((g) => (g as sidebarVisibility.SidebarItemGroup).id);
+ assert.deepEqual(groupIds, ["logs", "audit", "system"], "group ids must be logs, audit, system in order");
+});
+
+test("getSectionItems of monitoring does NOT contain logs-activity", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+
+ const items = sidebarVisibility.getSectionItems(section);
+ const itemIds = items.map((i) => i.id);
+
+ assert.equal(
+ itemIds.includes("logs-activity" as sidebarVisibility.HideableSidebarItemId),
+ false,
+ "logs-activity must not be in monitoring section items",
+ );
+});
+
+test("monitoring section does NOT have a group with id costs-parameters", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+
+ const groupIds = section.children
+ .filter((c): c is sidebarVisibility.SidebarItemGroup => "type" in c && c.type === "group")
+ .map((g) => g.id);
+
+ assert.equal(
+ groupIds.includes("costs-parameters"),
+ false,
+ "costs-parameters group must not exist in monitoring",
+ );
+});
+
+test("monitoring section activity item has correct href and icon", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+
+ const activityItem = sidebarVisibility
+ .getSectionItems(section)
+ .find((i) => i.id === "activity");
+
+ assert.ok(activityItem, "activity item must be in monitoring section");
+ assert.equal(activityItem.href, "/dashboard/activity");
+ assert.equal(activityItem.icon, "timeline");
+ assert.equal(activityItem.i18nKey, "activity");
+});
+
+test("monitoring logs group contains logs, logs-proxy, logs-console", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+
+ const logsGroup = section.children.find(
+ (c): c is sidebarVisibility.SidebarItemGroup => "type" in c && c.type === "group" && c.id === "logs",
+ );
+ assert.ok(logsGroup, "logs group must exist in monitoring");
+
+ const itemIds = logsGroup.items.map((i) => i.id);
+ assert.deepEqual(itemIds, ["logs", "logs-proxy", "logs-console"]);
+});
+
+test("monitoring system group contains health and runtime", () => {
+ const section = findSection("monitoring");
+ assert.ok(section, "monitoring section must exist");
+
+ const systemGroup = section.children.find(
+ (c): c is sidebarVisibility.SidebarItemGroup => "type" in c && c.type === "group" && c.id === "system",
+ );
+ assert.ok(systemGroup, "system group must exist in monitoring");
+
+ const itemIds = systemGroup.items.map((i) => i.id);
+ assert.deepEqual(itemIds, ["health", "runtime"]);
+});