Files
openclaw/src/commands/models/list.list-command.forward-compat.test.ts
loiie45e 2e04630105 openai-codex: add gpt-5.3-codex-spark forward-compat model (#15174)
Merged via maintainer flow after rebase + local gates.

Prepared head SHA: 6cac87cbf9

Co-authored-by: loiie45e <15420100+loiie45e@users.noreply.github.com>
Co-authored-by: mbelinky <2406260+mbelinky@users.noreply.github.com>
2026-02-13 15:21:07 +00:00

96 lines
2.9 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => {
const printModelTable = vi.fn();
return {
loadConfig: vi.fn().mockReturnValue({
agents: { defaults: { model: { primary: "openai-codex/gpt-5.3-codex-spark" } } },
models: { providers: {} },
}),
ensureAuthProfileStore: vi.fn().mockReturnValue({ version: 1, profiles: {}, order: {} }),
loadModelRegistry: vi.fn().mockResolvedValue({ models: [], availableKeys: new Set() }),
resolveConfiguredEntries: vi.fn().mockReturnValue({
entries: [
{
key: "openai-codex/gpt-5.3-codex-spark",
ref: { provider: "openai-codex", model: "gpt-5.3-codex-spark" },
tags: new Set(["configured"]),
aliases: [],
},
],
}),
printModelTable,
resolveModel: vi.fn().mockReturnValue({
model: {
provider: "openai-codex",
id: "gpt-5.3-codex-spark",
name: "GPT-5.3 Codex Spark",
api: "openai-codex-responses",
baseUrl: "https://chatgpt.com/backend-api",
input: ["text"],
contextWindow: 272000,
maxTokens: 128000,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
},
error: undefined,
authStorage: {} as never,
modelRegistry: {} as never,
}),
};
});
vi.mock("../../config/config.js", () => ({
loadConfig: mocks.loadConfig,
}));
vi.mock("../../agents/auth-profiles.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../../agents/auth-profiles.js")>();
return {
...actual,
ensureAuthProfileStore: mocks.ensureAuthProfileStore,
listProfilesForProvider: vi.fn().mockReturnValue([]),
};
});
vi.mock("./list.registry.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("./list.registry.js")>();
return {
...actual,
loadModelRegistry: mocks.loadModelRegistry,
};
});
vi.mock("./list.configured.js", () => ({
resolveConfiguredEntries: mocks.resolveConfiguredEntries,
}));
vi.mock("./list.table.js", () => ({
printModelTable: mocks.printModelTable,
}));
vi.mock("../../agents/pi-embedded-runner/model.js", () => ({
resolveModel: mocks.resolveModel,
}));
import { modelsListCommand } from "./list.list-command.js";
describe("modelsListCommand forward-compat", () => {
it("does not mark configured codex spark as missing when resolveModel can build a fallback", async () => {
const runtime = { log: vi.fn(), error: vi.fn() };
await modelsListCommand({ json: true }, runtime as never);
expect(mocks.printModelTable).toHaveBeenCalled();
const rows = mocks.printModelTable.mock.calls[0]?.[0] as Array<{
key: string;
tags: string[];
missing: boolean;
}>;
const spark = rows.find((r) => r.key === "openai-codex/gpt-5.3-codex-spark");
expect(spark).toBeTruthy();
expect(spark?.missing).toBe(false);
expect(spark?.tags).not.toContain("missing");
});
});