Fixed tab naming to correspond to the web client. (#1780)
This commit is contained in:
parent
07d6316fba
commit
d009fcca09
1 changed files with 134 additions and 51 deletions
|
|
@ -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",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue