fix(dashboard): remap Kimi Code bulk API-key save

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
adevwithpurpose
2026-08-17 10:39:18 -03:00
parent ff6d465140
commit 8179ed630e
2 changed files with 44 additions and 1 deletions

View File

@@ -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,

View File

@@ -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(
<AddApiKeyModal
isOpen={true}
provider="kimi-coding"
providerName="Kimi Code"
isCompatible={false}
onSave={vi.fn().mockResolvedValue(undefined)}
onClose={vi.fn()}
/>
);
const bulkTab = Array.from(c.querySelectorAll("button")).find(
(button) => button.textContent === "providers.bulkTabBulkAdd"
);
act(() => bulkTab!.click());
const bulkInput = c.querySelector<HTMLTextAreaElement>("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(
<AddApiKeyModal