mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-17 20:52:15 +03:00
fix(dashboard): remap Kimi Code bulk API-key save
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user