fix: 模型管理审查修复与归档
- 修复 registry 测试 ai mock 缺失 createProviderRegistry 导出 - 新增 POST /api/providers/test 支持未保存供应商配置连通性测试 - 供应商表单新增测试连接按钮,新建默认 openai-compatible - 连通性测试按 ok 展示成功/失败,不再统一 success 样式 - 模型表单新建时也可测试供应商连接 - 模型页使用独立 provider 列表避免分页/搜索影响 - 移除模型管理组件内联 style - 新增 ProviderTestResultResponse 共享响应类型 - 新增 bun run format:check 脚本 - 补充关键测试覆盖(删除关联、连通性、默认类型、表单测试) - 更新 docs/user/usage.md、docs/development/*、design.md、tasks.md - 归档 change 至 openspec/changes/archive/2026-05-29-add-model-management
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
enableProvider,
|
||||
fetchProvider,
|
||||
fetchProviderList,
|
||||
testProviderConfig,
|
||||
testProviderConnection,
|
||||
updateProvider,
|
||||
} from "../../../src/web/hooks/use-providers";
|
||||
@@ -89,6 +90,27 @@ describe("use-providers request helpers", () => {
|
||||
expect(result).toEqual({ message: "ok", ok: true });
|
||||
});
|
||||
|
||||
test("testProviderConfig posts form config and parses response", async () => {
|
||||
const calls = installFetchMock(() => jsonResponse({ providerTestResponse: { message: "ok", ok: true } }));
|
||||
|
||||
const result = await testProviderConfig({
|
||||
apiKey: "sk-test",
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
name: "OpenAI",
|
||||
type: "openai-compatible",
|
||||
});
|
||||
|
||||
expect(result).toEqual({ message: "ok", ok: true });
|
||||
expect(calls[0]?.method).toBe("POST");
|
||||
expect(calls[0]?.url).toBe("/api/providers/test");
|
||||
expect(jsonBody(calls[0]?.body)).toEqual({
|
||||
apiKey: "sk-test",
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
name: "OpenAI",
|
||||
type: "openai-compatible",
|
||||
});
|
||||
});
|
||||
|
||||
test("error response uses backend error field", async () => {
|
||||
installFetchMock(() => jsonResponse({ error: "dup" }, { status: 409 }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user