Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gui/src/components/provider-workspace/ProviderOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function ProviderOverview({
}, [connectionProbeKey]);

const testConnection = useCallback(async () => {
if (!apiBase) return;
if (apiBase === undefined) return;
connectionAbortRef.current?.controller.abort();
const controller = new AbortController();
connectionAbortRef.current = { key: connectionProbeKey, controller };
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function ProviderOverview({
</div>
)}
</dl>
{apiBase && (
{apiBase !== undefined && (
<div className="row" style={{ marginTop: 12, alignItems: "center" }}>
<button
type="button"
Expand Down
21 changes: 21 additions & 0 deletions gui/tests/provider-overview-notes-save.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,27 @@ test("static catalog connection test renders as not applicable instead of failed
await act(async () => { root.unmount(); });
});

test("connection test supports the default same-origin API base", async () => {
globalThis.fetch = (async (input: RequestInfo | URL) => {
expect(String(input)).toBe("/api/providers/test?name=openai");
return Response.json({ ok: true, latencyMs: 4, message: "Connected" });
}) as typeof fetch;

const { root, container } = await mountOverview(async () => ({ ok: true }), item, "");
const button = [...container.querySelectorAll<HTMLButtonElement>("button")]
.find(candidate => candidate.textContent?.includes("Test connection"));
expect(button).toBeTruthy();

await act(async () => {
button!.click();
await flush();
});

expect(container.querySelector('[data-connection-test-state="ok"]')?.textContent).toContain("Connected");

await act(async () => { root.unmount(); });
});

test("same-provider config changes clear a rendered connection result", async () => {
globalThis.fetch = (async () => Response.json({
ok: true,
Expand Down
Loading