diff --git a/apps/web/src/components/tx/confirmation-views/UpdateSafe/__snapshots__/index.test.tsx.snap b/apps/web/src/components/tx/confirmation-views/UpdateSafe/__snapshots__/index.test.tsx.snap new file mode 100644 index 0000000000..38ff722d34 --- /dev/null +++ b/apps/web/src/components/tx/confirmation-views/UpdateSafe/__snapshots__/index.test.tsx.snap @@ -0,0 +1,925 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Container renders correctly with a queue warning 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+ +
+
+ , + "container":
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`Container renders correctly without a queue warning because no queue 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+ +
+
+ , + "container":
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`Container renders correctly without a queue warning because no queue 2`] = ` +{ + "asFragment": [Function], + "baseElement": +
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+ +
+
+
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+
+
+ , + "container":
+
+
+ Current version: + 1.1.1 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`Container renders correctly without a queue warning because of compatible Safe version 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
+
+
+ Current version: + 1.3.0 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+
+
+ , + "container":
+
+
+ Current version: + 1.3.0 +
+
+ → +
+
+ New version: + 1.4.1 +
+
+

+ Read about the updates in the new Safe contracts version in the + + + + version + 1.4.1 + changelog + + + +

+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; diff --git a/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.test.tsx b/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.test.tsx new file mode 100644 index 0000000000..2067d03c71 --- /dev/null +++ b/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.test.tsx @@ -0,0 +1,35 @@ +import type { ChainInfo } from '@safe-global/safe-gateway-typescript-sdk' +import { _UpdateSafe as UpdateSafe } from './index' +import { render } from '@/tests/test-utils' + +const chain = { + recommendedMasterCopyVersion: '1.4.1' +} as ChainInfo + +describe('Container', () => { + it('renders correctly with a queue warning', () => { + const container = render( + + ) + expect(container).toMatchSnapshot() + }) + + it('renders correctly without a queue warning because no queue', () => { + const container = render( + + ) + expect(container).toMatchSnapshot() + + const container2 = render( + , + ) + expect(container2).toMatchSnapshot() + }) + + it('renders correctly without a queue warning because of compatible Safe version', () => { + const container = render( + , + ) + expect(container).toMatchSnapshot() + }) +}) diff --git a/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.tsx b/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.tsx index 9a8af7605a..28955161c0 100644 --- a/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.tsx +++ b/apps/web/src/components/tx/confirmation-views/UpdateSafe/index.tsx @@ -7,6 +7,7 @@ import useSafeInfo from '@/hooks/useSafeInfo' import { useQueuedTxsLength } from '@/hooks/useTxQueue' import ExternalLink from '@/components/common/ExternalLink' import { maybePlural } from '@/utils/formatters' +import madProps from '@/utils/mad-props' const QUEUE_WARNING_VERSION = '<1.3.0' @@ -26,11 +27,11 @@ function BgBox({ children, light }: { children: ReactNode; light?: boolean }) { ) } -function UpdateSafe() { - const { safe } = useSafeInfo() - const chain = useCurrentChain() - const queueSize = useQueuedTxsLength() - const safeVersion = safe?.version || '' +export function _UpdateSafe({ safeVersion, queueSize, chain }: { + safeVersion: string, + queueSize: string, + chain: ReturnType +}) { const showQueueWarning = queueSize && semverSatisfies(safeVersion, QUEUE_WARNING_VERSION) const latestSafeVersion = chain?.recommendedMasterCopyVersion || LATEST_SAFE_VERSION @@ -62,4 +63,16 @@ function UpdateSafe() { ) } + +function useSafeVersion() { + const { safe } = useSafeInfo() + return safe?.version || '' +} + +const UpdateSafe = madProps(_UpdateSafe, { + chain: useCurrentChain, + safeVersion: useSafeVersion, + queueSize: useQueuedTxsLength, +}) + export default UpdateSafe