conversation-session-v4-sendnow.test.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // M4 门禁:sendQueuedNow(catalog B 组)。
  2. // 证据层 L3:running turn 期间入队一项 → 点「立即发送」→ sendQueuedNow 命令 →
  3. // v4-bridge:读原文 → 从 queue 移除 → stop 当前 turn → 以原文重发(stop barrier)→
  4. // 该项以新 turn 消费,回复出现。证明 stop-barrier + 立即消费全链路。
  5. import { clearAppData } from "#e2e/helpers/desktop-app";
  6. import {
  7. clickV4QueueItemSendNow,
  8. getV4QueueItems,
  9. prepareV4ConversationE2E,
  10. sendV4Prompt,
  11. waitForV4Pane,
  12. waitForV4QueueCount,
  13. waitForV4TimelineContaining,
  14. } from "#e2e/helpers/v4-conversation";
  15. describe("v4 M4 门禁:sendQueuedNow", () => {
  16. after(async () => {
  17. await browser.electron.restoreAllMocks();
  18. await clearAppData();
  19. });
  20. it("running 中入队 → 立即发送 → stop 当前 + 该项以新 turn 消费", async () => {
  21. await prepareV4ConversationE2E();
  22. await sendV4Prompt("E2E_V4_SENDNOW_SLOW 慢慢回答");
  23. await waitForV4TimelineContaining("V4_SENDNOW_STREAMING", 45000);
  24. await waitForV4Pane(
  25. (s) => s.canStop && s.sessionId !== "draft" && s.sessionId !== null,
  26. "首轮没有进入 running(canStop)",
  27. 45000,
  28. );
  29. await sendV4Prompt("E2E_V4_SENDNOW_ITEM 立即发我");
  30. await waitForV4QueueCount(1, 30000);
  31. const before = await getV4QueueItems();
  32. const queueItemId = before[0]!.queueItemId;
  33. // 立即发送该队列项 → stop 当前 + 消费该项
  34. const clicked = await clickV4QueueItemSendNow(queueItemId);
  35. expect(clicked).toBe(true);
  36. // 队列清空(该项被消费)+ 该项回复出现
  37. await waitForV4QueueCount(0, 30000);
  38. await waitForV4TimelineContaining("V4_SENDNOW_ITEM_REPLY", 60000);
  39. expect(await getV4QueueItems()).toHaveLength(0);
  40. });
  41. });