| import { describe, expect, it } from "vitest"; |
|
|
| import { DEFAULT_SETTINGS, sanitizeSettings } from "../settings"; |
| import { buildOptionsSnapshot } from "../lib/analysisClient"; |
|
|
| describe("web settings defaults", () => { |
| it("defaults polish to browser direct and analysis to backend queue", () => { |
| expect(DEFAULT_SETTINGS.polishTransport).toBe("browser"); |
| expect(DEFAULT_SETTINGS.analysisTransport).toBe("backend"); |
| expect(DEFAULT_SETTINGS.apiMode).toBe("chat"); |
| expect(DEFAULT_SETTINGS.baseURL).toBe("https://api.deepseek.com"); |
| expect(DEFAULT_SETTINGS.modelPreset).toBe("deepseek-v4-pro"); |
| }); |
|
|
| it("normalizes old or unexpected analysis transports back to backend", () => { |
| const settings = sanitizeSettings({ |
| analysisTransport: "browser" as never, |
| polishTransport: "backend" as never, |
| modelPreset: "deepseek-v4-pro", |
| }); |
|
|
| expect(settings.analysisTransport).toBe("backend"); |
| expect(settings.polishTransport).toBe("browser"); |
| }); |
|
|
| it("stores reusable browser model credentials", () => { |
| const settings = sanitizeSettings({ |
| savedModelCredentials: [ |
| { id: "deepseek", name: "DeepSeek", baseURL: "https://api.deepseek.com", apiKey: "key-1" }, |
| { id: "empty", name: "Empty", baseURL: "", apiKey: "" }, |
| ], |
| selectedModelCredentialId: "deepseek", |
| }); |
|
|
| expect(settings.savedModelCredentials).toEqual([ |
| { id: "deepseek", name: "DeepSeek", baseURL: "https://api.deepseek.com", apiKey: "key-1" }, |
| ]); |
| expect(settings.selectedModelCredentialId).toBe("deepseek"); |
| }); |
|
|
| it("builds backend analysis options without browser-only transport fields", () => { |
| const snapshot = buildOptionsSnapshot(DEFAULT_SETTINGS, { |
| kind: "api", |
| optimizeTask: true, |
| strictFullMarks: false, |
| ignoreTaskComplexityForFullMarks: false, |
| feedback: "focus on channel state", |
| }); |
|
|
| expect(snapshot).toMatchObject({ |
| requestedMode: "api", |
| model: "deepseek-v4-pro", |
| baseURL: "https://api.deepseek.com", |
| apiMode: "chat", |
| feedback: "focus on channel state", |
| }); |
| expect(snapshot).not.toHaveProperty("polishTransport"); |
| expect(snapshot).not.toHaveProperty("analysisTransport"); |
| expect(snapshot).not.toHaveProperty("streaming"); |
| }); |
|
|
| it("clamps backend analysis numeric options before sending", () => { |
| const snapshot = buildOptionsSnapshot( |
| { |
| ...DEFAULT_SETTINGS, |
| concurrency: 99, |
| temperature: 9, |
| topP: 9, |
| maxTokens: 999999, |
| }, |
| { |
| kind: "api", |
| optimizeTask: true, |
| strictFullMarks: false, |
| ignoreTaskComplexityForFullMarks: false, |
| feedback: "", |
| }, |
| ); |
|
|
| expect(snapshot).toMatchObject({ |
| concurrency: 8, |
| temperature: 2, |
| topP: 1, |
| maxTokens: 131072, |
| }); |
| }); |
| }); |
|
|