mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-28 01:32:17 +00:00
fix(ui): trim both sides of delete confirmation compare
A stored team or credential name with surrounding spaces would never match a trimmed paste. Compare the trimmed stored name too.
This commit is contained in:
parent
9719747080
commit
9000134849
2 changed files with 8 additions and 1 deletions
|
|
@ -134,6 +134,12 @@ describe("DeleteResourceModal", () => {
|
|||
expect(screen.getByRole("button", { name: /delete/i })).toBeDisabled();
|
||||
});
|
||||
|
||||
it("should enable delete when the stored name itself has surrounding whitespace", () => {
|
||||
renderWithProviders(<DeleteResourceModal {...defaultProps} requiredConfirmation=" prod-key " />);
|
||||
fireEvent.change(screen.getByRole("textbox"), { target: { value: "prod-key" } });
|
||||
expect(screen.getByRole("button", { name: /delete/i })).toBeEnabled();
|
||||
});
|
||||
|
||||
it("should reset requiredConfirmation input when modal opens", async () => {
|
||||
const user = userEvent.setup();
|
||||
const { rerender } = renderWithProviders(<DeleteResourceModal {...defaultProps} requiredConfirmation="DELETE" />);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@ export default function DeleteResourceModal({
|
|||
variant="destructive"
|
||||
onClick={onOk}
|
||||
disabled={
|
||||
(!!requiredConfirmation && requiredConfirmationInput.trim() !== requiredConfirmation) || confirmLoading
|
||||
(!!requiredConfirmation && requiredConfirmationInput.trim() !== requiredConfirmation.trim()) ||
|
||||
confirmLoading
|
||||
}
|
||||
>
|
||||
{confirmLoading ? "Deleting..." : "Delete"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue