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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "#e2e/helpers/desktop-app";
  6. import {
  7. clickV4Stop,
  8. getV4PaneSnapshot,
  9. prepareV4ConversationE2E,
  10. sendV4Prompt,
  11. waitForV4Pane,
  12. waitForV4TimelineContaining,
  13. } from "#e2e/helpers/v4-conversation";
  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((snapshot) => snapshot.canStop, "streaming 中没有出现 stop 按钮");
  33. // ── agent 输出中刷新(M3 门禁核心:renderer 重载,CLI/host 继续跑)──
  34. await browser.refresh();
  35. await waitForV4Pane(
  36. (snapshot) => snapshot.sessionId === sessionId,
  37. "刷新后 pane 没有恢复到原 session",
  38. 60000,
  39. );
  40. // 恢复裁决 snapshot + 续流:历史行 + 完流文本都必须出现
  41. await waitForV4TimelineContaining("E2E_V4_SLICE_TURN1", 30000);
  42. await waitForV4TimelineContaining("V4_TURN1_DONE", 60000);
  43. await waitForV4Pane((snapshot) => !snapshot.canStop, "turn1 完流后 stop 按钮没有回收");
  44. // ── stop:turn2 长尾慢流窗口内点 stop ──
  45. await sendV4Prompt("E2E_V4_SLICE_TURN2 保持输出");
  46. await waitForV4TimelineContaining("V4_TURN2_STREAMING", 45000);
  47. await waitForV4Pane((snapshot) => snapshot.canStop, "turn2 streaming 中没有出现 stop 按钮");
  48. await clickV4Stop();
  49. await waitForV4Pane((snapshot) => !snapshot.canStop, "stop 后 canStop 没有回收", 30000);
  50. // 已流出的部分文本保留(中断不清空 timeline)
  51. const finalSnapshot = await getV4PaneSnapshot();
  52. expect(finalSnapshot.timelineText).toContain("V4_TURN2_STREAMING");
  53. expect(finalSnapshot.sessionId).toBe(sessionId);
  54. });
  55. });