conversation-session-v4-sidebar.test.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // 通过侧栏现有入口操作,验证真实标题投影或归档后的永久删除。
  2. import { TID_TASK_ITEM } from "@zcode/shared/test-ids";
  3. import { clearAppData } from "#e2e/helpers/desktop-app";
  4. import {
  5. clickV4DeleteSession,
  6. getV4PaneSnapshot,
  7. getV4SessionTitle,
  8. prepareV4ConversationE2E,
  9. renameV4Session,
  10. sendV4Prompt,
  11. waitForV4Pane,
  12. waitForV4TimelineContaining,
  13. } from "#e2e/helpers/v4-conversation";
  14. async function sidebarTaskItemText(sessionId: string): Promise<string | null> {
  15. return browser.execute(
  16. (itemTestId, id) => {
  17. const el = document.querySelector(`[data-testid="${itemTestId}-${id}"]`);
  18. return el ? (el.textContent ?? "") : null;
  19. },
  20. TID_TASK_ITEM,
  21. sessionId,
  22. );
  23. }
  24. describe("v4 M5 ② 门禁:侧栏列表数据源 sessions-index(建→现→改名→更新→删→消失)", () => {
  25. after(async () => {
  26. await browser.electron.restoreAllMocks();
  27. await clearAppData();
  28. });
  29. it("建会话 → 侧栏出现 → 改名 → 侧栏更新 → 删除 → 侧栏消失", async () => {
  30. await prepareV4ConversationE2E();
  31. await sendV4Prompt("E2E_V4_SIDEBAR_SEED 建立会话");
  32. await waitForV4TimelineContaining("V4_SIDEBAR_SEED_OK", 45000);
  33. await waitForV4Pane(
  34. (s) => s.sessionId !== "draft" && s.sessionId !== null,
  35. "会话没有建立",
  36. 45000,
  37. );
  38. const sessionId = (await getV4PaneSnapshot()).sessionId as string;
  39. // 1) 建会话 → 侧栏 task 列表出现该会话(sessions-index snapshot/upsert)。
  40. await browser.waitUntil(async () => (await sidebarTaskItemText(sessionId)) !== null, {
  41. timeout: 30000,
  42. timeoutMsg: "侧栏 task 列表没有出现新建会话",
  43. });
  44. // 2) 重命名 → sessions-index.title 权威 → 侧栏标题跟随更新。
  45. const customTitle = "E2E_V4_SIDEBAR_RENAMED";
  46. await renameV4Session(customTitle);
  47. await browser.waitUntil(async () => (await getV4SessionTitle()) === customTitle, {
  48. timeout: 30000,
  49. timeoutMsg: "会话标题没有更新为自定义值",
  50. });
  51. await browser.waitUntil(
  52. async () => {
  53. const text = await sidebarTaskItemText(sessionId);
  54. return text !== null && text.includes(customTitle);
  55. },
  56. { timeout: 30000, timeoutMsg: "侧栏 task 项没有跟随重命名更新标题" },
  57. );
  58. // 3) 删除 → session.removed delta → 侧栏消失。
  59. await clickV4DeleteSession();
  60. await browser.waitUntil(async () => (await sidebarTaskItemText(sessionId)) === null, {
  61. timeout: 30000,
  62. timeoutMsg: "删除后侧栏 task 项没有消失",
  63. });
  64. });
  65. });