import { describe, expect, it } from "vitest"; import { CONTENT_REGISTRY } from "./content-registry"; import { SETTINGS_TABS, parseSettingsTab, settingsPathForGroup } from "./settings-tabs"; describe("settings tabs", () => { it("places every content group on exactly one tab", () => { const groups = new Set(CONTENT_REGISTRY.map((f) => f.group)); for (const group of groups) { expect(SETTINGS_TABS.filter((tab) => (tab.groups as readonly string[]).includes(group))).toHaveLength(1); } }); it("falls back to the first tab for unknown or missing values", () => { expect(parseSettingsTab(undefined)).toBe("firma"); expect(parseSettingsTab("../../etc")).toBe("firma"); expect(parseSettingsTab(["system"])).toBe("firma"); expect(parseSettingsTab("system")).toBe("system"); }); it("returns to the tab of the saved group", () => { expect(settingsPathForGroup("shipping")).toBe("/admin/einstellungen?reiter=firma"); expect(settingsPathForGroup("legal")).toBe("/admin/einstellungen?reiter=recht"); expect(settingsPathForGroup("evil?x=1")).toBe("/admin/einstellungen"); }); });