- routes.ts registers all workspaces under /console (+ detail routes, engine, audit, login) - api.ts: cookie session first (credentials include, CSRF header), Bearer only with stored key, 401 -> /login - sse.ts: shared EventSource with ?after=seq catch-up, backoff reconnect, per-type subscribe - shared components: data-table, filter-bar, detail-sheet, timeline, json-view, confirm-dialog, form-field, kv-list, stat-tile, error/loading states; ui tabs and textarea Co-Authored-By: Claude Opus 5.5 <[email protected]>
24 lines
975 B
TypeScript
24 lines
975 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { consolePath, findNavItem, NAV_ITEMS } from "./nav.ts";
|
|
|
|
describe("控制台导航", () => {
|
|
it("12 个工作区 + 引擎面板 + 审计,路径唯一且都在 /console 下", () => {
|
|
expect(NAV_ITEMS).toHaveLength(14);
|
|
expect(new Set(NAV_ITEMS.map((i) => i.to)).size).toBe(14);
|
|
expect(NAV_ITEMS.every((i) => i.to.startsWith("/console"))).toBe(true);
|
|
});
|
|
|
|
it("按最长前缀匹配当前项", () => {
|
|
expect(findNavItem("/console")?.label).toBe("首页");
|
|
expect(findNavItem("/console/")?.label).toBe("首页");
|
|
expect(findNavItem("/console/library/abc")?.label).toBe("媒体库");
|
|
expect(findNavItem("/console/engine/r1")?.label).toBe("工作流引擎");
|
|
expect(findNavItem("/nope")).toBeUndefined();
|
|
});
|
|
|
|
it("consolePath 拼路径并编码", () => {
|
|
expect(consolePath()).toBe("/console");
|
|
expect(consolePath("library", "a b")).toBe("/console/library/a%20b");
|
|
});
|
|
});
|