Files
oh-my-pi/packages/coding-agent/test/config/models-config-validation.test.ts
can1357 3566bd9b41 fix(ai): unified Cursor interaction-query handling after merging #8889 and #8830
- Kept the shared cursor/interaction-query module as the single handler and deleted the duplicate local implementation in cursor.ts
- Added the named webFetchRequestQuery approval case (field 9 is named under the regenerated proto)
- Preserved the deliberate no-fake-VM-success semantics for setupVmEnvironmentArgs (review of #8047)
- Updated the field-9 regression test to assert the named decode of the raw same-field reply, which also pins the LEN-prefix wire framing
2026-08-19 01:47:20 +02:00

36 lines
1.3 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { validateProviderConfiguration } from "@oh-my-pi/pi-coding-agent/config/models-config";
const models = [{ id: "grok-4", api: "openai-completions" as const }];
const baseUrl = "https://api.example.invalid/v1";
describe("validateProviderConfiguration (models-config auth)", () => {
test("auth: oauth allows custom models without apiKey", () => {
expect(() =>
validateProviderConfiguration("xai-oauth", { baseUrl, auth: "oauth", models }, "models-config"),
).not.toThrow();
});
test("auth: none allows custom models without apiKey", () => {
expect(() =>
validateProviderConfiguration("local", { baseUrl, auth: "none", models }, "models-config"),
).not.toThrow();
});
test("default auth (apiKey) still requires apiKey for custom models", () => {
expect(() => validateProviderConfiguration("custom", { baseUrl, models }, "models-config")).toThrow(
'Provider custom: "apiKey" is required when defining custom models unless auth is "none" or "oauth".',
);
});
test("explicit auth: apiKey with apiKey set passes", () => {
expect(() =>
validateProviderConfiguration(
"custom",
{ baseUrl, auth: "apiKey", apiKey: "sk-test", models },
"models-config",
),
).not.toThrow();
});
});