From 8013ee7dae19299398453d9f0c668be8d37522ae Mon Sep 17 00:00:00 2001 From: Niranjana Binoy <43930900+NiranjanaBinoy@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:39:29 -0400 Subject: [PATCH] updating unit test --- .../delete-metametrics-data-button.test.tsx | 75 ++++++++++--------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/ui/pages/settings/security-tab/delete-metametrics-data-button/delete-metametrics-data-button.test.tsx b/ui/pages/settings/security-tab/delete-metametrics-data-button/delete-metametrics-data-button.test.tsx index d9eeb6cbf5cd..27132fb82f5c 100644 --- a/ui/pages/settings/security-tab/delete-metametrics-data-button/delete-metametrics-data-button.test.tsx +++ b/ui/pages/settings/security-tab/delete-metametrics-data-button/delete-metametrics-data-button.test.tsx @@ -47,22 +47,22 @@ describe('DeleteMetaMetricsDataButton', () => { it('renders correctly', () => { const store = configureStore({}); - const { getByText, getByTestId, getAllByText } = renderWithProvider( + const { getByTestId, getAllByText, container } = renderWithProvider( , store, ); expect(getByTestId('delete-metametrics-data-button')).toBeInTheDocument(); expect(getAllByText('Delete MetaMetrics data')).toHaveLength(2); expect( - getByText( - /This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-description') + ?.textContent, + ).toMatchInlineSnapshot( + `" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`, + ); }); - it('should enable the data deletion button when metrics is opted in and metametrics id is available ', async () => { const store = configureStore({}); - const { getByRole, getByText } = renderWithProvider( + const { getByRole, container } = renderWithProvider( , store, ); @@ -70,10 +70,11 @@ describe('DeleteMetaMetricsDataButton', () => { getByRole('button', { name: 'Delete MetaMetrics data' }), ).toBeEnabled(); expect( - getByText( - /This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-description') + ?.textContent, + ).toMatchInlineSnapshot( + `" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`, + ); }); it('should enable the data deletion button when page mounts after a deletion task is performed and more data is recoded after the deletion', async () => { useSelectorMock.mockImplementation((selector) => { @@ -86,7 +87,7 @@ describe('DeleteMetaMetricsDataButton', () => { return undefined; }); const store = configureStore({}); - const { getByRole, getByText } = renderWithProvider( + const { getByRole, container } = renderWithProvider( , store, ); @@ -94,10 +95,11 @@ describe('DeleteMetaMetricsDataButton', () => { getByRole('button', { name: 'Delete MetaMetrics data' }), ).toBeEnabled(); expect( - getByText( - /This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-description') + ?.textContent, + ).toMatchInlineSnapshot( + `" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`, + ); }); // if user does not opt in to participate in metrics or for profile sync, metametricsId will not be created. @@ -109,7 +111,7 @@ describe('DeleteMetaMetricsDataButton', () => { return undefined; }); const store = configureStore({}); - const { getByRole, getByText } = renderWithProvider( + const { getByRole, container } = renderWithProvider( , store, ); @@ -117,15 +119,16 @@ describe('DeleteMetaMetricsDataButton', () => { getByRole('button', { name: 'Delete MetaMetrics data' }), ).toBeDisabled(); expect( - getByText( - /This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-description') + ?.textContent, + ).toMatchInlineSnapshot( + `" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`, + ); expect( - getByText( - /Since you've never opted into MetaMetrics, there's no data to delete here./u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-item-col')?.textContent, + ).toMatchInlineSnapshot( + `"Since you've never opted into MetaMetrics, there's no data to delete here.Delete MetaMetrics data"`, + ); }); // particilapteInMetrics will be false before the deletion is performed, this way no further data will be recorded after deletion. @@ -146,7 +149,7 @@ describe('DeleteMetaMetricsDataButton', () => { return undefined; }); const store = configureStore({}); - const { getByRole, getByText } = renderWithProvider( + const { getByRole, container } = renderWithProvider( , store, ); @@ -154,10 +157,11 @@ describe('DeleteMetaMetricsDataButton', () => { getByRole('button', { name: 'Delete MetaMetrics data' }), ).toBeDisabled(); expect( - getByText( - /You initiated this action on 7\/06\/2024. This process can take up to 30 days. View the/u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-description') + ?.textContent, + ).toMatchInlineSnapshot( + `" You initiated this action on 7/06/2024. This process can take up to 30 days. View the Privacy policy "`, + ); }); // particilapteInMetrics will be false before the deletion is performed, this way no further data will be recorded after deletion. @@ -178,7 +182,7 @@ describe('DeleteMetaMetricsDataButton', () => { return undefined; }); const store = configureStore({}); - const { getByRole, getByText } = renderWithProvider( + const { getByRole, container } = renderWithProvider( , store, ); @@ -186,10 +190,11 @@ describe('DeleteMetaMetricsDataButton', () => { getByRole('button', { name: 'Delete MetaMetrics data' }), ).toBeDisabled(); expect( - getByText( - /You initiated this action on 7\/06\/2024. This process can take up to 30 days. View the/u, - ), - ).toBeInTheDocument(); + container.querySelector('.settings-page__content-description') + ?.textContent, + ).toMatchInlineSnapshot( + `" You initiated this action on 7/06/2024. This process can take up to 30 days. View the Privacy policy "`, + ); }); it('should open the modal on the button click', () => {