/** * @file Tests for settingsHref: the Settings page off a workspace, the * workspace's Settings tab on one (lane and run kept, a replay and a previous * sub-tab dropped, the section's own query and anchor carried). * @author Nguyễn Ngọc Trí Vĩ */ import { describe, expect, it } from "vitest"; import { settingsHref } from "../settingsLink"; describe("settingsHref", () => { it("opens the Settings page off a workspace", () => { const at = { pathname: "/sessions", search: "" }; expect(settingsHref("", at)).toBe("/settings"); expect(settingsHref("agents/claude-code?tab=mcp", at)).toBe( "/settings/agents/claude-code?tab=mcp" ); expect(settingsHref("appearance#pet", at)).toBe("/settings/appearance#pet"); // The Workspace page with no workspace yet has no tab bar to open it in. expect(settingsHref("agents", { pathname: "/workspace", search: "" })).toBe("/settings/agents"); }); it("opens the workspace's Settings tab on a workspace", () => { const at = { pathname: "/workspace", search: "?lane=3&run=agenthub-lane-3-1&tab=skills" }; expect(settingsHref("agents/claude-code?tab=mcp", at)).toBe( "/workspace?lane=3&run=agenthub-lane-3-1&settings=agents%2Fclaude-code&tab=mcp" ); expect(settingsHref("", { pathname: "/workspace", search: "?lane=3&session=abc" })).toBe( "/workspace?lane=3&settings=" ); expect( settingsHref("pricing#pricing-openai", { pathname: "/workspace", search: "?lane=3" }) ).toBe("/workspace?lane=3&settings=pricing#pricing-openai"); }); });