From bcd33d0bbd998c666f1bc99649a258ae280ff6a7 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Fri, 8 Sep 2023 16:41:44 +0200 Subject: [PATCH] test: verify import wallet is not displayed --- src/components/Wallets.test.jsx | 42 +++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/components/Wallets.test.jsx b/src/components/Wallets.test.jsx index 8ab76a5a5..802c78985 100644 --- a/src/components/Wallets.test.jsx +++ b/src/components/Wallets.test.jsx @@ -39,10 +39,7 @@ describe('', () => { beforeEach(() => { const neverResolvingPromise = new Promise(() => {}) apiMock.getSession.mockResolvedValue(neverResolvingPromise) - apiMock.getGetinfo.mockResolvedValue({ - ok: true, - json: () => Promise.resolve({ version: '0.9.10dev' }), - }) + apiMock.getGetinfo.mockResolvedValue(neverResolvingPromise) }) it('should render without errors', () => { @@ -91,6 +88,10 @@ describe('', () => { ok: true, json: () => Promise.resolve({ wallets: [] }), }) + apiMock.getGetinfo.mockResolvedValueOnce({ + ok: true, + json: () => Promise.resolve({ version: '0.9.10dev' }), + }) act(() => setup({})) @@ -126,6 +127,10 @@ describe('', () => { ok: true, json: () => Promise.resolve({ wallets: ['wallet0.jmdat', 'wallet1.jmdat'] }), }) + apiMock.getGetinfo.mockResolvedValueOnce({ + ok: true, + json: () => Promise.resolve({ version: '0.9.10dev' }), + }) act(() => setup({})) @@ -146,6 +151,35 @@ describe('', () => { expect(importWalletButton.classList.contains('btn-lg')).toBe(false) }) + it('should hide "Import Wallet"-button on unsupported backend version', async () => { + apiMock.getSession.mockResolvedValueOnce({ + ok: true, + json: () => + Promise.resolve({ + session: false, + maker_running: false, + coinjoin_in_process: false, + wallet_name: 'None', + }), + }) + apiMock.getWalletAll.mockResolvedValueOnce({ + ok: true, + json: () => Promise.resolve({ wallets: [] }), + }) + apiMock.getGetinfo.mockResolvedValueOnce({ + ok: true, + json: () => Promise.resolve({ version: '0.9.9' }), + }) + + act(() => setup({})) + + expect(screen.getByText('wallets.text_loading')).toBeInTheDocument() + await waitForElementToBeRemoved(screen.getByText('wallets.text_loading')) + + expect(screen.queryByTestId('import-wallet-btn')).not.toBeInTheDocument() + expect(screen.getByTestId('new-wallet-btn')).toBeInTheDocument() + }) + describe(' lock/unlock flow', () => { const dummyWalletName = 'dummy.jmdat' const dummyToken = 'dummyToken'