From 0f2c3c9aac198885a63afae849477e6db5b9046c Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Thu, 16 Nov 2023 13:25:03 +0100 Subject: [PATCH] feat(ui): show rescanning alert on Wallets page --- src/components/Wallets.test.tsx | 21 +++++++++++++++++++-- src/components/Wallets.tsx | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/Wallets.test.tsx b/src/components/Wallets.test.tsx index d74bce08..18dfbe9c 100644 --- a/src/components/Wallets.test.tsx +++ b/src/components/Wallets.test.tsx @@ -6,7 +6,6 @@ import user from '@testing-library/user-event' import * as apiMock from '../libs/JmWalletApi' import Wallets from './Wallets' -import { walletDisplayName } from '../utils' import { CurrentWallet } from '../context/WalletContext' jest.mock('../libs/JmWalletApi', () => ({ @@ -44,7 +43,7 @@ describe('', () => { ;(apiMock.getGetinfo as jest.Mock).mockResolvedValue(neverResolvingPromise) }) - it('should render without errors', () => { + it('should display loading indicator while fetching data', () => { const neverResolvingPromise = new Promise(() => {}) ;(apiMock.getSession as jest.Mock).mockResolvedValueOnce(neverResolvingPromise) ;(apiMock.getWalletAll as jest.Mock).mockResolvedValueOnce(neverResolvingPromise) @@ -75,6 +74,24 @@ describe('', () => { expect(screen.getByText('wallets.button_new_wallet')).toBeInTheDocument() }) + it('should display alert when rescanning is active', async () => { + ;(apiMock.getWalletAll as jest.Mock).mockResolvedValueOnce({ + ok: false, + }) + ;(apiMock.getSession as jest.Mock).mockResolvedValueOnce({ + ok: true, + json: () => + Promise.resolve({ + rescanning: true, + }), + }) + + await act(async () => setup({})) + + expect(screen.getByText('wallets.title')).toBeVisible() + expect(screen.getByTestId('alert-rescanning')).toBeVisible() + }) + it('should display big call-to-action buttons if no wallet has been created yet', async () => { ;(apiMock.getSession as jest.Mock).mockResolvedValueOnce({ ok: true, diff --git a/src/components/Wallets.tsx b/src/components/Wallets.tsx index 9b4d686c..dbead45c 100644 --- a/src/components/Wallets.tsx +++ b/src/components/Wallets.tsx @@ -210,6 +210,11 @@ export default function Wallets({ currentWallet, startWallet, stopWallet }: Wall subtitle={walletList?.length === 0 ? t('wallets.subtitle_no_wallets') : undefined} center={true} /> + {serviceInfo?.rescanning === true && ( + + {t('app.alert_rescan_in_progress')} + + )} {alert && } {isLoading ? (