conversation-session-stop-empty.test.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { clearAppData } from "../../../helpers/desktop-app.js";
  2. import {
  3. waitForUpstreamNetworkCapture,
  4. waitForUpstreamNetworkRequestStarted,
  5. } from "../../../helpers/upstream-capture.js";
  6. import { ensureToolCrossProductFullAccessMode } from "../../../helpers/conversation-session-tool-cross-product.js";
  7. import {
  8. E2E_REPLY_TOKEN,
  9. clickChatStop,
  10. prepareConversationE2E,
  11. sendPrompt,
  12. waitForChatState,
  13. waitForComposerText,
  14. waitForToolCallBlockByToolCallId,
  15. } from "../../../helpers/conversation-session.js";
  16. describe("会话区 Stop Empty Queue E2E", () => {
  17. after(async () => {
  18. await browser.electron.restoreAllMocks();
  19. await clearAppData();
  20. });
  21. it("stop 后 queue=0 应退出 running,之后普通文本应立即开始下一轮", async function () {
  22. this.timeout(150000);
  23. await prepareConversationE2E();
  24. const runId = Date.now();
  25. const firstPrompt = `E2E_SLOW_STREAM E2E_STOP_EMPTY_RUNNING_${runId}: Reply with exactly "${E2E_REPLY_TOKEN}" and no other text.`;
  26. await sendPrompt(firstPrompt);
  27. await waitForComposerText("", "空队列 stop 首轮发送后输入框没有清空");
  28. await waitForChatState(
  29. (snapshot) => snapshot.state === "streaming" && snapshot.queueCount === 0,
  30. "空队列 stop 首轮没有进入 streaming",
  31. 30000,
  32. );
  33. await waitForUpstreamNetworkRequestStarted(`E2E_STOP_EMPTY_RUNNING_${runId}`);
  34. await clickChatStop();
  35. await waitForChatState(
  36. (snapshot) =>
  37. snapshot.state !== "streaming" &&
  38. snapshot.queueCount === 0 &&
  39. snapshot.runtimeStatus === "completed" &&
  40. !snapshot.stopRequested,
  41. "空队列 stop 后没有退出 running completed 态",
  42. 30000,
  43. );
  44. const nextPrompt = `E2E_STOP_EMPTY_NEXT_${runId}: Reply with exactly "${E2E_REPLY_TOKEN}" and no other text.`;
  45. await sendPrompt(nextPrompt);
  46. await waitForComposerText("", "空队列 stop 后下一轮发送没有清空输入框");
  47. await waitForUpstreamNetworkCapture(`E2E_STOP_EMPTY_NEXT_${runId}`);
  48. await waitForChatState(
  49. (snapshot) => snapshot.state === "idle" && snapshot.queueCount === 0,
  50. "空队列 stop 后下一轮没有完成并保持 queue=0",
  51. 90000,
  52. );
  53. });
  54. it("tool call 运行中 stop 后 queue=0,之后普通文本应立即开始下一轮", async function () {
  55. this.timeout(150000);
  56. await prepareConversationE2E();
  57. await ensureToolCrossProductFullAccessMode();
  58. const runId = Date.now();
  59. const toolPrompt = `E2E_STOP_EMPTY_TOOLCALL_RUNNING_${runId}: Start a long Bash tool call, then wait.`;
  60. await sendPrompt(toolPrompt);
  61. await waitForComposerText("", "toolcall stop 首轮发送后输入框没有清空");
  62. await waitForUpstreamNetworkRequestStarted(`E2E_STOP_EMPTY_TOOLCALL_RUNNING_${runId}`);
  63. await waitForToolCallBlockByToolCallId("toolu_e2e_stop_empty_toolcall_bash", 30000);
  64. await waitForChatState(
  65. (snapshot) => snapshot.state === "streaming" && snapshot.queueCount === 0,
  66. "toolcall stop 首轮没有保持 streaming 且 queue=0",
  67. 30000,
  68. );
  69. await clickChatStop();
  70. await waitForChatState(
  71. (snapshot) =>
  72. snapshot.state !== "streaming" &&
  73. snapshot.queueCount === 0 &&
  74. snapshot.runtimeStatus === "completed" &&
  75. !snapshot.stopRequested,
  76. "toolcall stop 后没有退出 running completed 态",
  77. 30000,
  78. );
  79. const nextPrompt = `E2E_STOP_EMPTY_TOOLCALL_NEXT_${runId}: Reply with exactly "${E2E_REPLY_TOKEN}" and no other text.`;
  80. await sendPrompt(nextPrompt);
  81. await waitForComposerText("", "toolcall stop 后下一轮发送没有清空输入框");
  82. await waitForUpstreamNetworkCapture(`E2E_STOP_EMPTY_TOOLCALL_NEXT_${runId}`);
  83. await waitForChatState(
  84. (snapshot) => snapshot.state === "idle" && snapshot.queueCount === 0,
  85. "toolcall stop 后下一轮没有完成并保持 queue=0",
  86. 90000,
  87. );
  88. });
  89. });