From 08884f16af2b58171fb3273f0054c7a4f9450fc1 Mon Sep 17 00:00:00 2001 From: Tom Ratcliffe Date: Mon, 13 May 2024 11:03:21 +0100 Subject: [PATCH] Chore: Remove redux-rtl test helper (#87596) --- .../components/Signup/SignupPage.test.tsx | 4 +-- .../Signup/VerifyEmailPage.test.tsx | 8 ++--- .../features/auth-config/AuthDrawer.test.tsx | 3 +- .../log-context/LogRowContextModal.test.tsx | 4 +-- public/test/redux-rtl.tsx | 31 ------------------- 5 files changed, 6 insertions(+), 44 deletions(-) delete mode 100644 public/test/redux-rtl.tsx diff --git a/public/app/core/components/Signup/SignupPage.test.tsx b/public/app/core/components/Signup/SignupPage.test.tsx index 5c2a0ffb468..96b4c84be49 100644 --- a/public/app/core/components/Signup/SignupPage.test.tsx +++ b/public/app/core/components/Signup/SignupPage.test.tsx @@ -1,7 +1,5 @@ -import { fireEvent, screen, waitFor } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import React from 'react'; -import { render } from 'test/redux-rtl'; +import { render, fireEvent, screen, waitFor, userEvent } from 'test/test-utils'; import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; diff --git a/public/app/core/components/Signup/VerifyEmailPage.test.tsx b/public/app/core/components/Signup/VerifyEmailPage.test.tsx index ebdf201e9cd..424a7a6edd9 100644 --- a/public/app/core/components/Signup/VerifyEmailPage.test.tsx +++ b/public/app/core/components/Signup/VerifyEmailPage.test.tsx @@ -1,7 +1,5 @@ -import { fireEvent, screen, waitFor } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import React from 'react'; -import { render } from 'test/redux-rtl'; +import { render, fireEvent, screen, waitFor, userEvent } from 'test/test-utils'; import { VerifyEmailPage } from './VerifyEmailPage'; @@ -46,10 +44,10 @@ describe('VerifyEmail Page', () => { expect(await screen.findByText('Email is required')).toBeInTheDocument(); await userEvent.type(screen.getByRole('textbox', { name: /Email/i }), 'test'); - await waitFor(() => expect(screen.queryByText('Email is invalid')).toBeInTheDocument()); + expect(await screen.findByText('Email is invalid')).toBeInTheDocument(); await userEvent.type(screen.getByRole('textbox', { name: /Email/i }), 'test@gmail.com'); - await waitFor(() => expect(screen.queryByText('Email is invalid')).not.toBeInTheDocument()); + expect(screen.queryByText('Email is invalid')).not.toBeInTheDocument(); }); it('should show complete signup if email-verification is successful', async () => { postMock.mockResolvedValueOnce({ message: 'SignUpCreated' }); diff --git a/public/app/features/auth-config/AuthDrawer.test.tsx b/public/app/features/auth-config/AuthDrawer.test.tsx index 35a0fc87287..9578d7a777d 100644 --- a/public/app/features/auth-config/AuthDrawer.test.tsx +++ b/public/app/features/auth-config/AuthDrawer.test.tsx @@ -1,6 +1,5 @@ -import { screen } from '@testing-library/react'; import React from 'react'; -import { render } from 'test/redux-rtl'; +import { render, screen } from 'test/test-utils'; import { AuthDrawerUnconnected, Props } from './AuthDrawer'; diff --git a/public/app/features/logs/components/log-context/LogRowContextModal.test.tsx b/public/app/features/logs/components/log-context/LogRowContextModal.test.tsx index a7995848129..37bb407c7f4 100644 --- a/public/app/features/logs/components/log-context/LogRowContextModal.test.tsx +++ b/public/app/features/logs/components/log-context/LogRowContextModal.test.tsx @@ -1,7 +1,5 @@ -import { screen, waitFor, fireEvent } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import React from 'react'; -import { render } from 'test/redux-rtl'; +import { render, screen, waitFor, fireEvent, userEvent } from 'test/test-utils'; import { createDataFrame, diff --git a/public/test/redux-rtl.tsx b/public/test/redux-rtl.tsx deleted file mode 100644 index 2999aa0efb4..00000000000 --- a/public/test/redux-rtl.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { configureStore } from '@reduxjs/toolkit'; -import { render as rtlRender } from '@testing-library/react'; -import React from 'react'; -import { Provider } from 'react-redux'; - -import { createRootReducer } from 'app/core/reducers/root'; -import { StoreState } from 'app/types'; - -import { mockNavModel } from './mocks/navModel'; - -function render( - ui: React.ReactElement, - { - preloadedState = { navIndex: mockNavModel }, - store = configureStore({ - reducer: createRootReducer(), - preloadedState, - middleware: (getDefaultMiddleware) => - getDefaultMiddleware({ thunk: true, serializableCheck: false, immutableCheck: false }), - }), - ...renderOptions - }: { preloadedState?: Partial; store?: ReturnType } = {} -) { - function Wrapper({ children }: { children: React.ReactNode }) { - return {children}; - } - - return rtlRender(ui, { wrapper: Wrapper, ...renderOptions }); -} - -export { render };