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
21 changes: 12 additions & 9 deletions src/components/BatchSend/BatchForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ describe('BatchForm', () => {
const onSubmit = vi.fn()
render(<BatchForm onSubmit={onSubmit} supportedAssets={assets} />)

fireEvent.change(screen.getByPlaceholderText('G... recipient address'), {
fireEvent.change(screen.getByRole('textbox', { name: /recipient 1 address/i }), {
target: { value: VALID_ADDR },
})
fireEvent.change(screen.getByPlaceholderText('Amount'), {
fireEvent.change(screen.getByRole('spinbutton', { name: /recipient 1 amount/i }), {
target: { value: '0' },
})

Expand All @@ -29,21 +29,24 @@ describe('BatchForm', () => {
const onSubmit = vi.fn()
render(<BatchForm onSubmit={onSubmit} supportedAssets={assets} />)

fireEvent.change(screen.getByPlaceholderText('G... recipient address'), {
fireEvent.change(screen.getByRole('textbox', { name: /recipient 1 address/i }), {
target: { value: VALID_ADDR },
})
fireEvent.change(screen.getByPlaceholderText('Amount'), {
fireEvent.change(screen.getByRole('spinbutton', { name: /recipient 1 amount/i }), {
target: { value: '10' },
})

fireEvent.click(screen.getByRole('button', { name: /add recipient/i }))

const addresses = screen.getAllByPlaceholderText('G... recipient address')
const amounts = screen.getAllByPlaceholderText('Amount')
expect(addresses).toHaveLength(2)
expect(screen.getByRole('textbox', { name: /recipient 2 address/i })).toBeInTheDocument()
expect(screen.getByRole('spinbutton', { name: /recipient 2 amount/i })).toBeInTheDocument()

fireEvent.change(addresses[1], { target: { value: VALID_ADDR } })
fireEvent.change(amounts[1], { target: { value: '5' } })
fireEvent.change(screen.getByRole('textbox', { name: /recipient 2 address/i }), {
target: { value: VALID_ADDR },
})
fireEvent.change(screen.getByRole('spinbutton', { name: /recipient 2 amount/i }), {
target: { value: '5' },
})

await waitFor(() => {
expect(screen.getByRole('button', { name: /review batch/i })).not.toBeDisabled()
Expand Down
2 changes: 2 additions & 0 deletions src/components/BatchSend/BatchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ export function BatchForm({
>
<div className="flex-1 space-y-2">
<Input
aria-label={`Recipient ${index + 1} address`}
placeholder="G... recipient address"
fullWidth
error={errors.recipients?.[index]?.destinationAddress?.message}
{...register(`recipients.${index}.destinationAddress` as const)}
/>
<Input
aria-label={`Recipient ${index + 1} amount`}
placeholder="Amount"
type="number"
min="0"
Expand Down