v4SessionConfigTaskCache.test.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { describe, expect, it } from "vitest";
  2. import type { ZCodeConfigOption } from "@zcode/shared";
  3. import { projectSessionConfigToTaskConfigOptions } from "@/v4/composer/sessionConfigTaskCache.js";
  4. const OPTIONS: ZCodeConfigOption[] = [
  5. {
  6. id: "model",
  7. name: "Model",
  8. category: "model",
  9. type: "select",
  10. currentValue: "e2e-default/default-model",
  11. options: [
  12. { value: "e2e-default/default-model", name: "Default" },
  13. { value: "e2e-vision/vision-model", name: "Vision" },
  14. ],
  15. },
  16. {
  17. id: "mode",
  18. name: "Mode",
  19. category: "mode",
  20. type: "select",
  21. currentValue: "build",
  22. options: [{ value: "yolo", name: "YOLO" }],
  23. },
  24. {
  25. id: "thought_level",
  26. name: "Thought",
  27. category: "thought_level",
  28. type: "select",
  29. currentValue: "max",
  30. options: [{ value: "high", name: "High" }],
  31. },
  32. ];
  33. describe("projectSessionConfigToTaskConfigOptions", () => {
  34. it("用 v4 权威 model/mode/thought 更新 task 缓存且保留完整目录", () => {
  35. const projected = projectSessionConfigToTaskConfigOptions(OPTIONS, {
  36. provider: "e2e-vision",
  37. model: "vision-model",
  38. mode: "yolo",
  39. thought: "high",
  40. });
  41. expect(projected).toHaveLength(OPTIONS.length);
  42. expect(projected[0]).toMatchObject({
  43. currentValue: "e2e-vision/vision-model",
  44. options: OPTIONS[0]?.options,
  45. });
  46. expect(projected[1]?.currentValue).toBe("yolo");
  47. expect(projected[2]?.currentValue).toBe("high");
  48. });
  49. it("runtime model 已含 provider 前缀时不会重复拼接", () => {
  50. const projected = projectSessionConfigToTaskConfigOptions(OPTIONS, {
  51. provider: "e2e-vision",
  52. model: "e2e-vision/vision-model",
  53. mode: "build",
  54. thought: "",
  55. });
  56. expect(projected[0]?.currentValue).toBe("e2e-vision/vision-model");
  57. });
  58. });