conversation-session-v4-model-switch.test.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // M4 门禁:switchModelConfig(v4 控制条模型配置表单)。
  2. // 证据层 L3:建立 session → 填 provider/model/thought 应用 → switchModelConfig 命令 →
  3. // v4-bridge → app.setModel + emitModelSelected → ModelSelected 事件 → reducer onModelSelected →
  4. // config.provider/model/thought 更新(首次选型不产 marker)→ 控制条 data-* 同步。
  5. // 证明模型切换全链路(ModelSelected 补发 + config 投影 + 通用配置表单 UI)。
  6. import { clearAppData } from "../helpers/desktop-app.js";
  7. import {
  8. UPSTREAM_MODEL,
  9. UPSTREAM_PROVIDER_ID,
  10. } from "../helpers/upstream-provider.js";
  11. import {
  12. getV4ModelConfig,
  13. prepareV4ConversationE2E,
  14. sendV4Prompt,
  15. switchV4Model,
  16. waitForV4Pane,
  17. waitForV4TimelineContaining,
  18. } from "../helpers/v4-conversation.js";
  19. describe("v4 M4 门禁:switchModelConfig", () => {
  20. after(async () => {
  21. await browser.electron.restoreAllMocks();
  22. await clearAppData();
  23. });
  24. it("建立 session → 应用模型配置(thought=max)→ config 投影更新", async () => {
  25. await prepareV4ConversationE2E();
  26. await sendV4Prompt("E2E_V4_MODEL_SWITCH_SEED 建立会话");
  27. await waitForV4TimelineContaining("V4_MODEL_SWITCH_SEED_OK", 45000);
  28. await waitForV4Pane(
  29. (s) => s.sessionId !== "draft" && s.sessionId !== null,
  30. "会话没有建立",
  31. 45000,
  32. );
  33. // 切换到已注册的当前模型 + thought=max(保证 setModel 目录解析成功)
  34. await switchV4Model(UPSTREAM_PROVIDER_ID, UPSTREAM_MODEL, "max");
  35. // config 投影更新为目标值
  36. await browser.waitUntil(
  37. async () => {
  38. const cfg = await getV4ModelConfig();
  39. return cfg.model === UPSTREAM_MODEL && cfg.thought === "max";
  40. },
  41. { timeout: 30000, timeoutMsg: "模型 config 没有更新为目标值" },
  42. );
  43. const cfg = await getV4ModelConfig();
  44. expect(cfg.provider).toBe(UPSTREAM_PROVIDER_ID);
  45. expect(cfg.model).toBe(UPSTREAM_MODEL);
  46. expect(cfg.thought).toBe("max");
  47. });
  48. });