conversation-session-highspeed-queue-edit.test.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { TID_CHAT_ERROR_BANNER } from "@zcode/shared/test-ids";
  2. import { clearAppData } from "#e2e/helpers/desktop-app";
  3. import { prepareHighspeedDrawWorkspace } from "#e2e/helpers/highspeed-card";
  4. import { E2E_BIGMODEL_PLAN_PROVIDER_ID } from "#e2e/helpers/model-provider-restart";
  5. import {
  6. clickV4QueueItemDelete,
  7. clickV4Stop,
  8. getV4ComposerText,
  9. getV4ModelConfig,
  10. getV4QueueItems,
  11. sendV4Prompt,
  12. waitForV4Pane,
  13. waitForV4QueueCount,
  14. waitForV4TimelineContaining,
  15. } from "#e2e/helpers/v4-conversation";
  16. import {
  17. openV4QueueItemEditInComposer,
  18. waitForV4ComposerEditClosed,
  19. } from "#e2e/helpers/v4-composer-edit";
  20. const RUNNING_PROMPT = "E2E_HIGHSPEED_QUEUE_EDIT_SLOW keep running";
  21. const QUEUED_PROMPT = "E2E_HIGHSPEED_QUEUE_EDIT_PENDING original";
  22. const RESUBMITTED_PROMPT = "E2E_HIGHSPEED_QUEUE_EDIT_RESUBMITTED changed";
  23. const RUNNING_REPLY_TOKEN = "HIGHSPEED_QUEUE_EDIT_STREAMING";
  24. const INTERNAL_HIGHSPEED_PROVIDER = "account:bigmodel-highspeed-card";
  25. // Host Mock 场景:hit-queue-edit(按 spec 文件注入,见 helpers/highspeed-mock-env.ts)。
  26. describe("Highspeed queued prompt edit E2E", () => {
  27. afterEach(async () => {
  28. const queued = await getV4QueueItems();
  29. for (const item of queued) {
  30. await clickV4QueueItemDelete(item.queueItemId);
  31. }
  32. if (queued.length > 0) await waitForV4QueueCount(0, 30000);
  33. const pane = await waitForV4Pane(() => true, "无法读取 Highspeed queue pane");
  34. if (pane.canStop) {
  35. await clickV4Stop();
  36. await waitForV4Pane((snapshot) => !snapshot.canStop, "Highspeed queue 收尾 stop 未完成");
  37. }
  38. });
  39. after(async () => {
  40. await browser.electron.restoreAllMocks();
  41. await clearAppData();
  42. });
  43. it("HS-E2E-06: 编辑 Highspeed 队列输入时工具栏载入普通模型,修改后原地替换", async function () {
  44. this.timeout(180000);
  45. await prepareHighspeedDrawWorkspace();
  46. await sendV4Prompt(RUNNING_PROMPT);
  47. await waitForV4TimelineContaining(RUNNING_REPLY_TOKEN, 45000);
  48. await waitForV4Pane(
  49. (snapshot) => snapshot.canStop,
  50. "首轮 Highspeed 输入没有保持 running",
  51. 45000,
  52. );
  53. await sendV4Prompt(QUEUED_PROMPT);
  54. await waitForV4QueueCount(1, 30000);
  55. const [queued] = await getV4QueueItems();
  56. expect(queued?.text).toContain(QUEUED_PROMPT);
  57. if (!queued) throw new Error("Highspeed 队列项不存在");
  58. await openV4QueueItemEditInComposer(queued.queueItemId);
  59. expect(await getV4QueueItems()).toHaveLength(1);
  60. await browser.waitUntil(async () => (await getV4ComposerText()) === QUEUED_PROMPT, {
  61. timeout: 30000,
  62. timeoutMsg: "Highspeed 队列项没有载入 Composer 编辑态",
  63. });
  64. // Bug 根因:旧 QueueItem 保存单轮 Highspeed Selection,编辑时把隐藏 Provider
  65. // 载入 Composer,会污染修改后提交的 fallback。工具栏只能载入队列项的普通模型。
  66. expect(await getV4ModelConfig()).toMatchObject({
  67. provider: E2E_BIGMODEL_PLAN_PROVIDER_ID,
  68. });
  69. await sendV4Prompt(RESUBMITTED_PROMPT);
  70. await waitForV4ComposerEditClosed("Highspeed 队列项编辑提交后没有退出编辑态", 30000);
  71. await browser.waitUntil(
  72. async () => ((await getV4QueueItems())[0]?.text ?? "").includes(RESUBMITTED_PROMPT),
  73. { timeout: 30000, timeoutMsg: "Highspeed 队列项没有原地替换" },
  74. );
  75. const [resubmitted] = await getV4QueueItems();
  76. expect(resubmitted?.queueItemId).toBe(queued.queueItemId);
  77. expect((await getV4ModelConfig()).provider).not.toBe(INTERNAL_HIGHSPEED_PROVIDER);
  78. const errorBanner = $(`[data-testid="${TID_CHAT_ERROR_BANNER}"]`);
  79. expect(await errorBanner.isExisting()).toBe(false);
  80. expect((await $("body").getText()).includes(INTERNAL_HIGHSPEED_PROVIDER)).toBe(false);
  81. });
  82. });