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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { readFile, rm } from "node:fs/promises";
  2. import { clearAppData, seedSettings } from "../../../helpers/desktop-app.js";
  3. import {
  4. toggleLatestConversationToolGroup,
  5. waitForConversationToolGroup,
  6. } from "../../../helpers/conversation-session-tool-groups.js";
  7. import { ensureToolCrossProductFullAccessMode } from "../../../helpers/conversation-session-tool-cross-product.js";
  8. import {
  9. resolveE2ERuntimePath,
  10. resolveE2EToolPath,
  11. } from "../../../helpers/e2e-runtime-paths.js";
  12. import {
  13. E2E_REPLY_TOKEN,
  14. prepareV4ConversationE2E,
  15. sendV4Prompt,
  16. switchV4Mode,
  17. waitForV4AssistantMessageContaining,
  18. waitForV4Pane,
  19. } from "../../../helpers/v4-conversation.js";
  20. const CASE_NAME = "conversation-session-changes-group-unresolved-path";
  21. const CASE_MARKER = "E2E_CHANGES_GROUP_UNRESOLVED_PATH";
  22. const RUNTIME_ROOT = resolveE2ERuntimePath(CASE_NAME);
  23. const WRITE_PATH = resolveE2EToolPath(CASE_NAME, "App.tsx");
  24. describe("TGE07 Changes unresolved path and single-file summary", () => {
  25. before(async function () {
  26. this.timeout(150000);
  27. await seedSettings({ toolGroupingChangesEnabled: true });
  28. await prepareV4ConversationE2E();
  29. await switchV4Mode("yolo");
  30. });
  31. afterEach(async () => {
  32. await rm(RUNTIME_ROOT, { recursive: true, force: true });
  33. });
  34. after(async () => {
  35. await browser.electron.restoreAllMocks();
  36. await clearAppData();
  37. });
  38. it("路径未到达时显示 tool 数,展开保留 Writing;路径到达后切换文件摘要", async function () {
  39. this.timeout(180000);
  40. await ensureToolCrossProductFullAccessMode();
  41. await sendV4Prompt(
  42. `${CASE_MARKER}: Write ${WRITE_PATH}, then reply with exactly "${E2E_REPLY_TOKEN}".`,
  43. );
  44. const unresolved = await waitForConversationToolGroup(
  45. "ChangesGroup",
  46. (group) =>
  47. group.status === "in_progress" &&
  48. /1 tool|1 个工具/u.test(group.summaryText),
  49. "Changes 在 file_path 到达前没有显示 1 tool",
  50. 60000,
  51. );
  52. expect(unresolved.summaryText).not.toMatch(/0 files?|0 个文件/u);
  53. const expanded = await toggleLatestConversationToolGroup(
  54. "ChangesGroup",
  55. true,
  56. );
  57. expect(expanded.text).toMatch(/Writing|写入/u);
  58. await waitForConversationToolGroup(
  59. "ChangesGroup",
  60. (group) =>
  61. group.status === "in_progress" && group.summaryText.includes("App.tsx"),
  62. "file_path 到达后 Changes 没有切换为文件摘要",
  63. 60000,
  64. );
  65. await waitForV4AssistantMessageContaining(E2E_REPLY_TOKEN, 120000);
  66. await waitForV4Pane(
  67. (snapshot) => !snapshot.canStop,
  68. "TGE07 工具轮没有结束",
  69. 120000,
  70. );
  71. expect(await readFile(WRITE_PATH, "utf8")).toBe(
  72. "export const app = true;\n",
  73. );
  74. const collapsed = await toggleLatestConversationToolGroup(
  75. "ChangesGroup",
  76. false,
  77. );
  78. expect(collapsed.summaryText).toContain("App.tsx");
  79. expect(collapsed.summaryText).not.toMatch(/1 file|1 个文件/u);
  80. });
  81. });