|
1 | | -// Control UI tests cover navigation groups behavior. |
| 1 | +// Control UI tests cover sidebar pinned-route customization behavior. |
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | 3 | import { |
| 4 | + DEFAULT_SIDEBAR_PINNED_ROUTES, |
4 | 5 | SETTINGS_NAVIGATION_ROUTES, |
5 | | - SIDEBAR_SECTIONS, |
| 6 | + SIDEBAR_NAV_ROUTES, |
6 | 7 | isSettingsNavigationRoute, |
7 | | - isRouteInSidebarSection, |
| 8 | + normalizeSidebarPinnedRoutes, |
| 9 | + sidebarMoreRoutes, |
8 | 10 | } from "./app-navigation.ts"; |
9 | 11 | import { routeIdFromPath } from "./app-routes.ts"; |
10 | 12 |
|
11 | | -describe("SIDEBAR_SECTIONS", () => { |
12 | | - it("collapses detailed settings slices into one sidebar entry", () => { |
13 | | - const settings = SIDEBAR_SECTIONS.find((group) => group.label === "settings"); |
14 | | - expect(settings?.routes).toEqual(["config"]); |
| 13 | +describe("sidebar pinned routes", () => { |
| 14 | + it("defaults to a small pinned set drawn from the customizable routes", () => { |
| 15 | + expect(DEFAULT_SIDEBAR_PINNED_ROUTES.length).toBeLessThan(SIDEBAR_NAV_ROUTES.length); |
| 16 | + for (const routeId of DEFAULT_SIDEBAR_PINNED_ROUTES) { |
| 17 | + expect(SIDEBAR_NAV_ROUTES).toContain(routeId); |
| 18 | + } |
| 19 | + }); |
| 20 | + |
| 21 | + it("keeps managed worktrees in the customizable sidebar", () => { |
| 22 | + expect(SIDEBAR_NAV_ROUTES).toContain("worktrees"); |
| 23 | + }); |
| 24 | + |
| 25 | + it("keeps channel management and settings slices out of the customizable sidebar", () => { |
| 26 | + expect(SIDEBAR_NAV_ROUTES).not.toContain("channels"); |
| 27 | + expect(SIDEBAR_NAV_ROUTES).not.toContain("config"); |
| 28 | + expect(SETTINGS_NAVIGATION_ROUTES).toContain("channels"); |
15 | 29 | expect(SETTINGS_NAVIGATION_ROUTES.every((routeId) => isSettingsNavigationRoute(routeId))).toBe( |
16 | 30 | true, |
17 | 31 | ); |
18 | 32 | }); |
19 | 33 |
|
20 | | - it("keeps channel management out of the primary control sidebar", () => { |
21 | | - const control = SIDEBAR_SECTIONS.find((group) => group.label === "control"); |
22 | | - expect(control?.routes).toEqual([ |
23 | | - "overview", |
24 | | - "activity", |
25 | | - "workboard", |
26 | | - "worktrees", |
27 | | - "instances", |
28 | | - "sessions", |
29 | | - "usage", |
30 | | - "cron", |
31 | | - ]); |
32 | | - expect(SETTINGS_NAVIGATION_ROUTES).toContain("channels"); |
| 34 | + it("normalizes persisted pinned routes, dropping unknown and duplicate entries", () => { |
| 35 | + expect( |
| 36 | + normalizeSidebarPinnedRoutes(["worktrees", "overview", "worktrees", "bogus", 7]), |
| 37 | + ).toEqual(["worktrees", "overview"]); |
| 38 | + expect(normalizeSidebarPinnedRoutes([])).toEqual([]); |
33 | 39 | }); |
34 | 40 |
|
35 | | - it("keeps the settings group active for nested settings routes", () => { |
36 | | - const settings = SIDEBAR_SECTIONS.find((group) => group.label === "settings"); |
37 | | - if (!settings) { |
38 | | - throw new Error("Expected settings group"); |
39 | | - } |
| 41 | + it("falls back to null for non-list values so callers use defaults", () => { |
| 42 | + expect(normalizeSidebarPinnedRoutes(undefined)).toBeNull(); |
| 43 | + expect(normalizeSidebarPinnedRoutes({ overview: true })).toBeNull(); |
| 44 | + expect(normalizeSidebarPinnedRoutes("overview")).toBeNull(); |
| 45 | + }); |
40 | 46 |
|
41 | | - expect(isRouteInSidebarSection(settings, "appearance")).toBe(true); |
42 | | - expect(isRouteInSidebarSection(settings, "channels")).toBe(true); |
43 | | - expect(isRouteInSidebarSection(settings, "debug")).toBe(true); |
44 | | - expect(isRouteInSidebarSection(settings, "chat")).toBe(false); |
| 47 | + it("puts every unpinned nav route into the More section", () => { |
| 48 | + const pinned = ["overview", "worktrees"] as const; |
| 49 | + const more = sidebarMoreRoutes(pinned); |
| 50 | + expect(more).not.toContain("overview"); |
| 51 | + expect(more).not.toContain("worktrees"); |
| 52 | + expect(new Set([...pinned, ...more])).toEqual(new Set(SIDEBAR_NAV_ROUTES)); |
45 | 53 | }); |
46 | 54 |
|
47 | 55 | it("routes every published settings slice", () => { |
|
0 commit comments