diff --git a/bun.lockb b/bun.lockb index 218160e4..554eb353 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/bank/forms/__tests__/ibcSendForm.test.tsx b/components/bank/forms/__tests__/ibcSendForm.test.tsx index 2451357f..ebc76322 100644 --- a/components/bank/forms/__tests__/ibcSendForm.test.tsx +++ b/components/bank/forms/__tests__/ibcSendForm.test.tsx @@ -20,7 +20,6 @@ function renderWithProps(props = {}) { return renderWithChainProvider(); } -// TODO: Validate form inputs in component describe('IbcSendForm Component', () => { afterEach(cleanup); @@ -60,14 +59,12 @@ describe('IbcSendForm Component', () => { expect(amountInput).toHaveValue('100'); }); - // // TODO: Make this test pass - // test('send button is disabled when inputs are invalid', () => { - // renderWithProps(); - // const sendButton = screen.getByLabelText('send-btn'); - // expect(sendButton).toBeDisabled(); - // }); + test('send button is disabled when inputs are invalid', () => { + renderWithProps(); + const sendButton = screen.getByLabelText('send-btn'); + expect(sendButton).toBeDisabled(); + }); - // TODO: Fix inputs to be valid test('send button is enabled when inputs are valid', () => { renderWithProps(); fireEvent.change(screen.getByPlaceholderText('Recipient address'), { diff --git a/components/bank/forms/__tests__/sendForm.test.tsx b/components/bank/forms/__tests__/sendForm.test.tsx index 33024e13..2b214540 100644 --- a/components/bank/forms/__tests__/sendForm.test.tsx +++ b/components/bank/forms/__tests__/sendForm.test.tsx @@ -27,7 +27,6 @@ function renderWithProps(props = {}) { return renderWithChainProvider(); } -// TODO: Validate form inputs in component describe('SendForm Component', () => { afterEach(cleanup); @@ -67,14 +66,12 @@ describe('SendForm Component', () => { expect(amountInput).toHaveValue('100'); }); - // TODO: Make this test pass - // test('send button is disabled when inputs are invalid', () => { - // renderWithProps(); - // const sendButton = screen.getByText('Send'); - // expect(sendButton).toBeDisabled(); - // }); + test('send button is disabled when inputs are invalid', () => { + renderWithProps(); + const sendButton = screen.getByText('Send'); + expect(sendButton).toBeDisabled(); + }); - // TODO: Fix inputs to be valid test('send button is enabled when inputs are valid', () => { renderWithProps(); fireEvent.change(screen.getByPlaceholderText('Recipient address'), { diff --git a/components/factory/forms/CreateDenom.tsx b/components/factory/forms/CreateDenom.tsx index 1e641ec7..26600806 100644 --- a/components/factory/forms/CreateDenom.tsx +++ b/components/factory/forms/CreateDenom.tsx @@ -29,7 +29,6 @@ export default function CreateDenom({ const { estimateFee } = useFeeEstimation('manifest'); const validateSubdenom = (value: string) => { - console.log('Validating subdenom', value); if (value.length === 0) { return 'Subdenom is required'; } diff --git a/components/groups/forms/groups/GroupDetailsForm.tsx b/components/groups/forms/groups/GroupDetailsForm.tsx index f47cdc99..16dfb3e8 100644 --- a/components/groups/forms/groups/GroupDetailsForm.tsx +++ b/components/groups/forms/groups/GroupDetailsForm.tsx @@ -53,8 +53,10 @@ export default function GroupDetails({ validationSchema={GroupSchema} onSubmit={nextStep} validateOnChange={true} + validateOnMount={true} + enableReinitialize > - {({ isValid, dirty, setFieldValue }) => ( + {({ isValid, setFieldValue }) => (
void; prevStep: () => void; }>) { - const [votingUnit, setVotingUnit] = useState('days'); + const updateField = (field: keyof FormData, value: any) => { + dispatch({ type: 'UPDATE_FIELD', field, value }); + }; + + const [votingUnit, setVotingUnit] = useState(VotingUnit.Days); const [votingAmount, setVotingAmount] = useState(1); - const convertToSeconds = (unit: string, amount: number): number => { + const convertToSeconds = (unit: VotingUnit, amount: number): number => { switch (unit) { - case 'hours': + case VotingUnit.Hours: return amount * 3600; - case 'days': + case VotingUnit.Days: return amount * 86400; - case 'weeks': + case VotingUnit.Weeks: return amount * 604800; - case 'months': + case VotingUnit.Months: return amount * 2592000; default: return 0; @@ -45,17 +56,13 @@ export default function GroupPolicyForm({ useEffect(() => { const votingPeriodSeconds = convertToSeconds(votingUnit, votingAmount); - dispatch({ - type: 'UPDATE_FIELD', - field: 'votingPeriod', - value: { - seconds: BigInt(votingPeriodSeconds), - nanos: 0, - }, + updateField('votingPeriod', { + seconds: BigInt(votingPeriodSeconds), + nanos: 0, }); }, [votingUnit, votingAmount, dispatch]); - const handleUnitChange = (unit: string) => { + const handleUnitChange = (unit: VotingUnit) => { setVotingUnit(unit); }; @@ -106,7 +113,7 @@ export default function GroupPolicyForm({ tabIndex={0} className="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52 mt-1" > - {['hours', 'days', 'weeks', 'months'].map(unit => ( + {Object.values(VotingUnit).map(unit => (
  • handleUnitChange(unit)}> {unit.charAt(0).toUpperCase() + unit.slice(1)} @@ -132,12 +139,8 @@ export default function GroupPolicyForm({ label="" value={formData.votingThreshold} onChange={(e: React.ChangeEvent) => { - const value = Math.max(1, parseInt(e.target.value) || 1); - dispatch({ - type: 'UPDATE_FIELD', - field: 'votingThreshold', - value: value.toString(), - }); + const value = Math.max(1, parseInt(e.target.value)); + updateField('votingThreshold', value.toString()); setFieldValue('votingThreshold', value); }} min={1} @@ -148,7 +151,7 @@ export default function GroupPolicyForm({