Skip to content

πŸ™Œ OpenHands: AI-Driven Development

hotfix: Set proper minimum and maximum defaults that can be entered in billing input (#6842)

sp.wack3f8bc8a7ea2f
diff --git a/frontend/__tests__/components/features/payment/payment-form.test.tsx b/frontend/__tests__/components/features/payment/payment-form.test.tsx
index 3235976939..2d30f45fad 100644
--- a/frontend/__tests__/components/features/payment/payment-form.test.tsx
+++ b/frontend/__tests__/components/features/payment/payment-form.test.tsx
@@ -149,7 +149,7 @@ describe("PaymentForm", () => {
renderPaymentForm();
const topUpInput = await screen.findByTestId("top-up-input");
- await user.type(topUpInput, "20"); // test assumes the minimum is 25
+ await user.type(topUpInput, "9"); // test assumes the minimum is 10
const topUpButton = screen.getByText("Add credit");
await user.click(topUpButton);
diff --git a/frontend/__tests__/utils/amount-is-valid.test.ts b/frontend/__tests__/utils/amount-is-valid.test.ts
index 30181e1b48..3a940f77e0 100644
--- a/frontend/__tests__/utils/amount-is-valid.test.ts
+++ b/frontend/__tests__/utils/amount-is-valid.test.ts
@@ -24,9 +24,15 @@ describe("amountIsValid", () => {
});
test("when an amount less than the minimum is passed", () => {
- // test assumes the minimum is 25
- expect(amountIsValid("24")).toBe(false);
- expect(amountIsValid("24.99")).toBe(false);
+ // test assumes the minimum is 10
+ expect(amountIsValid("9")).toBe(false);
+ expect(amountIsValid("9.99")).toBe(false);
+ });
+
+ test("when an amount more than the maximum is passed", () => {
+ // test assumes the minimum is 25000
+ expect(amountIsValid("25001")).toBe(false);
+ expect(amountIsValid("25000.01")).toBe(false);
});
});
});
diff --git a/frontend/src/utils/amount-is-valid.ts b/frontend/src/utils/amount-is-valid.ts
index c987fcecff..0912221f93 100644
--- a/frontend/src/utils/amount-is-valid.ts
+++ b/frontend/src/utils/amount-is-valid.ts
@@ -1,10 +1,12 @@
-const MINIMUM_AMOUNT = 25;
+const MINIMUM_AMOUNT = 10;
+const MAXIMUM_AMOUNT = 25_000;
export const amountIsValid = (amount: string) => {
const float = parseFloat(amount);
if (Number.isNaN(float)) return false;
if (float < 0) return false;
if (float < MINIMUM_AMOUNT) return false;
+ if (float > MAXIMUM_AMOUNT) return false;
return true;
};