zcodeConfigOptions.test.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { describe, expect, it } from "vitest";
  2. import type { ZCodeSessionSettingsState } from "@zcode/shared";
  3. import {
  4. getZCodeAgentAvailableModes,
  5. normalizeAvailableZCodeMode,
  6. settingsToConfigOptions,
  7. } from "../src/zcode-agent/zcodeConfigOptions.js";
  8. function settingsWithMode(
  9. mode: ZCodeSessionSettingsState["mode"]["current"],
  10. ): ZCodeSessionSettingsState {
  11. return {
  12. model: {
  13. current: { providerId: "glm", modelId: "glm-5" },
  14. available: [],
  15. },
  16. thoughtLevel: {
  17. enabled: false,
  18. available: [],
  19. },
  20. mode: { current: mode },
  21. };
  22. }
  23. describe("zcodeConfigOptions", () => {
  24. it("keeps persisted edit while the shared menu replaces it with guarded", () => {
  25. const options = settingsToConfigOptions(settingsWithMode("edit"));
  26. const modeOption = options.find((option) => option.category === "mode");
  27. expect(modeOption?.currentValue).toBe("edit");
  28. expect(modeOption?.options?.map((option) => option.value)).toEqual([
  29. "build",
  30. "guarded",
  31. "plan",
  32. "yolo",
  33. ]);
  34. expect(getZCodeAgentAvailableModes().map((mode) => mode.id)).toEqual([
  35. "build",
  36. "guarded",
  37. "plan",
  38. "yolo",
  39. ]);
  40. expect(normalizeAvailableZCodeMode("edit")).toBe("edit");
  41. });
  42. });