Skip to content

Commit

Permalink
Merge pull request #1037 from oasisprotocol/csillag/dont-choke-on-empty
Browse files Browse the repository at this point in the history
Fix error on clicking "Send" on an empty transfer
  • Loading branch information
csillag committed Oct 13, 2022
2 parents f631e9e + dc27f78 commit 3e9c6f6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cypress/e2e/scenario-transaction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ describe('Scenario : from mnemonic', () => {
})

it('Should send a transaction', () => {
// expect not to crash
cy.findByRole('button', { name: /Send/ }).click()

cy.get('#recipient-id').type('oasis1qz0k5q8vjqvu4s4nwxyj406ylnflkc4vrcjghuwk')
cy.get('#amount-id').type('10')
cy.findByRole('button', { name: /Send/ }).click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,23 @@ describe('<SendTransaction />', () => {
store = configureAppStore()
})

it('should NOT dispatch sendTransaction action when amount is missing', async () => {
const spy = jest.spyOn(store, 'dispatch')
renderComponent(store)

await userEvent.type(screen.getByPlaceholderText('account.sendTransaction.enterAddress'), 'walletAddress')
await userEvent.clear(screen.getByPlaceholderText('account.sendTransaction.enterAmount'))
spy.mockClear()
await userEvent.click(screen.getByRole('button'))
expect(spy).not.toHaveBeenCalled()
})

it('should dispatch sendTransaction action on submit', async () => {
const spy = jest.spyOn(store, 'dispatch')
renderComponent(store)

await userEvent.type(screen.getByPlaceholderText('account.sendTransaction.enterAddress'), 'walletAddress')
await userEvent.type(screen.getByPlaceholderText('0'), '10')
await userEvent.type(screen.getByPlaceholderText('account.sendTransaction.enterAmount'), '10')
await userEvent.click(screen.getByRole('button'))

expect(spy).toHaveBeenCalledWith({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function SendTransaction(props: SendTransactionProps) {
<TextInput
id="amount-id"
name="amount"
placeholder="0"
placeholder={t('account.sendTransaction.enterAmount', 'Enter an amount')}
type="number"
step="any"
min="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ exports[`<AccountPage /> should match snapshot 1`] = `
id="amount-id"
min="0"
name="amount"
placeholder="0"
placeholder="Enter an amount"
required=""
step="any"
type="number"
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"title": "Are you sure you want to continue?"
},
"enterAddress": "Enter an address",
"enterAmount": "Enter an amount",
"recipient": "Recipient",
"send": "Send",
"success": "Transaction successfully sent. The transaction might take up to a minute to appear on your account."
Expand Down

0 comments on commit 3e9c6f6

Please sign in to comment.