independentPlanSupport.test.ts 1.0 KB

1234567891011121314151617181920
  1. import { describe, expect, it, vi } from "vitest";
  2. import { ensureIndependentPlanSupport } from "../src/zcode-agent/independentPlanSupport.js";
  3. describe("独立 Plan 执行端能力", () => {
  4. it("复用同一 CLI 的成功检查,重建 CLI 后重新检查", async () => {
  5. const first = { request: vi.fn().mockResolvedValue({ independentPlanState: true }) };
  6. await ensureIndependentPlanSupport(first as never);
  7. await ensureIndependentPlanSupport(first as never);
  8. expect(first.request).toHaveBeenCalledTimes(1);
  9. const second = { request: vi.fn().mockResolvedValue({ independentPlanState: true }) };
  10. await ensureIndependentPlanSupport(second as never);
  11. expect(second.request).toHaveBeenCalledTimes(1);
  12. });
  13. it("旧 CLI 不认识能力查询时拒绝,不能只相信新 Host 的版本", async () => {
  14. const client = { request: vi.fn().mockRejectedValue(new Error("Method not found")) };
  15. await expect(ensureIndependentPlanSupport(client as never)).rejects.toThrow(
  16. "proto.independentPlanUnsupported",
  17. );
  18. });
  19. });