unboundModelSelection.test.ts 983 B

123456789101112131415161718192021222324
  1. import { describe, expect, it } from "vitest";
  2. import { formatModelPickerValue, zcodeSessionSettingsStateSchema } from "../src/index.js";
  3. describe("未绑定模型的协议与显示边界", () => {
  4. it("允许 settings 没有当前模型,不用空 Provider/Model 冒充有效身份", () => {
  5. const settings = {
  6. model: { available: [] },
  7. thoughtLevel: { enabled: false, available: [] },
  8. mode: { current: "build" },
  9. };
  10. expect(zcodeSessionSettingsStateSchema.parse(settings).model.current).toBeUndefined();
  11. expect(
  12. zcodeSessionSettingsStateSchema.safeParse({
  13. ...settings,
  14. model: { ...settings.model, current: { providerId: "", modelId: "" } },
  15. }).success,
  16. ).toBe(false);
  17. });
  18. it("模型控件的空选择显示为空,实际选择仍保留完整编码", () => {
  19. expect(formatModelPickerValue(undefined)).toBe("");
  20. expect(formatModelPickerValue({ providerId: "p", modelId: "m" })).toBe("p/m");
  21. });
  22. });