mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
hotfix: Set proper minimum and maximum defaults that can be entered in billing input (#6842)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user