Files
PaperClipAI/server/src/services/onboarding-models.test.ts
T
Devin FoleyandPaperclip 6e340a3f96 Verify onboarding models and explain provider failures (#23563)
Verify deployment-configured model preferences with the selected account.
Preserve structured provider failures and show descriptive messages for known
causes through the existing onboarding error display. Keep the existing failure
buttons, account binding, and retry/sign-in behavior.

Validation: UI typecheck, 38 focused tests, four browser journeys, all applicable
CI checks, and Greptile 5/5 with no unresolved review comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-12-02 16:47:58 -08:00

17 lines
981 B
TypeScript

import { expect, it } from "vitest";
import { onboardingModels } from "./onboarding-models.js";
it("leaves deployments without preferences on their normal adapter defaults", () => {
expect(onboardingModels({})).toEqual({});
});
it("reads fresh deployment preferences without provider or plan policy in Core", () => {
const env = { PAPERCLIP_ONBOARDING_MODELS: '{"example_local":["preferred","backup","preferred"]}' };
expect(onboardingModels(env)).toEqual({ example_local: ["preferred", "backup"] });
env.PAPERCLIP_ONBOARDING_MODELS = '{"example_local":["replacement"]}';
expect(onboardingModels(env)).toEqual({ example_local: ["replacement"] });
});
it.each(["null", "[]", "invalid", '{"adapter":[]}', '{"adapter":[1]}', '{"adapter":["https://private.example"]}',
'{"adapter":["one","two","three","four"]}', " ".repeat(8193)])("rejects malformed or unbounded preferences %#", raw => {
expect(onboardingModels({ PAPERCLIP_ONBOARDING_MODELS: raw })).toEqual({});
});