pi.provider / baseUrl / model / thinkingLevel / apiKeySecretRef are now DEPRECATED_SETTINGS_FIELDS: kept in the schema for stored JSON, dropped from PATCH /settings and from the settings sections, never read by the server. runAgent fails with a clear message when no upstream is set. The agent demo gate checks the default upstream provider; e2e seeds a fake upstream as default. OpenAPI summaries say Agent upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
DEFAULT_SETTINGS,
|
|
DEPRECATED_SETTINGS_FIELDS,
|
|
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 deprecated = new Set<string>(DEPRECATED_SETTINGS_FIELDS);
|
|
const all = Object.entries(DEFAULT_SETTINGS)
|
|
.flatMap(([key, v]) => Object.keys(v).map((f) => `${key}.${f}`))
|
|
.filter((f) => !deprecated.has(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();
|
|
});
|
|
});
|