From 8179ed630ef65a0e4b20ecf2d3447af65e5fe780 Mon Sep 17 00:00:00 2001 From: adevwithpurpose Date: Mon, 17 Aug 2026 10:39:18 -0300 Subject: [PATCH] fix(dashboard): remap Kimi Code bulk API-key save Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --- .../[id]/components/modals/AddApiKeyModal.tsx | 2 +- .../modals/__tests__/connModals.test.tsx | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/app/(dashboard)/dashboard/providers/[id]/components/modals/AddApiKeyModal.tsx b/src/app/(dashboard)/dashboard/providers/[id]/components/modals/AddApiKeyModal.tsx index 7e74679dbe..de377cd9cb 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/components/modals/AddApiKeyModal.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/components/modals/AddApiKeyModal.tsx @@ -435,7 +435,7 @@ export default function AddApiKeyModal({ method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ - provider, + provider: provider === "kimi-coding" ? "kimi-coding-apikey" : provider, entries: parsed.entries.map((e) => ({ name: e.name, apiKey: e.apiKey, diff --git a/src/app/(dashboard)/dashboard/providers/[id]/components/modals/__tests__/connModals.test.tsx b/src/app/(dashboard)/dashboard/providers/[id]/components/modals/__tests__/connModals.test.tsx index 74db3db3c1..36064cd75a 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/components/modals/__tests__/connModals.test.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/components/modals/__tests__/connModals.test.tsx @@ -241,6 +241,49 @@ describe("conn-modals (Phase 1c extraction)", () => { ); }); + it("AddApiKeyModal remaps Kimi Code bulk API-key additions to the admitted provider id", async () => { + const fetchMock = vi.fn(() => + Promise.resolve({ + ok: true, + json: async () => ({ success: 1, failed: 0, total: 1, errors: [] }), + text: async () => "", + } as Response) + ); + vi.stubGlobal("fetch", fetchMock); + const c = renderModal( + + ); + + const bulkTab = Array.from(c.querySelectorAll("button")).find( + (button) => button.textContent === "providers.bulkTabBulkAdd" + ); + act(() => bulkTab!.click()); + const bulkInput = c.querySelector("textarea"); + setTextareaValue(bulkInput!, "main|sk-kimi-test"); + const submitButton = Array.from(c.querySelectorAll("button")).find( + (button) => button.textContent === "providers.bulkAddAllKeys" + ); + await act(async () => { + submitButton!.click(); + await Promise.resolve(); + await Promise.resolve(); + }); + + expect(fetchMock).toHaveBeenCalledWith( + "/api/providers/bulk", + expect.objectContaining({ + body: expect.stringContaining('"provider":"kimi-coding-apikey"'), + }) + ); + }); + it("AddApiKeyModal does not infer a regional provider selection", () => { const c = renderModal(