conversation-session-changes-group-unresolved-path.test.ts 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { readFile, rm } from "node:fs/promises";
  2. import { expandAssistantHistoriesWithContent } from "#e2e/helpers/conversation-session-tool-diagnostics";
  3. import { releaseControlledReplay } from "#e2e/helpers/controlled-replay";
  4. import { clearAppData, seedSettings } from "../helpers/desktop-app.js";
  5. import {
  6. toggleLatestConversationToolGroup,
  7. waitForConversationToolGroup,
  8. } from "../helpers/conversation-session-tool-groups.js";
  9. import { ensureToolCrossProductFullAccessMode } from "../helpers/conversation-session-tool-cross-product.js";
  10. import { resolveE2ERuntimePath, resolveE2EToolPath } from "../helpers/e2e-runtime-paths.js";
  11. import {
  12. E2E_REPLY_TOKEN,
  13. prepareV4ConversationE2E,
  14. sendV4Prompt,
  15. switchV4Mode,
  16. waitForV4AssistantMessageContaining,
  17. waitForV4Pane,
  18. } from "../helpers/v4-conversation.js";
  19. const CASE_NAME = "conversation-session-changes-group-unresolved-path";
  20. const CASE_MARKER = "E2E_CHANGES_GROUP_UNRESOLVED_PATH";
  21. const RUNTIME_ROOT = resolveE2ERuntimePath(CASE_NAME);
  22. const WRITE_PATH = resolveE2EToolPath(CASE_NAME, "App.tsx");
  23. describe("TGE07 Changes unresolved path and single-file summary", () => {
  24. before(async function () {
  25. this.timeout(150000);
  26. await seedSettings({ toolGroupingChangesEnabled: true });
  27. await prepareV4ConversationE2E();
  28. await switchV4Mode("yolo");
  29. });
  30. afterEach(async () => {
  31. await rm(RUNTIME_ROOT, { recursive: true, force: true });
  32. });
  33. after(async () => {
  34. await browser.electron.restoreAllMocks();
  35. await clearAppData();
  36. });
  37. it("路径未到达时显示 tool 数,展开保留 Writing;路径到达后切换文件摘要", async function () {
  38. this.timeout(180000);
  39. await ensureToolCrossProductFullAccessMode();
  40. await sendV4Prompt(
  41. `${CASE_MARKER}: Write ${WRITE_PATH}, then reply with exactly "${E2E_REPLY_TOKEN}".`,
  42. );
  43. // 当前合同仅在两个连续工具时建父组;两个 Write 指向同一文件,仍覆盖单文件摘要。
  44. const unresolved = await waitForConversationToolGroup(
  45. "ChangesGroup",
  46. (group) => group.status === "in_progress" && /2 tools|2 个工具/u.test(group.summaryText),
  47. "Changes 在 file_path 到达前没有显示 2 tools",
  48. 60000,
  49. );
  50. expect(unresolved.summaryText).not.toMatch(/0 files?|0 个文件/u);
  51. const expanded = await toggleLatestConversationToolGroup("ChangesGroup", true);
  52. expect(expanded.text).toMatch(/Writing|写入/u);
  53. // 旧时间窗口会被启动耗时吃掉;观察后才推进完整工具输入及 input_end。
  54. // input_end 保证刷新合法节流缓冲;整轮结束帧仍阻塞,不靠延时等待中间预览窗口。
  55. await releaseControlledReplay("tge07-write-controlled-stream");
  56. await waitForConversationToolGroup(
  57. "ChangesGroup",
  58. (group) =>
  59. group.status === "in_progress" &&
  60. group.expanded &&
  61. /1 file|1 个文件/u.test(group.summaryText) &&
  62. group.text.includes("App.tsx"),
  63. "file_path 到达后 Changes 展开态没有更新文件计数和 child 路径",
  64. 60000,
  65. );
  66. // 展开态按合同只显示去重文件计数;文件 chip 在收起态,不能用同一个摘要断言。
  67. await toggleLatestConversationToolGroup("ChangesGroup", false);
  68. await waitForConversationToolGroup(
  69. "ChangesGroup",
  70. (group) => group.status === "in_progress" && group.summaryText.includes("App.tsx"),
  71. "file_path 到达后 Changes 收起态没有显示文件摘要",
  72. );
  73. await releaseControlledReplay("tge07-write-controlled-stream");
  74. await waitForV4AssistantMessageContaining(E2E_REPLY_TOKEN, 120000);
  75. await waitForV4Pane((snapshot) => !snapshot.canStop, "TGE07 工具轮没有结束", 120000);
  76. expect(await readFile(WRITE_PATH, "utf8")).toBe("export const app = true;\n");
  77. // 最终回复会收起工具历史;先走真实历史展开入口,再检查完成态摘要。
  78. await expandAssistantHistoriesWithContent();
  79. const collapsed = await toggleLatestConversationToolGroup("ChangesGroup", false);
  80. expect(collapsed.summaryText).toContain("App.tsx");
  81. expect(collapsed.summaryText).not.toMatch(/1 file|1 个文件/u);
  82. });
  83. });