Add upstream model list fetching and a Codex-specific model section

This commit is contained in:
kate522 committed 2026-10-18 19:33:32 +08:00
1 parent d759fe5e5d
commit f3bf1472e7
12 files changed
+339 -16

No files matched your search

+22
View File
@@ -8,6 +8,7 @@ const createProvider = vi.fn();
const applyProvider = vi.fn();
const restore = vi.fn();
const getStatus = vi.fn();
const fetchModels = vi.fn();
vi.mock("@/lib/api", () => ({
api: {
@@ -22,6 +23,7 @@ vi.mock("@/lib/api", () => ({
updateSettings: vi.fn(),
listLogs: vi.fn().mockResolvedValue({ items: [] }),
listBackups: vi.fn().mockResolvedValue({ items: [] }),
fetchModels: (input: unknown) => fetchModels(input),
},
}));
@@ -70,6 +72,7 @@ beforeEach(() => {
},
});
restore.mockResolvedValue({ restored_from: "" });
fetchModels.mockResolvedValue({ items: [{ id: "deepseek-chat" }, { id: "deepseek-reasoner" }] });
});
describe("Codex page", () => {
@@ -102,6 +105,25 @@ describe("Codex page", () => {
});
});
it("offers model fetching instead of Claude role fields", async () => {
const user = userEvent.setup();
renderWithProviders(<Codex />);
await user.click(await screen.findByRole("button", { name: /新增供应商|Add provider/ }));
expect(screen.queryByLabelText(/Sonnet 模型|Sonnet model/)).not.toBeInTheDocument();
expect(screen.queryByLabelText(/Haiku 模型|Haiku model/)).not.toBeInTheDocument();
expect(screen.queryByLabelText(/Opus 模型|Opus model/)).not.toBeInTheDocument();
await user.type(screen.getByLabelText(/Base URL/), "https://api.deepseek.com/v1");
await user.type(screen.getByLabelText(/API Key/), "sk-x");
await user.click(screen.getByRole("button", { name: /获取模型列表|Fetch models/ }));
await waitFor(() =>
expect(fetchModels).toHaveBeenCalledWith({
base_url: "https://api.deepseek.com/v1",
api_key: "sk-x",
}),
);
expect(await screen.findByText(/已获取 2 个模型|Fetched 2 models/)).toBeInTheDocument();
});
it("activates a provider for Codex and previews the injected keys", async () => {
const user = userEvent.setup();
renderWithProviders(<Codex />);