diff --git a/src/transaction/components/TransactionButton.test.tsx b/src/transaction/components/TransactionButton.test.tsx index 6bd2c873d3..b305945fde 100644 --- a/src/transaction/components/TransactionButton.test.tsx +++ b/src/transaction/components/TransactionButton.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { useChainId } from 'wagmi'; import { useShowCallsStatus } from 'wagmi/experimental'; @@ -97,4 +97,34 @@ describe('TransactionButton', () => { const button = getByRole('button'); expect(button).toBeDisabled(); }); + + it('should call showCallsStatus when receipt and transactionId exist', () => { + const showCallsStatus = vi.fn(); + (useShowCallsStatus as vi.Mock).mockReturnValue({ showCallsStatus }); + (useTransactionContext as vi.Mock).mockReturnValue({ + receipt: '123', + transactionId: '456', + }); + + render(); + const button = screen.getByText('View transaction'); + fireEvent.click(button); + + expect(showCallsStatus).toHaveBeenCalledWith({ id: '456' }); + }); + + it('should enable button when not in progress, not missing props, and not waiting for receipt', () => { + (useTransactionContext as vi.Mock).mockReturnValue({ + isLoading: false, + contracts: {}, + address: '0x123', + transactionId: undefined, + transactionHash: undefined, + receipt: undefined, + }); + + const { getByRole } = render(); + const button = getByRole('button'); + expect(button).not.toBeDisabled(); + }); });