mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(panel): add pickTab helper for validated URL tab params * fix(panel): validate kanban view + KB tab params via pickTab The bare `as T || default` cast only guarded null — a typo/invalid value (?view=deev, ?tab=foo) passed through as an out-of-set TabValue, blanking the active tab highlight and the content pane. pickTab validates against the known set and falls back to the default on null/empty/invalid. * fix(panel): highlight active sidebar footer link (exact match) SidebarFooter had no isActive branch (SidebarNav does), so footer links never highlighted. Added with EXACT match (pathname === href) — not startsWith — so /settings does not also highlight on /settings/ai-providers. Main nav keeps startsWith (longer hrefs need prefix matching); the two intentionally differ. --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
23 lines
694 B
TypeScript
23 lines
694 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { pickTab } from "@/lib/tabs";
|
|
|
|
const VIEWS = ["dev", "qa", "pr-review", "pm"] as const;
|
|
|
|
describe("pickTab", () => {
|
|
it("returns the raw value when it is in the valid set", () => {
|
|
expect(pickTab("qa", VIEWS, "dev")).toBe("qa");
|
|
});
|
|
|
|
it("falls back when raw is null", () => {
|
|
expect(pickTab(null, VIEWS, "dev")).toBe("dev");
|
|
});
|
|
|
|
it("falls back when raw is an invalid/typo value", () => {
|
|
expect(pickTab("deev", VIEWS, "dev")).toBe("dev");
|
|
expect(pickTab("foo", VIEWS, "dev")).toBe("dev");
|
|
});
|
|
|
|
it("falls back when raw is the empty string", () => {
|
|
expect(pickTab("", VIEWS, "dev")).toBe("dev");
|
|
});
|
|
}); |