Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/App/__tests__/App.test.js
| Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | it('Renders onboarding screen at home route if user has no wallet', async () => { | ||||
| // Wait for the app to load | // Wait for the app to load | ||||
| await waitFor(() => | await waitFor(() => | ||||
| expect( | expect( | ||||
| screen.queryByTitle('Cashtab Loading'), | screen.queryByTitle('Cashtab Loading'), | ||||
| ).not.toBeInTheDocument(), | ).not.toBeInTheDocument(), | ||||
| ); | ); | ||||
| // We get the Onboarding screen | // We get the Onboarding screen (text may be split across elements) | ||||
| expect( | expect( | ||||
| await screen.findByText('Welcome to Cashtab!'), | await screen.findByText(/Welcome to Cashtab!/), | ||||
| ).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
| }); | }); | ||||
| it('Renders onboarding screen at Receive route if user has no wallet', async () => { | it('Renders onboarding screen at Receive route if user has no wallet', async () => { | ||||
| // This is the experience of a user visiting cashtab.com for the first time | // This is the experience of a user visiting cashtab.com for the first time | ||||
| const mockedChronik = await initializeCashtabStateForTests( | const mockedChronik = await initializeCashtabStateForTests( | ||||
| false, | false, | ||||
| localforage, | localforage, | ||||
| ); | ); | ||||
| render( | render( | ||||
| <CashtabTestWrapper | <CashtabTestWrapper | ||||
| ecc={ecc} | ecc={ecc} | ||||
| chronik={mockedChronik} | chronik={mockedChronik} | ||||
| route="/receive" | route="/receive" | ||||
| />, | />, | ||||
| ); | ); | ||||
| // Wait for the app to load | // Wait for the app to load | ||||
| await waitFor(() => | await waitFor(() => | ||||
| expect( | expect( | ||||
| screen.queryByTitle('Cashtab Loading'), | screen.queryByTitle('Cashtab Loading'), | ||||
| ).not.toBeInTheDocument(), | ).not.toBeInTheDocument(), | ||||
| ); | ); | ||||
| // We get the Onboarding screen | // We get the Onboarding screen (text may be split across elements) | ||||
| expect( | expect( | ||||
| await screen.findByText('Welcome to Cashtab!'), | await screen.findByText(/Welcome to Cashtab!/), | ||||
| ).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
| }); | }); | ||||
| it('Renders onboarding screen even on a bad route if user has no wallet', async () => { | it('Renders onboarding screen even on a bad route if user has no wallet', async () => { | ||||
| // This is the experience of a user visiting cashtab.com for the first time | // This is the experience of a user visiting cashtab.com for the first time | ||||
| const mockedChronik = await initializeCashtabStateForTests( | const mockedChronik = await initializeCashtabStateForTests( | ||||
| false, | false, | ||||
| localforage, | localforage, | ||||
| ); | ); | ||||
| render( | render( | ||||
| <CashtabTestWrapper chronik={mockedChronik} route="/not-a-route" />, | <CashtabTestWrapper chronik={mockedChronik} route="/not-a-route" />, | ||||
| ); | ); | ||||
| // Wait for the app to load | // Wait for the app to load | ||||
| await waitFor(() => | await waitFor(() => | ||||
| expect( | expect( | ||||
| screen.queryByTitle('Cashtab Loading'), | screen.queryByTitle('Cashtab Loading'), | ||||
| ).not.toBeInTheDocument(), | ).not.toBeInTheDocument(), | ||||
| ); | ); | ||||
| // We get the Onboarding screen | // We get the Onboarding screen (text may be split across elements) | ||||
| expect( | expect( | ||||
| await screen.findByText('Welcome to Cashtab!'), | await screen.findByText(/Welcome to Cashtab!/), | ||||
| ).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
| }); | }); | ||||
| it('Renders 404 at bad route if user has a wallet', async () => { | it('Renders 404 at bad route if user has a wallet', async () => { | ||||
| // This is the experience of a user visiting cashtab.com for the first time | // This is the experience of a user visiting cashtab.com for the first time | ||||
| const mockedChronik = await initializeCashtabStateForTests( | const mockedChronik = await initializeCashtabStateForTests( | ||||
| walletWithXecAndTokensActive, | walletWithXecAndTokensActive, | ||||
| localforage, | localforage, | ||||
| ); | ); | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | it('Navigation menu routes to expected components', async () => { | ||||
| // Navigate to Send screen | // Navigate to Send screen | ||||
| await user.click( | await user.click( | ||||
| screen.getByRole('button', { | screen.getByRole('button', { | ||||
| name: /Send Screen/i, | name: /Send Screen/i, | ||||
| }), | }), | ||||
| ); | ); | ||||
| // Now we see the Send screen (we check by confirming presence of the send to many switch) | // Now we see the Send screen (Toggle Multisend was removed; verify Address input) | ||||
| expect(screen.getByTitle('Toggle Multisend')).toBeInTheDocument(); | expect(screen.getByPlaceholderText('Address')).toBeInTheDocument(); | ||||
| // Navigate to eTokens screen | // Navigate to eTokens screen | ||||
| await user.click( | await user.click( | ||||
| screen.getByRole('button', { | screen.getByRole('button', { | ||||
| name: /Tokens/i, | name: /Tokens/i, | ||||
| }), | }), | ||||
| ); | ); | ||||
| // Now we see the eTokens screen | // Now we see the eTokens screen | ||||
| expect(screen.getByTitle('Wallet Tokens')).toBeInTheDocument(); | expect(screen.getByTitle('Wallet Tokens')).toBeInTheDocument(); | ||||
| // Navigate to Receive screen | // Navigate to Agora screen (footer nav changed; hamburger menu commented out) | ||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Receive/i, | |||||
| }), | |||||
| ); | |||||
| // Now we see the Receive screen | |||||
| expect(screen.getByTitle('Receive')).toBeInTheDocument(); | |||||
| // Navigate to Airdrop screen | |||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Airdrop/i, | |||||
| }), | |||||
| ); | |||||
| // Now we see the Airdrop screen | |||||
| expect( | |||||
| screen.getByText('Airdrop scaled to token balance'), | |||||
| ).toBeInTheDocument(); | |||||
| // Navigate to SignVerifyMsg screen | |||||
| await user.click( | await user.click( | ||||
| screen.getByRole('button', { | screen.getByRole('button', { | ||||
| name: /Sign & Verify/i, | name: /Agora/i, | ||||
| }), | |||||
| ); | |||||
| // Now we see the SignVerifyMsg screen | |||||
| expect(screen.getByTitle('Sign & Verify')).toBeInTheDocument(); | |||||
| // Navigate to Settings screen | |||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Settings/i, | |||||
| }), | |||||
| ); | |||||
| // Now we see the Settings screen | |||||
| expect(screen.getByTitle('Settings')).toBeInTheDocument(); | |||||
| // Navigate to Backup screen | |||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Wallet Backup/i, | |||||
| }), | }), | ||||
| ); | ); | ||||
| // Now we see the Backup screen | // Now we see the Agora screen (ActionButtonRow has "Token Market Place") | ||||
| expect( | expect(screen.getByText('Token Market Place')).toBeInTheDocument(); | ||||
| screen.getByText( | |||||
| `ℹ️ Your seed phrase is the only way to restore your wallet. Write it down. Keep it safe.`, | |||||
| ), | |||||
| ).toBeInTheDocument(); | |||||
| // Navigate to Contacts screen | // Navigate to Tools (Contacts) screen | ||||
| await user.click( | await user.click( | ||||
| screen.getByRole('button', { | screen.getByRole('button', { | ||||
| name: /Contacts/i, | name: /Tools/i, | ||||
| }), | }), | ||||
| ); | ); | ||||
| // Now we see the Contacts screen | // Now we see the Contacts screen | ||||
| expect(screen.getByTitle('Contacts')).toBeInTheDocument(); | expect(screen.getByTitle('Contacts')).toBeInTheDocument(); | ||||
| // Navigate to Wallets screen | // Navigate to Settings screen | ||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Wallets/i, | |||||
| }), | |||||
| ); | |||||
| // Now we see the Wallets screen | |||||
| expect(screen.getByTitle('Wallets')).toBeInTheDocument(); | |||||
| // Navigate to Rewards screen | |||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Rewards/i, | |||||
| }), | |||||
| ); | |||||
| // Now we see the Rewards screen | |||||
| expect(screen.getByTitle('Rewards')).toBeInTheDocument(); | |||||
| // Navigate to NFTs screen | |||||
| await user.click( | await user.click( | ||||
| screen.getByRole('button', { | screen.getByRole('button', { | ||||
| name: /NFTs/i, | name: /Settings/i, | ||||
| }), | }), | ||||
| ); | ); | ||||
| // Now we see the NFTs screen | // Now we see the Settings screen (use Display Currency to avoid multiple Settings matches) | ||||
| expect( | expect(screen.getByText('Display Currency')).toBeInTheDocument(); | ||||
| await screen.findByText(/Error querying listed NFTs/), | |||||
| ).toBeInTheDocument(); | |||||
| // Navigate to Agora screen | |||||
| await user.click( | |||||
| screen.getByRole('button', { | |||||
| name: /Agora/i, | |||||
| }), | |||||
| ); | |||||
| // We did not set all the mocks we need but this error confirms our nav destination | // Footer nav verified: Transactions, Send, Tokens, Agora, Tools, Settings | ||||
| expect( | // (Receive, Airdrop, Sign & Verify, Backup, Wallets, Rewards, NFTs are in commented-out hamburger) | ||||
| await screen.findByText(/Error querying listed tokens/), | |||||
| ).toBeInTheDocument(); | |||||
| }); | }); | ||||
| it('Adding a contact to to a new contactList by clicking on tx history adds it to localforage and wallet context', async () => { | it('Adding a contact to to a new contactList by clicking on tx history adds it to localforage and wallet context', async () => { | ||||
| const mockedChronik = await initializeCashtabStateForTests( | const mockedChronik = await initializeCashtabStateForTests( | ||||
| freshWalletWithOneIncomingCashtabMsg, | freshWalletWithOneIncomingCashtabMsg, | ||||
| localforage, | localforage, | ||||
| false, | false, | ||||
| freshWalletWithOneIncomingCashtabMsgTxs, | freshWalletWithOneIncomingCashtabMsgTxs, | ||||
| ); | ); | ||||
| ▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | it('Clicking "reply" on a Cashtab Msg correctly populates the SendXec to address and amount fields', async () => { | ||||
| // Balance is correct | // Balance is correct | ||||
| expect(await screen.findByTitle('Balance XEC')).toHaveTextContent( | expect(await screen.findByTitle('Balance XEC')).toHaveTextContent( | ||||
| '10,000.00 XEC', | '10,000.00 XEC', | ||||
| ); | ); | ||||
| // We do not see the send screen before clicking the button | // We do not see the send screen before clicking the button | ||||
| await waitFor(() => | await waitFor(() => | ||||
| expect( | expect( | ||||
| screen.queryByTitle('Toggle Multisend'), | screen.queryByPlaceholderText('Address'), | ||||
| ).not.toBeInTheDocument(), | ).not.toBeInTheDocument(), | ||||
| ); | ); | ||||
| await user.click(screen.getByTitle('reply')); | await user.click(screen.getByTitle('reply')); | ||||
| // Now we see the Send screen | // Now we see the Send screen (Toggle Multisend was removed; verify Address input) | ||||
| expect( | expect( | ||||
| await screen.findByTitle('Toggle Multisend'), | await screen.findByPlaceholderText('Address'), | ||||
| ).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
| // The SendXec send address input is rendered and has expected value | // The SendXec send address input is rendered and has expected value | ||||
| expect(screen.getByPlaceholderText('Address')).toHaveValue( | expect(screen.getByPlaceholderText('Address')).toHaveValue( | ||||
| 'ecash:qphlhe78677sz227k83hrh542qeehh8el5lcjwk72y', | 'ecash:qphlhe78677sz227k83hrh542qeehh8el5lcjwk72y', | ||||
| ); | ); | ||||
| // The value field is populated with dust | // The value field is populated with dust | ||||
| expect(screen.getByPlaceholderText('Amount')).toHaveValue(5.46); | expect(screen.getByPlaceholderText('Amount')).toHaveValue(5.46); | ||||
| ▲ Show 20 Lines • Show All 940 Lines • Show Last 20 Lines | |||||