From 507a1c0713e19849f432cc01b242c556c1a12c54 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Wed, 1 Nov 2023 15:43:30 +0100 Subject: [PATCH] Fix unit tests --- .../FallbackHandler/__tests__/index.test.tsx | 54 ++----------------- .../settings/FallbackHandler/index.tsx | 4 +- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/src/components/settings/FallbackHandler/__tests__/index.test.tsx b/src/components/settings/FallbackHandler/__tests__/index.test.tsx index 4546a74e75..3c7697a661 100644 --- a/src/components/settings/FallbackHandler/__tests__/index.test.tsx +++ b/src/components/settings/FallbackHandler/__tests__/index.test.tsx @@ -1,4 +1,4 @@ -import { act, fireEvent, render, waitFor } from '@/tests/test-utils' +import { render, waitFor } from '@/tests/test-utils' import * as useSafeInfoHook from '@/hooks/useSafeInfo' import * as useTxBuilderHook from '@/hooks/safe-apps/useTxBuilderApp' @@ -104,7 +104,7 @@ describe('FallbackHandler', () => { }) describe('No Fallback Handler', () => { - it('should render the Fallback Handler and warning tooltip when no Fallback Handler is set', async () => { + it('should render a warning when no Fallback Handler is set', async () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation( () => ({ @@ -117,21 +117,6 @@ describe('FallbackHandler', () => { const fbHandler = render() - await waitFor(() => { - expect(fbHandler.getByText('No fallback handler set')).toBeDefined() - }) - - const icon = fbHandler.getByTestId('fallback-handler-warning') - - await act(() => { - fireEvent( - icon, - new MouseEvent('mouseover', { - bubbles: true, - }), - ) - }) - await waitFor(() => { expect( fbHandler.queryByText( @@ -157,17 +142,6 @@ describe('FallbackHandler', () => { const fbHandler = render() - const icon = fbHandler.getByTestId('fallback-handler-warning') - - await act(() => { - fireEvent( - icon, - new MouseEvent('mouseover', { - bubbles: true, - }), - ) - }) - await waitFor(() => { expect( fbHandler.queryByText( @@ -180,7 +154,7 @@ describe('FallbackHandler', () => { }) describe('Unofficial Fallback Handler', () => { - it('should render placeholder and warning tooltip when an unofficial Fallback Handler is set', async () => { + it('should render placeholder and warning when an unofficial Fallback Handler is set', async () => { jest.spyOn(useSafeInfoHook, 'default').mockImplementation( () => ({ @@ -206,17 +180,6 @@ describe('FallbackHandler', () => { expect(fbHandler.getByText('0x123')).toBeDefined() }) - const icon = fbHandler.getByTestId('fallback-handler-warning') - - await act(() => { - fireEvent( - icon, - new MouseEvent('mouseover', { - bubbles: true, - }), - ) - }) - await waitFor(() => { expect(fbHandler.queryByText(new RegExp('An unofficial fallback handler is currently set.'))) expect(fbHandler.queryByText('Transaction Builder')).toBeInTheDocument() @@ -241,17 +204,6 @@ describe('FallbackHandler', () => { const fbHandler = render() - const icon = fbHandler.getByTestId('fallback-handler-warning') - - await act(() => { - fireEvent( - icon, - new MouseEvent('mouseover', { - bubbles: true, - }), - ) - }) - await waitFor(() => { expect(fbHandler.queryByText(new RegExp('An unofficial fallback handler is currently set.'))) expect(fbHandler.queryByText('Transaction Builder')).not.toBeInTheDocument() diff --git a/src/components/settings/FallbackHandler/index.tsx b/src/components/settings/FallbackHandler/index.tsx index 23a3523ea5..28bd7e09ea 100644 --- a/src/components/settings/FallbackHandler/index.tsx +++ b/src/components/settings/FallbackHandler/index.tsx @@ -31,7 +31,7 @@ export const FallbackHandler = (): ReactElement | null => { const isOfficial = hasFallbackHandler && safe.fallbackHandler?.value === fallbackHandlerDeployment?.networkAddresses[safe.chainId] - const tooltip = !hasFallbackHandler ? ( + const warning = !hasFallbackHandler ? ( <> The {'Safe{Wallet}'} may not work correctly as no fallback handler is currently set. {txBuilder && ( @@ -79,7 +79,7 @@ export const FallbackHandler = (): ReactElement | null => { - {tooltip && {tooltip}} + {warning && {warning}} {safe.fallbackHandler && (