Q168: a connected provider's default model changes without its credential
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
26c3365896
commit
5cd413ffcf
12 files changed
+130
-2
No files matched your search
@@ -195,6 +195,23 @@ test("onboards, hires, and creates work in the Electron shell", async () => {
|
||||
await page.getByRole("button", { name: "Save OpenAI policy" }).click();
|
||||
await expect(page.getByText("0 / 25").first()).toBeVisible();
|
||||
|
||||
// Changing only the default model asks for no key and keeps the sign-in.
|
||||
const changeModel = async (pick: (options: string[]) => string) => {
|
||||
await page.getByRole("button", { name: "Change model" }).first().click();
|
||||
const modelSelect = page.locator(".modal select[name=model]");
|
||||
const options = await modelSelect.locator("option").evaluateAll((nodes) => nodes.map((node) => (node as HTMLOptionElement).value));
|
||||
const chosen = pick(options);
|
||||
await modelSelect.selectOption(chosen);
|
||||
await expect(page.locator(".modal input[type=password]")).toHaveCount(0);
|
||||
await page.locator(".modal").getByRole("button", { name: "Save" }).click();
|
||||
await expect(page.locator(".modal")).toHaveCount(0);
|
||||
return chosen;
|
||||
};
|
||||
const otherModel = await changeModel((options) => options.find((option) => option !== "gpt-5.4") ?? "");
|
||||
await expect(page.getByText(`${otherModel} · API key`).first()).toBeVisible();
|
||||
await changeModel(() => "gpt-5.4");
|
||||
await expect(page.getByText("gpt-5.4 · API key").first()).toBeVisible();
|
||||
|
||||
// Skills are built-in now: no Skills tab exists, yet the bundled
|
||||
// catalogue imported itself during onboarding.
|
||||
await expect(page.getByRole("button", { name: "Skills" })).toHaveCount(0);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { DatabaseConnection } from "../../src/main/database/connection";
|
||||
import { OrganizationService } from "../../src/main/services/organization-service";
|
||||
import { ProviderService } from "../../src/main/services/provider-service";
|
||||
import { providerAdapters } from "../../src/main/services/provider-adapters";
|
||||
import { setProviderModel } from "../../src/main/services/provider-default-model";
|
||||
|
||||
const vault = { encryptSecret: (secret: string) => Buffer.from(secret, "utf8"), decryptSecret: (ciphertext: Buffer) => ciphertext.toString("utf8") };
|
||||
|
||||
describe("changing a connected provider's default model", () => {
|
||||
test("changes only the model: the credential, its sign-in and its health stay as they were", () => {
|
||||
const connection = new DatabaseConnection(join(tmpdir(), `ac-default-model-${randomUUID()}.db`));
|
||||
const db = connection.db;
|
||||
const providers = new ProviderService(db, providerAdapters, vault);
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = new OrganizationService(db).createOrganization({ organizationName: "Acme", employeeName: "Dana", mission: "m", goal: "g" });
|
||||
});
|
||||
const idOf = (key: string) => (db.prepare("select id from providers where org_id = ? and provider_key = ?").get(orgId, key) as { id: string }).id;
|
||||
const openai = idOf("openai");
|
||||
providers.saveCredential({ orgId, providerId: openai, secret: "sk-test", model: "gpt-5.4" });
|
||||
db.prepare("update providers set health_state = 'healthy' where id = ?").run(openai);
|
||||
const before = db.prepare("select credential_id, auth_state, health_state from providers where id = ?").get(openai);
|
||||
|
||||
setProviderModel(db, { orgId, providerId: openai, model: " gpt-6 " });
|
||||
expect(db.prepare("select model from providers where id = ?").get(openai)).toEqual({ model: "gpt-6" });
|
||||
expect(db.prepare("select credential_id, auth_state, health_state from providers where id = ?").get(openai)).toEqual(before);
|
||||
expect(db.prepare("select action, payload_json from audit_events where entity_id = ? and action = 'default_model_changed'").get(openai))
|
||||
.toEqual({ action: "default_model_changed", payload_json: JSON.stringify({ from: "gpt-5.4", to: "gpt-6" }) });
|
||||
|
||||
expect(() => setProviderModel(db, { orgId, providerId: openai, model: " " })).toThrow("Name the default model.");
|
||||
expect(() => setProviderModel(db, { orgId, providerId: idOf("anthropic"), model: "claude" })).toThrow("Connect this provider first; its default model is set when it connects.");
|
||||
db.prepare("update providers set credential_id = (select credential_id from providers where id = ?), auth_state = 'configured' where id = ?").run(openai, idOf("azure-openai"));
|
||||
expect(() => setProviderModel(db, { orgId, providerId: idOf("azure-openai"), model: "gpt-6" }))
|
||||
.toThrow("Azure OpenAI calls the deployment saved with its credential; change the deployment under Manage.");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user