highspeedPrepareSelection.test.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { describe, expect, it } from "vitest";
  2. import { resolveHighspeedPrepareSelection } from "../src/highspeed/highspeedSend.js";
  3. describe("resolveHighspeedPrepareSelection", () => {
  4. it("prefers the submission selection so a freshly switched model drives admission", async () => {
  5. // 回归:切换模型后首次发送曾读会话投影的旧 Coding Plan 组合发起 draw,
  6. // 抽中后把用户的提交选择覆盖成卡模型(spec §3 规则 15)。
  7. const resolved = resolveHighspeedPrepareSelection({
  8. submissionSelection: {
  9. providerId: "2b05e183-7ae4-46d6-aedb-4c8f750d9811",
  10. modelId: "glm-5.3-flash-cc-highspeed",
  11. options: { reasoningLevel: "high" },
  12. },
  13. projectedConfig: { provider: "account:bigmodel-team-coding-plan", model: "GLM-5.3" },
  14. draftConfig: { provider: "account:bigmodel-team-coding-plan", model: "GLM-5.3" },
  15. });
  16. expect(resolved).toEqual({
  17. provider: "2b05e183-7ae4-46d6-aedb-4c8f750d9811",
  18. model: "glm-5.3-flash-cc-highspeed",
  19. reasoningLevel: "high",
  20. });
  21. });
  22. it("falls back per-field to projection, draft, then initial draft without a submission", () => {
  23. const resolved = resolveHighspeedPrepareSelection({
  24. projectedConfig: { model: "GLM-5.3", thought: "" },
  25. draftConfig: { provider: "account:bigmodel-team-coding-plan" },
  26. initialDraftConfig: { provider: "account:zai-team-coding-plan", model: "GLM-5.2" },
  27. });
  28. expect(resolved).toEqual({
  29. provider: "account:bigmodel-team-coding-plan",
  30. model: "GLM-5.3",
  31. });
  32. });
  33. it("resolves reasoningLevel from the submission options first, then legacy sources", () => {
  34. const fromSubmission = resolveHighspeedPrepareSelection({
  35. submissionSelection: {
  36. providerId: "account:bigmodel-team-coding-plan",
  37. modelId: "GLM-5.3",
  38. options: { reasoningLevel: "medium" },
  39. },
  40. projectedConfig: { provider: "account:bigmodel-team-coding-plan", model: "GLM-5.3", thought: "high" },
  41. });
  42. expect(fromSubmission).toEqual({
  43. provider: "account:bigmodel-team-coding-plan",
  44. model: "GLM-5.3",
  45. reasoningLevel: "medium",
  46. });
  47. const fromProjectionThought = resolveHighspeedPrepareSelection({
  48. projectedConfig: {
  49. provider: "account:bigmodel-team-coding-plan",
  50. model: "GLM-5.3",
  51. thought: "high",
  52. },
  53. draftConfig: {
  54. provider: "account:bigmodel-team-coding-plan",
  55. model: "GLM-5.3",
  56. modelSelection: { providerId: "account:bigmodel-team-coding-plan", modelId: "GLM-5.3", options: { reasoningLevel: "low" } },
  57. },
  58. });
  59. expect(fromProjectionThought?.reasoningLevel).toBe("high");
  60. });
  61. it("returns null when neither submission nor fallbacks yield a provider and model", () => {
  62. expect(
  63. resolveHighspeedPrepareSelection({ draftConfig: { provider: "account:bigmodel-team-coding-plan" } }),
  64. ).toBeNull();
  65. expect(resolveHighspeedPrepareSelection({})).toBeNull();
  66. });
  67. });