Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Home/__tests__/Home.test.tsx
| Show First 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | it('Renders backup warning, token rewards button, and QR Code if user loads with a new wallet that is not the only wallet', async () => { | ||||
| // Backup warning is rendered | // Backup warning is rendered | ||||
| await screen.findByText('Backup your wallet'); | await screen.findByText('Backup your wallet'); | ||||
| await screen.findByText( | await screen.findByText( | ||||
| 'Write down your 12-word seed and keep it in a safe place.', | 'Write down your 12-word seed and keep it in a safe place.', | ||||
| ); | ); | ||||
| await screen.findByText('Do not share your backup with anyone.'); | await screen.findByText('Do not share your backup with anyone.'); | ||||
| // Token rewards button is present | // Token rewards button is present (multiple wallets) | ||||
| const tokenRewardsButton = screen.getByRole('button', { | const tokenRewardsButton = screen.getByRole('button', { | ||||
| name: /Claim Token Rewards/, | name: /You've earned Token Rewards/, | ||||
| }); | }); | ||||
| expect(tokenRewardsButton).toBeInTheDocument(); | expect(tokenRewardsButton).toBeInTheDocument(); | ||||
| // Free XEC button is not present, because the user has more than 1 wallet | // Free XEC button is not present, because the user has more than 1 wallet | ||||
| expect( | expect( | ||||
| screen.queryByRole('button', { | screen.queryByRole('button', { | ||||
| name: /Claim Free XEC/, | name: /Free XEC Welcome Bonus/, | ||||
| }), | }), | ||||
| ).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
| // Token rewards button button is NOT disabled | // Token rewards button button is NOT disabled | ||||
| expect(tokenRewardsButton).toHaveProperty('disabled', false); | expect(tokenRewardsButton).toHaveProperty('disabled', false); | ||||
| // Receive QR code is rendered | // Receive link is rendered (ActionButtonRow on Home) | ||||
| expect(screen.getByTitle('Receive')).toBeInTheDocument(); | expect( | ||||
| screen.getByRole('link', { name: /Receive/ }), | |||||
| ).toBeInTheDocument(); | |||||
| // We can claim an airdrop on a new wallet | // We can claim an airdrop on a new wallet | ||||
| await user.click(tokenRewardsButton); | await user.click(tokenRewardsButton); | ||||
| // Token rewards button is disabled after clicking for claim | // Token rewards button is disabled after clicking for claim | ||||
| expect(tokenRewardsButton).toBeDisabled(); | expect(tokenRewardsButton).toBeDisabled(); | ||||
| // We see a toast for the successful rewards claim | // We see a toast for the successful rewards claim | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | it('Renders backup warning, Airdrop button, and QR Code if user loads with a new wallet that is the only created wallet', async () => { | ||||
| // isNewishWallet info is NOT displayed (no tx history) | // isNewishWallet info is NOT displayed (no tx history) | ||||
| expect( | expect( | ||||
| screen.queryByText(/Nice, you have some eCash. What can you do?/), | screen.queryByText(/Nice, you have some eCash. What can you do?/), | ||||
| ).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
| // reCAPTCHA component is rendered for XEC airdrop | // reCAPTCHA component is rendered for XEC airdrop | ||||
| expect(screen.getByTestId('mock-recaptcha')).toBeInTheDocument(); | expect(screen.getByTestId('mock-recaptcha')).toBeInTheDocument(); | ||||
| // Airdrop button is present | // Airdrop button is present (single wallet) | ||||
| const airdropButton = screen.getByRole('button', { | const airdropButton = screen.getByRole('button', { | ||||
| name: /Claim Free XEC/, | name: /Free XEC Welcome Bonus/, | ||||
| }); | }); | ||||
| expect(airdropButton).toBeInTheDocument(); | expect(airdropButton).toBeInTheDocument(); | ||||
| // Claim token rewards button is not present, because the user has only 1 wallet | // Claim token rewards button is not present, because the user has only 1 wallet | ||||
| expect( | expect( | ||||
| screen.queryByRole('button', { | screen.queryByRole('button', { | ||||
| name: /Claim Token Rewards/, | name: /You've earned Token Rewards/, | ||||
| }), | }), | ||||
| ).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
| // Airdrop button is NOT disabled (reCAPTCHA token is present) | // Airdrop button is NOT disabled (reCAPTCHA token is present) | ||||
| expect(airdropButton).toHaveProperty('disabled', false); | expect(airdropButton).toHaveProperty('disabled', false); | ||||
| // Receive QR code is rendered | // Receive link is rendered (ActionButtonRow on Home) | ||||
| expect(screen.getByTitle('Receive')).toBeInTheDocument(); | expect( | ||||
| screen.getByRole('link', { name: /Receive/ }), | |||||
| ).toBeInTheDocument(); | |||||
| // We can claim an airdrop on a new wallet | // We can claim an airdrop on a new wallet | ||||
| await user.click(airdropButton); | await user.click(airdropButton); | ||||
| // Airdrop button is disabled after clicking for claim | // Airdrop button is disabled after clicking for claim | ||||
| await waitFor(() => { | await waitFor(() => { | ||||
| expect(airdropButton).toHaveProperty('disabled', true); | expect(airdropButton).toHaveProperty('disabled', true); | ||||
| }); | }); | ||||
| ▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines | |||||