Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Send/__tests__/SendXec.test.js
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | it('Renders the SendXec screen with send address input', async () => { | ||||
// Input fields are rendered | // Input fields are rendered | ||||
expect(addressInputEl).toBeInTheDocument(); | expect(addressInputEl).toBeInTheDocument(); | ||||
expect(amountInputEl).toBeInTheDocument(); | expect(amountInputEl).toBeInTheDocument(); | ||||
// Inputs are not disabled | // Inputs are not disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', false); | expect(addressInputEl).toHaveProperty('disabled', false); | ||||
expect(amountInputEl).toHaveProperty('disabled', false); | expect(amountInputEl).toHaveProperty('disabled', false); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// The Send button is disabled | // The Send button is disabled | ||||
expect(screen.getByRole('button', { name: /Send/ })).toHaveStyle( | expect(screen.getByRole('button', { name: /Send/ })).toHaveStyle( | ||||
Show All 28 Lines | it('Pass valid address to Send To field', async () => { | ||||
// The user enters a valid address | // The user enters a valid address | ||||
const addressInput = 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6'; | const addressInput = 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | it('Pass valid alias to Send To field', async () => { | ||||
// The user enters a valid alias | // The user enters a valid alias | ||||
const addressInput = 'twelvechar12.xec'; | const addressInput = 'twelvechar12.xec'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | it('Pass an invalid address to Send To field and get a validation error', async () => { | ||||
// The user enters an invalid address | // The user enters an invalid address | ||||
const addressInput = 'ecash:notValid'; | const addressInput = 'ecash:notValid'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
Show All 28 Lines | it('Pass a possibly valid alias without .xec suffix to Send To field and get expected error', async () => { | ||||
// The user enters an alias that could be valid except missing suffix '.xec' | // The user enters an alias that could be valid except missing suffix '.xec' | ||||
const addressInput = 'aliasnosuffix'; | const addressInput = 'aliasnosuffix'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | it('Pass a valid alias to Send To field that has not yet been registered and get expected error', async () => { | ||||
// The user enters a valid alias | // The user enters a valid alias | ||||
const addressInput = `${alias}.xec`; | const addressInput = `${alias}.xec`; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | it('Get expected error msg and send disabled if bad response from alias server', async () => { | ||||
// The user enters a valid alias | // The user enters a valid alias | ||||
const addressInput = `${alias}.xec`; | const addressInput = `${alias}.xec`; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The Bip21Alert span is not rendered | // The Bip21Alert span is not rendered | ||||
expect( | expect( | ||||
screen.queryByText('(set by BIP21 query string)'), | screen.queryByText('(set by BIP21 query string)'), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
Show All 33 Lines | it('Pass a valid address and bip21 query string with valid amount param to Send To field', async () => { | ||||
// The user enters a valid BIP21 query string with a valid amount param | // The user enters a valid BIP21 query string with a valid amount param | ||||
const addressInput = | const addressInput = | ||||
'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?amount=500'; | 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?amount=500'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is the valid amount param value | // Amount input is the valid amount param value | ||||
expect(amountInputEl).toHaveValue(500); | expect(amountInputEl).toHaveValue(500); | ||||
// The amount input is disabled because it is set by a bip21 query string | // The amount input is disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', true); | expect(amountInputEl).toHaveProperty('disabled', true); | ||||
// No addr validation errors on load | // No addr validation errors on load | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | it('Pass a valid alias and bip21 query string with valid amount param to Send To field', async () => { | ||||
// The user enters a valid BIP21 query string with a valid amount param | // The user enters a valid BIP21 query string with a valid amount param | ||||
const addressInput = `${alias}.xec?amount=500`; | const addressInput = `${alias}.xec?amount=500`; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is the valid amount param value | // Amount input is the valid amount param value | ||||
expect(amountInputEl).toHaveValue(500); | expect(amountInputEl).toHaveValue(500); | ||||
// The amount input is disabled because it is set by a bip21 query string | // The amount input is disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', true); | expect(amountInputEl).toHaveProperty('disabled', true); | ||||
// No addr validation errors on load | // No addr validation errors on load | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | it('Pass a valid address and bip21 query string with invalid amount param (dust) to Send To field', async () => { | ||||
'cursor: not-allowed', | 'cursor: not-allowed', | ||||
); | ); | ||||
// The Bip21Alert span is rendered | // The Bip21Alert span is rendered | ||||
expect( | expect( | ||||
screen.getByText('(set by BIP21 query string)'), | screen.getByText('(set by BIP21 query string)'), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
}); | }); | ||||
it('Valid address with valid bip21 query string with valid amount param rejected if amount exceeds wallet balance', async () => { | it('Valid address with valid bip21 query string with valid amount param rejected if amount exceeds wallet balance', async () => { | ||||
// Mock the app with context at the Send screen | // Mock the app with context at the Send screen | ||||
const mockedChronik = await initializeCashtabStateForTests( | const mockedChronik = await initializeCashtabStateForTests( | ||||
walletWithXecAndTokens, | walletWithXecAndTokens, | ||||
localforage, | localforage, | ||||
); | ); | ||||
render(<CashtabTestWrapper chronik={mockedChronik} route="/send" />); | render(<CashtabTestWrapper chronik={mockedChronik} route="/send" />); | ||||
Show All 33 Lines | it('Valid address with valid bip21 query string with valid amount param rejected if amount exceeds wallet balance', async () => { | ||||
'cursor: not-allowed', | 'cursor: not-allowed', | ||||
); | ); | ||||
// The Bip21Alert span is rendered | // The Bip21Alert span is rendered | ||||
expect( | expect( | ||||
screen.getByText('(set by BIP21 query string)'), | screen.getByText('(set by BIP21 query string)'), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
}); | }); | ||||
it('Pass a valid alias and bip21 query string with invalid amount param (too many decimals) to Send To field', async () => { | it('Pass a valid alias and bip21 query string with invalid amount param (too many decimals) to Send To field', async () => { | ||||
// Mock the app with context at the Send screen | // Mock the app with context at the Send screen | ||||
const mockedChronik = await initializeCashtabStateForTests( | const mockedChronik = await initializeCashtabStateForTests( | ||||
walletWithXecAndTokens, | walletWithXecAndTokens, | ||||
localforage, | localforage, | ||||
); | ); | ||||
render(<CashtabTestWrapper chronik={mockedChronik} route="/send" />); | render(<CashtabTestWrapper chronik={mockedChronik} route="/send" />); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | it('Pass a valid alias and bip21 query string with invalid amount param (too many decimals) to Send To field', async () => { | ||||
'cursor: not-allowed', | 'cursor: not-allowed', | ||||
); | ); | ||||
// The Bip21Alert span is rendered | // The Bip21Alert span is rendered | ||||
expect( | expect( | ||||
screen.getByText('(set by BIP21 query string)'), | screen.getByText('(set by BIP21 query string)'), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// The alias address preview renders the expected address preview | // The alias address preview renders the expected address preview | ||||
expect( | expect( | ||||
screen.getByText( | screen.getByText( | ||||
`${expectedResolvedAddress.slice( | `${expectedResolvedAddress.slice( | ||||
0, | 0, | ||||
10, | 10, | ||||
)}...${expectedResolvedAddress.slice(-5)}`, | )}...${expectedResolvedAddress.slice(-5)}`, | ||||
Show All 19 Lines | it('Pass a valid address and an invalid bip21 query string', async () => { | ||||
// The user enters a badly formed query string | // The user enters a badly formed query string | ||||
const addressInput = | const addressInput = | ||||
'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?notaparam=500'; | 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?notaparam=500'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The Send To input value matches user input | // The Send To input value matches user input | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input unchanged | // Amount input unchanged | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
// The amount input is not disabled because no amount param is specified | // The amount input is not disabled because no amount param is specified | ||||
expect(amountInputEl).toHaveProperty('disabled', false); | expect(amountInputEl).toHaveProperty('disabled', false); | ||||
// We get expected addr validation error | // We get expected addr validation error | ||||
Show All 34 Lines | it('Pass a valid address and bip21 query string with op_return_raw param to Send To field', async () => { | ||||
// The user enters a valid BIP21 query string with a valid amount param | // The user enters a valid BIP21 query string with a valid amount param | ||||
const addressInput = | const addressInput = | ||||
'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?op_return_raw=0401020304'; | 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?op_return_raw=0401020304'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is untouched | // Amount input is untouched | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
// The amount input is not disabled because it is set by a bip21 query string | // The amount input is not disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', false); | expect(amountInputEl).toHaveProperty('disabled', false); | ||||
// No addr validation errors on load | // No addr validation errors on load | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | it('Pass a valid address and bip21 query string with valid amount and op_return_raw params to Send To field', async () => { | ||||
// The user enters a valid BIP21 query string with a valid amount param | // The user enters a valid BIP21 query string with a valid amount param | ||||
const addressInput = | const addressInput = | ||||
'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?amount=500&op_return_raw=0401020304'; | 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?amount=500&op_return_raw=0401020304'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is the valid amount param value | // Amount input is the valid amount param value | ||||
expect(amountInputEl).toHaveValue(500); | expect(amountInputEl).toHaveValue(500); | ||||
// The amount input is disabled because it is set by a bip21 query string | // The amount input is disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', true); | expect(amountInputEl).toHaveProperty('disabled', true); | ||||
// No addr validation errors on load | // No addr validation errors on load | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | it('Pass a valid address and bip21 query string with valid amount and invalid op_return_raw params to Send To field', async () => { | ||||
// The user enters a valid BIP21 query string with a valid amount param | // The user enters a valid BIP21 query string with a valid amount param | ||||
const addressInput = | const addressInput = | ||||
'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?amount=500&op_return_raw=notahexstring'; | 'ecash:qp89xgjhcqdnzzemts0aj378nfe2mhu9yvxj9nhgg6?amount=500&op_return_raw=notahexstring'; | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is the valid amount param value | // Amount input is the valid amount param value | ||||
expect(amountInputEl).toHaveValue(500); | expect(amountInputEl).toHaveValue(500); | ||||
// The amount input is disabled because it is set by a bip21 query string | // The amount input is disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', true); | expect(amountInputEl).toHaveProperty('disabled', true); | ||||
// We get expected addr validation error | // We get expected addr validation error | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | it('Clicking "Send" will send a valid tx with op_return_raw after entry of a valid address and bip21 query string with valid amount and op_return_raw params to Send To field', async () => { | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The 'Send To' input field is not disabled | // The 'Send To' input field is not disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', false); | expect(addressInputEl).toHaveProperty('disabled', false); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is the valid amount param value | // Amount input is the valid amount param value | ||||
expect(amountInputEl).toHaveValue(17); | expect(amountInputEl).toHaveValue(17); | ||||
// The amount input is disabled because it is set by a bip21 query string | // The amount input is disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', true); | expect(amountInputEl).toHaveProperty('disabled', true); | ||||
// No addr validation errors on load | // No addr validation errors on load | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | it('Clicking "Send" will send a valid tx with op_return_raw after entry of a valid address and bip21 query string with valid amount and op_return_raw params to Send To field', async () => { | ||||
// The amount input is no longer disabled | // The amount input is no longer disabled | ||||
expect(amountInputEl).toHaveProperty('disabled', false), | expect(amountInputEl).toHaveProperty('disabled', false), | ||||
); | ); | ||||
await waitFor(() => | await waitFor(() => | ||||
// Amount input is reset | // Amount input is reset | ||||
expect(amountInputEl).toHaveValue(null), | expect(amountInputEl).toHaveValue(null), | ||||
); | ); | ||||
// The multiple recipients switch is now rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The 'Send To' input field has been cleared | // The 'Send To' input field has been cleared | ||||
expect(addressInputEl).toHaveValue(''); | expect(addressInputEl).toHaveValue(''); | ||||
// The Cashtab Message collapse is now rendered because op_return_raw is no longer set | // The Cashtab Message collapse is now rendered because op_return_raw is no longer set | ||||
expect(screen.getByText('Message')).toBeInTheDocument(); | expect(screen.getByText('Message')).toBeInTheDocument(); | ||||
}); | }); | ||||
it('We can calculate max send amount with and without a cashtab msg, and send a max sat tx with a cashtab msg', async () => { | it('We can calculate max send amount with and without a cashtab msg, and send a max sat tx with a cashtab msg', async () => { | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | it('If the user has minFeeSends set to true but no longer has the right token amount, the feature is disabled', async () => { | ||||
await user.type(addressInputEl, addressInput); | await user.type(addressInputEl, addressInput); | ||||
// The 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(addressInput); | expect(addressInputEl).toHaveValue(addressInput); | ||||
// The 'Send To' input field is not disabled | // The 'Send To' input field is not disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', false); | expect(addressInputEl).toHaveProperty('disabled', false); | ||||
// The multiple recipients switch is NOT rendered | // The "Send to Many" switch is disabled | ||||
expect( | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
screen.queryByText('Multiple Recipients:'), | 'disabled', | ||||
).not.toBeInTheDocument(); | true, | ||||
); | |||||
// Amount input is the valid amount param value | // Amount input is the valid amount param value | ||||
expect(amountInputEl).toHaveValue(17); | expect(amountInputEl).toHaveValue(17); | ||||
// The amount input is disabled because it is set by a bip21 query string | // The amount input is disabled because it is set by a bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', true); | expect(amountInputEl).toHaveProperty('disabled', true); | ||||
// No addr validation errors on load | // No addr validation errors on load | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | it('If the user has minFeeSends set to true but no longer has the right token amount, the feature is disabled', async () => { | ||||
// The amount input is no longer disabled | // The amount input is no longer disabled | ||||
expect(amountInputEl).toHaveProperty('disabled', false), | expect(amountInputEl).toHaveProperty('disabled', false), | ||||
); | ); | ||||
await waitFor(() => | await waitFor(() => | ||||
// Amount input is reset | // Amount input is reset | ||||
expect(amountInputEl).toHaveValue(null), | expect(amountInputEl).toHaveValue(null), | ||||
); | ); | ||||
// The multiple recipients switch is now rendered | // The "Send to Many" switch is not disabled | ||||
expect(screen.getByText('Multiple Recipients:')).toBeInTheDocument(); | expect(screen.getByTestId('Send to many')).toHaveProperty( | ||||
'disabled', | |||||
false, | |||||
); | |||||
// The 'Send To' input field has been cleared | // The 'Send To' input field has been cleared | ||||
expect(addressInputEl).toHaveValue(''); | expect(addressInputEl).toHaveValue(''); | ||||
// The Cashtab Message collapse is now rendered because op_return_raw is no longer set | // The Cashtab Message collapse is now rendered because op_return_raw is no longer set | ||||
expect(screen.getByText('Message')).toBeInTheDocument(); | expect(screen.getByText('Message')).toBeInTheDocument(); | ||||
}); | }); | ||||
it('We can send a tx with amount denominated in fiat currency', async () => { | it('We can send a tx with amount denominated in fiat currency', async () => { | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |