conversation-session-v4-vertical-slice.test.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // M3 竖切出口门禁(docs/v4-refactor/08-phasing.md M3):
  2. // 单 pane「订阅 → 渲染 → 发送 → agent 输出中刷新恢复 → stop」全链路。
  3. // 证据层:L3(13-golden-test-mapping —— A 组 composer 冒烟 + B 组 stop 按钮态 + 刷新恢复跨进程链路)。
  4. // 状态语义的完整覆盖在 L1 reducer 黄金测试,这里只断言真实 UI 交互与跨进程恢复。
  5. import { clearAppData } from "../helpers/desktop-app.js";
  6. import {
  7. clickV4Stop,
  8. getV4PaneSnapshot,
  9. prepareV4ConversationE2E,
  10. sendV4Prompt,
  11. waitForV4Pane,
  12. waitForV4TimelineContaining,
  13. } from "../helpers/v4-conversation.js";
  14. describe("v4 竖切 M3 门禁:订阅→渲染→发送→刷新恢复→stop", () => {
  15. after(async () => {
  16. await browser.electron.restoreAllMocks();
  17. await clearAppData();
  18. });
  19. it("单 pane 全链路(含 agent 输出中刷新恢复)", async () => {
  20. await prepareV4ConversationE2E();
  21. // ── 发送(draft 首发 createSession + sendText)──
  22. await sendV4Prompt("E2E_V4_SLICE_TURN1 请慢慢回答");
  23. const bound = await waitForV4Pane(
  24. (snapshot) => snapshot.sessionId !== "draft" && snapshot.sessionId !== null,
  25. "首发后 pane 没有绑定到新 session",
  26. 45000,
  27. );
  28. const sessionId = bound.sessionId;
  29. // ── 渲染:用户行 + assistant 流式行 ──
  30. await waitForV4TimelineContaining("E2E_V4_SLICE_TURN1");
  31. await waitForV4TimelineContaining("V4_TURN1_STREAMING", 45000);
  32. await waitForV4Pane(
  33. (snapshot) => snapshot.canStop,
  34. "streaming 中没有出现 stop 按钮",
  35. );
  36. // ── agent 输出中刷新(M3 门禁核心:renderer 重载,CLI/host 继续跑)──
  37. await browser.refresh();
  38. await waitForV4Pane(
  39. (snapshot) => snapshot.sessionId === sessionId,
  40. "刷新后 pane 没有恢复到原 session",
  41. 60000,
  42. );
  43. // 恢复裁决 snapshot + 续流:历史行 + 完流文本都必须出现
  44. await waitForV4TimelineContaining("E2E_V4_SLICE_TURN1", 30000);
  45. await waitForV4TimelineContaining("V4_TURN1_DONE", 60000);
  46. await waitForV4Pane(
  47. (snapshot) => !snapshot.canStop,
  48. "turn1 完流后 stop 按钮没有回收",
  49. );
  50. // ── stop:turn2 长尾慢流窗口内点 stop ──
  51. await sendV4Prompt("E2E_V4_SLICE_TURN2 保持输出");
  52. await waitForV4TimelineContaining("V4_TURN2_STREAMING", 45000);
  53. await waitForV4Pane(
  54. (snapshot) => snapshot.canStop,
  55. "turn2 streaming 中没有出现 stop 按钮",
  56. );
  57. await clickV4Stop();
  58. await waitForV4Pane(
  59. (snapshot) => !snapshot.canStop,
  60. "stop 后 canStop 没有回收",
  61. 30000,
  62. );
  63. // 已流出的部分文本保留(中断不清空 timeline)
  64. const finalSnapshot = await getV4PaneSnapshot();
  65. expect(finalSnapshot.timelineText).toContain("V4_TURN2_STREAMING");
  66. expect(finalSnapshot.sessionId).toBe(sessionId);
  67. });
  68. });