c276cd6eff
Also normalizes setting labels/descriptions and carries the package changelog entries for this batch (adjacent unreleased bullets are not splittable per commit), restoring section placement disturbed by the two prior changelog hunks.
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import {
|
|
SETTING_TABS,
|
|
SETTINGS_SCHEMA,
|
|
type SettingTab,
|
|
TAB_GROUPS,
|
|
} from "@oh-my-pi/pi-coding-agent/config/settings-schema";
|
|
import { getSettingsForTab } from "@oh-my-pi/pi-coding-agent/modes/components/settings-defs";
|
|
|
|
interface UiShape {
|
|
tab: SettingTab;
|
|
group?: string;
|
|
}
|
|
|
|
describe("settings layout", () => {
|
|
it("every UI setting declares a group registered in TAB_GROUPS for its tab", () => {
|
|
const violations: string[] = [];
|
|
for (const path in SETTINGS_SCHEMA) {
|
|
const ui = (SETTINGS_SCHEMA[path as keyof typeof SETTINGS_SCHEMA] as { ui?: UiShape }).ui;
|
|
if (!ui) continue;
|
|
if (!ui.group) {
|
|
violations.push(`${path}: missing ui.group`);
|
|
} else if (!TAB_GROUPS[ui.tab].includes(ui.group)) {
|
|
violations.push(`${path}: group "${ui.group}" not in TAB_GROUPS["${ui.tab}"]`);
|
|
}
|
|
}
|
|
expect(violations).toEqual([]);
|
|
});
|
|
|
|
it("getSettingsForTab returns contiguous groups in TAB_GROUPS order", () => {
|
|
for (const tab of SETTING_TABS) {
|
|
const defs = getSettingsForTab(tab);
|
|
expect(defs.length).toBeGreaterThan(0);
|
|
|
|
// Collapse the def sequence into the order groups first appear.
|
|
const sequence: string[] = [];
|
|
for (const def of defs) {
|
|
const group = def.group ?? "";
|
|
if (sequence[sequence.length - 1] !== group) sequence.push(group);
|
|
}
|
|
|
|
// Contiguous: no group appears twice in the collapsed sequence.
|
|
expect(new Set(sequence).size).toBe(sequence.length);
|
|
|
|
// Ordered: grouped sections follow the TAB_GROUPS declaration order.
|
|
const grouped = sequence.filter(group => group !== "");
|
|
const expected = TAB_GROUPS[tab].filter(group => grouped.includes(group));
|
|
expect(grouped).toEqual(expected);
|
|
}
|
|
});
|
|
});
|