mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-28 01:32:17 +00:00
Merge 9000134849 into e26a6450c8
This commit is contained in:
commit
75e7174163
2 changed files with 23 additions and 1 deletions
|
|
@ -121,6 +121,25 @@ describe("DeleteResourceModal", () => {
|
|||
expect(deleteButton).toBeEnabled();
|
||||
});
|
||||
|
||||
it("should enable delete button when the confirmation input matches after surrounding whitespace is trimmed", () => {
|
||||
renderWithProviders(<DeleteResourceModal {...defaultProps} requiredConfirmation="prod-key" />);
|
||||
const input = screen.getByPlaceholderText("prod-key");
|
||||
fireEvent.change(input, { target: { value: " prod-key " } });
|
||||
expect(screen.getByRole("button", { name: /delete/i })).toBeEnabled();
|
||||
});
|
||||
|
||||
it("should keep delete disabled when trimmed confirmation input still does not match", () => {
|
||||
renderWithProviders(<DeleteResourceModal {...defaultProps} requiredConfirmation="prod-key" />);
|
||||
fireEvent.change(screen.getByPlaceholderText("prod-key"), { target: { value: " other-key " } });
|
||||
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" />);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,10 @@ export default function DeleteResourceModal({
|
|||
<Button
|
||||
variant="destructive"
|
||||
onClick={onOk}
|
||||
disabled={(!!requiredConfirmation && requiredConfirmationInput !== requiredConfirmation) || confirmLoading}
|
||||
disabled={
|
||||
(!!requiredConfirmation && requiredConfirmationInput.trim() !== requiredConfirmation.trim()) ||
|
||||
confirmLoading
|
||||
}
|
||||
>
|
||||
{confirmLoading ? "Deleting..." : "Delete"}
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue