Files
UHD_Media_Tool/packages/contracts/test/settings-sections.test.ts
T
rootandClaude Opus 5.5 c67f6a9682 feat(web): settings with 9 sidebar sections and Agent upstream management
- /console/settings#<section>[/<anchor>]; legacy ?tab= redirected in clientLoader
- SETTINGS_SECTIONS in contracts with field-ownership test
- Agent section: upstream list, create wizard (provider -> credentials/model -> login/test/default),
  edit drawer with OAuth browser/device login, test, set default, delete
- sites section with site registration, snapshot/rate-limit drawer and account credentials
- path mappings moved into downloader / media-server drawers; metadata and account sections

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-28 03:05:51 +08:00

40 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
DEFAULT_SETTINGS,
SETTINGS_SECTIONS,
SettingsSectionId,
settingsSectionForLegacyTab,
} from "../src/settings.ts";
describe("SETTINGS_SECTIONS", () => {
it("9 个分区,顺序与 SettingsSectionId 一致", () => {
expect(SETTINGS_SECTIONS.map((s) => s.id)).toEqual(SettingsSectionId.options);
});
it("8 个存储 key 的每个字段恰好归属一个分区", () => {
const all = Object.entries(DEFAULT_SETTINGS).flatMap(([key, v]) => Object.keys(v).map((f) => `${key}.${f}`));
const owned = SETTINGS_SECTIONS.flatMap((s) => s.fields);
expect(new Set(owned).size).toBe(owned.length);
expect([...owned].sort()).toEqual([...all].sort());
});
it("旧 ?tab= 值都能落到分区", () => {
for (const tab of [
"automation",
"downloaders",
"media-servers",
"library-roots",
"path-mappings",
"site-credentials",
"api-keys",
"pi",
"storage",
]) {
expect(settingsSectionForLegacyTab(tab), tab).not.toBeNull();
}
expect(settingsSectionForLegacyTab("storage")).toEqual({ section: "automation", anchor: "cache" });
expect(settingsSectionForLegacyTab("path-mappings")).toEqual({ section: "downloaders", anchor: undefined });
expect(settingsSectionForLegacyTab("nope")).toBeNull();
});
});