diff --git a/nodejs/test/client.test.ts b/nodejs/test/client.test.ts index e2d630ba0..f171658d2 100644 --- a/nodejs/test/client.test.ts +++ b/nodejs/test/client.test.ts @@ -14,6 +14,7 @@ import { type GitHubTelemetryNotification, type ModelInfo, } from "../src/index.js"; +import type { Model } from "../src/generated/rpc.js"; import { CopilotSession } from "../src/session.js"; import { defaultJoinSessionPermissionHandler } from "../src/types.js"; @@ -2854,7 +2855,32 @@ describe("CopilotClient", () => { }); }); - describe("onListModels", () => { + describe("model listing", () => { + it("preserves synthetic model identifiers and picker metadata through models.list", async () => { + const models: Model[] = [ + { + id: "hydrafusion", + name: "HydraFusion", + capabilities: {}, + modelPickerCategory: "powerful", + }, + { + id: "hydrafusion-max", + name: "HydraFusion Max", + capabilities: {}, + modelPickerCategory: "powerful", + }, + ]; + const sendRequest = vi.fn().mockResolvedValue({ models }); + const client = new CopilotClient(); + (client as any).connection = { sendRequest }; + + const result = await client.rpc.models.list({}); + + expect(sendRequest).toHaveBeenCalledWith("models.list", {}); + expect(result.models).toEqual(models); + }); + it("calls onListModels handler instead of RPC when provided", async () => { const customModels: ModelInfo[] = [ {