From b8f09261f0121e26dc5c14aad4a3ffb01c88c91c Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 18 Nov 2024 22:45:32 -0800 Subject: [PATCH] fixed flakey tx test --- .../components/TransactionProvider.test.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/transaction/components/TransactionProvider.test.tsx b/src/transaction/components/TransactionProvider.test.tsx index 0d8d7c2bee..db9a15b987 100644 --- a/src/transaction/components/TransactionProvider.test.tsx +++ b/src/transaction/components/TransactionProvider.test.tsx @@ -289,6 +289,12 @@ describe('TransactionProvider', () => { }); it('should emit onError when legacy transactions fail', async () => { + // need to mock sendWalletTransactions to prevent lifecycleStatus from being + // set to 'error' when sendWalletTransactions is called + const sendWalletTransactionsMock = vi.fn().mockResolvedValue(undefined); + (useSendWalletTransactions as ReturnType).mockReturnValue( + sendWalletTransactionsMock, + ); const onErrorMock = vi.fn(); (waitForTransactionReceipt as ReturnType).mockRejectedValue( new Error('error getting transaction receipt'), @@ -309,7 +315,12 @@ describe('TransactionProvider', () => { ); fireEvent.click(button); await waitFor(() => { - expect(onErrorMock).toHaveBeenCalled(); + expect(sendWalletTransactionsMock).toHaveBeenCalled(); + expect(onErrorMock).toHaveBeenCalledWith({ + code: 'TmTPc01', + error: '{}', + message: 'Something went wrong. Please try again.', + }); }); });