Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Send/__tests__/SendByUrlParams.test.js
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | it('Legacy params. Address and value keys are set and valid.', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded, as input fields are not populated until balance loads | // Wait for balance to be loaded, as input fields are not populated until balance loads | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(addressInputEl).toHaveValue(destinationAddress), | expect(addressInputEl).toHaveValue(destinationAddress), | ||||
); | ); | ||||
// The address input is disabled | // The address input is disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | it('Legacy params. Address and value keys are set and valid. Invalid bip21 string is ignored.', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded | // Wait for balance to be loaded | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(addressInputEl).toHaveValue(destinationAddress), | expect(addressInputEl).toHaveValue(destinationAddress), | ||||
); | ); | ||||
// The address input is disabled | // The address input is disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | it('Legacy params. Address field is populated + disabled while value field is empty + enabled if legacy url params have address defined and value present as undefined', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded, as input fields are not populated until balance loads | // Wait for balance to be loaded, as input fields are not populated until balance loads | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(addressInputEl).toHaveValue(destinationAddress), | expect(addressInputEl).toHaveValue(destinationAddress), | ||||
); | ); | ||||
// The address input is disabled | // The address input is disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | it('Legacy params. Address field is populated + disabled while value field is empty + enabled if legacy url params have address defined and no value key present', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded, as input fields are not populated until balance loads | // Wait for balance to be loaded, as input fields are not populated until balance loads | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(addressInputEl).toHaveValue(destinationAddress), | expect(addressInputEl).toHaveValue(destinationAddress), | ||||
); | ); | ||||
// The address input is disabled | // The address input is disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | it('Legacy params. Params are ignored if only value param is present', async () => { | ||||
// Wait for the app to load | // Wait for the app to load | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(screen.queryByTestId('loading-ctn')).not.toBeInTheDocument(), | expect(screen.queryByTestId('loading-ctn')).not.toBeInTheDocument(), | ||||
); | ); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field is untouched | // The 'Send To' input field is untouched | ||||
expect(addressInputEl).toHaveValue(''); | expect(addressInputEl).toHaveValue(''); | ||||
// The address input is not disabled | // The address input is not disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', false); | expect(addressInputEl).toHaveProperty('disabled', false); | ||||
// The amount input is empty | // The amount input is empty | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | it('Legacy params. Params are ignored if param is duplicated', async () => { | ||||
// Wait for the app to load | // Wait for the app to load | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(screen.queryByTestId('loading-ctn')).not.toBeInTheDocument(), | expect(screen.queryByTestId('loading-ctn')).not.toBeInTheDocument(), | ||||
); | ); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field is untouched | // The 'Send To' input field is untouched | ||||
expect(addressInputEl).toHaveValue(''); | expect(addressInputEl).toHaveValue(''); | ||||
// The address input is not disabled | // The address input is not disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', false); | expect(addressInputEl).toHaveProperty('disabled', false); | ||||
// The amount input is empty | // The amount input is empty | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | it('Legacy params are not parsed as bip21 even if the bip21 param appears in the string', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded | // Wait for balance to be loaded | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(addressInputEl).toHaveValue(destinationAddress), | expect(addressInputEl).toHaveValue(destinationAddress), | ||||
); | ); | ||||
// The address input is disabled | // The address input is disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | it('bip21 param - valid bip21 param with amount and op_return_raw is parsed as expected', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded | // Wait for balance to be loaded | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => expect(addressInputEl).toHaveValue(bip21Str)); | await waitFor(() => expect(addressInputEl).toHaveValue(bip21Str)); | ||||
// The address input is disabled for app txs with bip21 strings | // The address input is disabled for app txs with bip21 strings | ||||
// Note it is NOT disabled for txs where the user inputs the bip21 string | // Note it is NOT disabled for txs where the user inputs the bip21 string | ||||
// This is covered in SendXec.test.js | // This is covered in SendXec.test.js | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
// 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(amount); | expect(amountInputEl).toHaveValue(amount); | ||||
// 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 61 Lines • ▼ Show 20 Lines | it('bip21 param - an invalid bip21 param shows validation errors but cannot be changed', async () => { | ||||
); | ); | ||||
// Wait for balance to be loaded, as input fields are not populated until balance loads | // Wait for balance to be loaded, as input fields are not populated until balance loads | ||||
expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | expect(await screen.findByText('9,513.12 XEC')).toBeInTheDocument(); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
await waitFor(() => expect(addressInputEl).toHaveValue(bip21Str)); | await waitFor(() => expect(addressInputEl).toHaveValue(bip21Str)); | ||||
// The address input is disabled for app txs with bip21 strings | // The address input is disabled for app txs with bip21 strings | ||||
// Note it is NOT disabled for txs where the user inputs the bip21 string | // Note it is NOT disabled for txs where the user inputs the bip21 string | ||||
// This is covered in SendXec.test.js | // This is covered in SendXec.test.js | ||||
expect(addressInputEl).toHaveProperty('disabled', true); | expect(addressInputEl).toHaveProperty('disabled', true); | ||||
// 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 not updated as the bip21 query is invalid | // Amount input is not updated as the bip21 query is invalid | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
// The amount input is not disabled because it is not set by the invalid bip21 query string | // The amount input is not disabled because it is not set by the invalid bip21 query string | ||||
expect(amountInputEl).toHaveProperty('disabled', false); | expect(amountInputEl).toHaveProperty('disabled', false); | ||||
// We get the expected validation error | // We get the expected validation error | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | it('No params. Send screen loads normally with no rendered input.', async () => { | ||||
// Wait for the app to load | // Wait for the app to load | ||||
await waitFor(() => | await waitFor(() => | ||||
expect(screen.queryByTestId('loading-ctn')).not.toBeInTheDocument(), | expect(screen.queryByTestId('loading-ctn')).not.toBeInTheDocument(), | ||||
); | ); | ||||
const addressInputEl = screen.getByPlaceholderText('Address'); | const addressInputEl = screen.getByPlaceholderText('Address'); | ||||
const amountInputEl = screen.getByPlaceholderText('Amount'); | const amountInputEl = screen.getByPlaceholderText('Amount'); | ||||
// 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 'Send To' input field has this address as a value | // The 'Send To' input field has this address as a value | ||||
expect(addressInputEl).toHaveValue(''); | expect(addressInputEl).toHaveValue(''); | ||||
// The address input is not disabled | // The address input is not disabled | ||||
expect(addressInputEl).toHaveProperty('disabled', false); | expect(addressInputEl).toHaveProperty('disabled', false); | ||||
// The amount input is empty | // The amount input is empty | ||||
expect(amountInputEl).toHaveValue(null); | expect(amountInputEl).toHaveValue(null); | ||||
Show All 26 Lines |