From c812e774ddeecc43c30531e254d2c125f4bc24f0 Mon Sep 17 00:00:00 2001 From: Otfrugger Date: Mon, 31 Aug 2026 12:03:37 +0100 Subject: [PATCH] fix(web): disable deposit and withdraw submit on zero or negative amounts --- .../src/__tests__/components/DepositTab.test.tsx | 16 ++++++++++++++++ .../__tests__/components/WithdrawTab.test.tsx | 16 ++++++++++++++++ apps/web/src/components/dashboard/DepositTab.tsx | 8 +++++++- .../web/src/components/dashboard/WithdrawTab.tsx | 2 ++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/apps/web/src/__tests__/components/DepositTab.test.tsx b/apps/web/src/__tests__/components/DepositTab.test.tsx index 89fb4251..74437e14 100644 --- a/apps/web/src/__tests__/components/DepositTab.test.tsx +++ b/apps/web/src/__tests__/components/DepositTab.test.tsx @@ -64,6 +64,22 @@ describe("DepositTab", () => { expect(onSubmit).toHaveBeenCalledTimes(1); }); + it("disables the submit button when amount is zero", () => { + renderDepositTab({ amount: "0" }); + expect(screen.getByTestId("vault-deposit-submit")).toHaveProperty( + "disabled", + true + ); + }); + + it("disables the submit button when amount is negative", () => { + renderDepositTab({ amount: "-1" }); + expect(screen.getByTestId("vault-deposit-submit")).toHaveProperty( + "disabled", + true + ); + }); + it("disables the submit button when amount is empty", () => { renderDepositTab({ amount: "" }); diff --git a/apps/web/src/__tests__/components/WithdrawTab.test.tsx b/apps/web/src/__tests__/components/WithdrawTab.test.tsx index c3604199..ec660448 100644 --- a/apps/web/src/__tests__/components/WithdrawTab.test.tsx +++ b/apps/web/src/__tests__/components/WithdrawTab.test.tsx @@ -79,6 +79,22 @@ describe("WithdrawTab", () => { expect(onSubmit).toHaveBeenCalledTimes(1); }); + it("disables the submit button when amount is zero", () => { + renderWithdrawTab({ amount: "0" }); + expect(screen.getByTestId("vault-withdraw-submit")).toHaveProperty( + "disabled", + true + ); + }); + + it("disables the submit button when amount is negative", () => { + renderWithdrawTab({ amount: "-1" }); + expect(screen.getByTestId("vault-withdraw-submit")).toHaveProperty( + "disabled", + true + ); + }); + it("disables the submit button when amount exceeds available shares", () => { renderWithdrawTab({ amount: "999" }); diff --git a/apps/web/src/components/dashboard/DepositTab.tsx b/apps/web/src/components/dashboard/DepositTab.tsx index 6da1f0ed..7d909f3c 100644 --- a/apps/web/src/components/dashboard/DepositTab.tsx +++ b/apps/web/src/components/dashboard/DepositTab.tsx @@ -58,7 +58,13 @@ export function DepositTab({