Add support for custom AI providers and refresh the built-in model catalog from settings. - Recognize custom provider configuration in provider status and onboarding readiness. - Add bounded model-catalog refresh endpoints and settings controls with localized copy. - Cover provider discovery, cache refresh, routes, and authentication UI behavior with tests. Files changed: .changeset/fn-019-provider-catalog.md | 7 ++ docs/dashboard-guide.md | 6 ++ .../dashboard/app/__tests__/api-models.test.ts | 29 +++++++++ .../dashboard/app/api/settings/provider-status.ts | 15 +++++ ...thenticationSection.modelsCacheRefresh.test.tsx | 46 +++++++++++++- .../__tests__/AuthenticationSection.test.tsx | 10 +++ .../settings/sections/AuthenticationSection.css | 20 ++++++ .../settings/sections/AuthenticationSection.tsx | 37 ++++++++++- .../app/hooks/__tests__/useAuthOnboarding.test.ts | 29 +++++++++ .../app/hooks/__tests__/useSetupReadiness.test.ts | 14 ++++ packages/dashboard/app/hooks/useAuthOnboarding.ts | 9 +-- packages/dashboard/app/hooks/useSetupReadiness.ts | 8 ++- .../register-model-routes-refresh-bounding.test.ts | 74 ++++++++++++++++++++++ .../dashboard/src/__tests__/routes-auth.test.ts | 18 ++++++ .../dashboard/src/routes/register-auth-routes.ts | 17 ++++- .../dashboard/src/routes/register-model-routes.ts | 22 ++++++- packages/i18n/locales/en/app.json | 6 ++ packages/i18n/locales/es/app.json | 6 ++ packages/i18n/locales/fr/app.json | 6 ++ packages/i18n/locales/ko/app.json | 6 ++ packages/i18n/locales/pt-BR/app.json | 6 ++ packages/i18n/locales/zh-CN/app.json | 6 ++ packages/i18n/locales/zh-TW/app.json | 6 ++ packages/i18n/src/resources.d.ts | 6 ++ 24 files changed, 397 insertions(+), 12 deletions(-) Fusion-Task-Id: FN-019 Fusion-Task-Lineage: 1e9daf0e-8aa8-4205-9fc7-686fbdd5bd35 Co-authored-by: Fusion <noreply@runfusion.ai>
30 lines
997 B
TypeScript
30 lines
997 B
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { refreshBuiltInModels } from "../api";
|
|
import { API_JSON_HEADERS } from "../test/apiRequestHeaders";
|
|
|
|
function mockResponse(body: unknown): Response {
|
|
return {
|
|
ok: true,
|
|
status: 200,
|
|
statusText: "OK",
|
|
headers: { get: () => "application/json" },
|
|
json: () => Promise.resolve(body),
|
|
text: () => Promise.resolve(JSON.stringify(body)),
|
|
} as unknown as Response;
|
|
}
|
|
|
|
describe("refreshBuiltInModels", () => {
|
|
afterEach(() => vi.restoreAllMocks());
|
|
|
|
it("posts to the explicit built-in catalog refresh endpoint and returns its typed outcome", async () => {
|
|
const response = { outcome: "completed" as const };
|
|
globalThis.fetch = vi.fn().mockResolvedValue(mockResponse(response));
|
|
|
|
await expect(refreshBuiltInModels()).resolves.toEqual(response);
|
|
expect(globalThis.fetch).toHaveBeenCalledWith("/api/models/refresh", {
|
|
headers: API_JSON_HEADERS,
|
|
method: "POST",
|
|
});
|
|
});
|
|
});
|