appTaskSwitchGuard.test.ts 740 B

12345678910111213141516171819202122
  1. import { describe, it, expect } from "vitest";
  2. import { shouldBlockTaskSelectionDuringModelRestart } from "@/lib/taskSwitchGuard.js";
  3. describe("shouldBlockTaskSelectionDuringModelRestart", () => {
  4. it("模型切换重建阶段且 pending 时应阻止任务切换", () => {
  5. expect(
  6. shouldBlockTaskSelectionDuringModelRestart(true, "restartingRuntime"),
  7. ).toBe(true);
  8. });
  9. it("pending 但非重建阶段时不阻止任务切换", () => {
  10. expect(
  11. shouldBlockTaskSelectionDuringModelRestart(true, "syncingSession"),
  12. ).toBe(false);
  13. });
  14. it("非 pending 时不阻止任务切换", () => {
  15. expect(
  16. shouldBlockTaskSelectionDuringModelRestart(false, "restartingRuntime"),
  17. ).toBe(false);
  18. });
  19. });