Fixed tab naming to correspond to the web client. (#1780)

This commit is contained in:
Bob Dickinson 2026-07-25 17:11:52 -07:00 • committed by GitHub
commit d009fcca09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,6 @@
import { describe, it, expect } from "vitest";
import { tabs } from "../src/components/tabsConfig.js";
import { splitLabelAtAccelerator } from "../src/components/Tabs.js";
describe("TUI", () => {
it("exports tabs with expected shape", () => {
@ -18,4 +19,52 @@ describe("TUI", () => {
expect(info?.label).toBe("Info");
expect(info?.accelerator).toBe("i");
});
it("uses web-aligned monitor tab labels with unique in-label accelerators", () => {
expect(tabs.find((t) => t.id === "messages")).toMatchObject({
label: "Protocol",
accelerator: "p",
});
expect(tabs.find((t) => t.id === "requests")).toMatchObject({
label: "Network",
accelerator: "n",
});
expect(tabs.find((t) => t.id === "logging")).toMatchObject({
label: "Console",
accelerator: "o",
});
expect(tabs.find((t) => t.id === "prompts")).toMatchObject({
label: "Prompts",
accelerator: "m",
});
const accelerators = tabs.map((t) => t.accelerator);
expect(new Set(accelerators).size).toBe(accelerators.length);
for (const tab of tabs) {
expect(tab.label.toLowerCase()).toContain(tab.accelerator.toLowerCase());
}
});
it("splits labels so the accelerator letter can be underlined mid-word", () => {
expect(splitLabelAtAccelerator("Prompts", "m")).toEqual({
before: "Pro",
accel: "m",
after: "pts",
});
expect(splitLabelAtAccelerator("Console", "o")).toEqual({
before: "C",
accel: "o",
after: "nsole",
});
expect(splitLabelAtAccelerator("Protocol", "p")).toEqual({
before: "",
accel: "P",
after: "rotocol",
});
expect(splitLabelAtAccelerator("Info", "z")).toEqual({
before: "",
accel: "I",
after: "nfo",
});
});
});