mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
fix(ui): preserve credential actions menu across panel refreshes
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
a56a27deb6
commit
f6ba209e03
2 changed files with 34 additions and 5 deletions
|
|
@ -111,6 +111,35 @@ const renderPanel = () =>
|
|||
);
|
||||
|
||||
describe("CredentialsPanel", () => {
|
||||
it("keeps an open credential menu usable when the panel refreshes", async () => {
|
||||
const user = userEvent.setup();
|
||||
mockUseAuthorized.mockReturnValue({ accessToken: "test-token", userRole: "Admin" });
|
||||
mockUseCredentials.mockReturnValue({ data: { credentials }, isLoading: false, refetch: vi.fn() });
|
||||
const client = createQueryClient();
|
||||
const panel = (
|
||||
<QueryClientProvider client={client}>
|
||||
<CredentialsPanel />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
const { rerender } = render(panel);
|
||||
|
||||
await user.click(screen.getByTestId("credential-actions-openai-key"));
|
||||
expect(await screen.findByTestId("credential-action-edit")).toBeInTheDocument();
|
||||
mockUseCredentials.mockReturnValue({
|
||||
data: { credentials: credentials.map((credential) => ({ ...credential })) },
|
||||
isLoading: false,
|
||||
refetch: vi.fn(),
|
||||
});
|
||||
rerender(
|
||||
<QueryClientProvider client={client}>
|
||||
<CredentialsPanel />
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId("credential-action-edit"));
|
||||
expect(screen.getByTestId("credential-modal-edit-submit")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { useTerminology } from "@/contexts/TerminologyContext";
|
||||
import { Plus } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useCallback, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useCredentials } from "@/app/(dashboard)/hooks/credentials/useCredentials";
|
||||
|
|
@ -91,15 +91,15 @@ export default function CredentialsPanel() {
|
|||
}
|
||||
};
|
||||
|
||||
const openEditModal = (credential: CredentialItem) => {
|
||||
const openEditModal = useCallback((credential: CredentialItem) => {
|
||||
setSelectedCredential(credential);
|
||||
setIsUpdateModalOpen(true);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const openDeleteModal = (credential: CredentialItem) => {
|
||||
const openDeleteModal = useCallback((credential: CredentialItem) => {
|
||||
setCredentialToDelete(credential);
|
||||
setIsDeleteModalOpen(true);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const closeDeleteModal = () => {
|
||||
setCredentialToDelete(null);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue