conversation-session-highspeed-card-fallback-unlocks-model.test.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { TID_CHAT_ERROR_BANNER, TID_CHAT_MODEL_SELECT_TRIGGER } from "@zcode/shared/test-ids";
  2. import { clearAppData } from "#e2e/helpers/desktop-app";
  3. import { waitForToastContaining } from "#e2e/helpers/conversation-session-toast";
  4. import {
  5. prepareHighspeedDrawWorkspace,
  6. startHighspeedComposerProbe,
  7. takeHighspeedComposerProbe,
  8. waitForHighspeedComposerCleared,
  9. } from "#e2e/helpers/highspeed-card";
  10. import {
  11. sendV4Prompt,
  12. waitForV4Pane,
  13. waitForV4TimelineContaining,
  14. } from "#e2e/helpers/v4-conversation";
  15. // Host Mock 场景:hit-invalid-model(按 spec 文件注入,见 helpers/highspeed-mock-env.ts)。
  16. const FALLBACK_REPLY_TOKEN = "hs-invalid-model-fallback-done";
  17. const FALLBACK_TOAST = "加速服务暂不可用,本轮后续内容将使用原模型继续生成";
  18. describe("Highspeed card fallback unlock E2E", () => {
  19. after(async () => {
  20. await browser.electron.restoreAllMocks();
  21. await clearAppData();
  22. });
  23. it("HS-E2E-05: 加速模型不在目录时自动退回原模型并解锁模型选择", async function () {
  24. this.timeout(180000);
  25. await prepareHighspeedDrawWorkspace();
  26. // 创建期退回可能很快完成。发送前安装属性探针,避免只在最终状态采样而漏掉中途加速态。
  27. await startHighspeedComposerProbe();
  28. await sendV4Prompt(
  29. "E2E_HIGHSPEED_INVALID_MODEL_FALLBACK: reply with the fixed fallback token.",
  30. );
  31. await waitForToastContaining(FALLBACK_TOAST, "Highspeed 创建失败后没有显示一次降级提示");
  32. await waitForV4TimelineContaining(FALLBACK_REPLY_TOKEN);
  33. await waitForV4Pane(
  34. (snapshot) => !snapshot.canStop && snapshot.timelineText.includes(FALLBACK_REPLY_TOKEN),
  35. "退回原模型后本轮没有正常完成",
  36. 90000,
  37. );
  38. expect(await takeHighspeedComposerProbe()).toBe(true);
  39. await waitForHighspeedComposerCleared("退回原模型后输入框仍处于 Highspeed 状态");
  40. expect(await $(`[data-testid="${TID_CHAT_ERROR_BANNER}"]`).isExisting()).toBe(false);
  41. const modelTrigger = $(`[data-testid="${TID_CHAT_MODEL_SELECT_TRIGGER}"]`);
  42. await modelTrigger.waitForExist({ timeout: 15000 });
  43. expect(await modelTrigger.isEnabled()).toBe(true);
  44. expect(await modelTrigger.getAttribute("aria-disabled")).not.toBe("true");
  45. await modelTrigger.click();
  46. await browser.waitUntil(
  47. async () => (await modelTrigger.getAttribute("aria-expanded")) === "true",
  48. { timeout: 15000, timeoutMsg: "Highspeed 退回后模型选择器仍无法打开" },
  49. );
  50. await browser.keys("Escape");
  51. });
  52. });