Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/web/src/__tests__/components/DepositTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: "" });

Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/__tests__/components/WithdrawTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" });

Expand Down
8 changes: 7 additions & 1 deletion apps/web/src/components/dashboard/DepositTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export function DepositTab({
<button
data-testid="vault-deposit-submit"
onClick={onSubmit}
disabled={!amount || !bestVault || isDepositing}
disabled={
!amount ||
!bestVault ||
isDepositing ||
parseFloat(amount) <= 0 ||
Number.isNaN(parseFloat(amount))
}
className="w-full rounded-xl bg-emerald-600 hover:bg-emerald-500 disabled:bg-gray-800 disabled:text-gray-600 text-white text-sm font-semibold py-3.5 transition-all duration-150 disabled:cursor-not-allowed"
>
{isDepositing ? t("vaultPanel.waiting") : t("vaultPanel.deposit")}
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/components/dashboard/WithdrawTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export function WithdrawTab({
!amount ||
!bestVault ||
isWithdrawing ||
parseFloat(amount) <= 0 ||
Number.isNaN(parseFloat(amount)) ||
parseFloat(amount) > (position?.shares ?? 0)
}
className="w-full rounded-xl bg-emerald-600 hover:bg-emerald-500 disabled:bg-gray-800 disabled:text-gray-600 text-white text-sm font-semibold py-3.5 transition-all duration-150 disabled:cursor-not-allowed"
Expand Down