From c0404aeb8d3306c97cd28c27d4e1eec5002ab3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Thu, 2 May 2024 19:01:47 -0300 Subject: [PATCH] test: add queryclientprovider to fix errors --- src/CourseAuthoringPage.test.jsx | 11 ++++++++--- src/CourseAuthoringRoutes.test.jsx | 15 ++++++++++++--- src/accessibility-page/AccessibilityPage.test.jsx | 7 ++++++- src/course-rerun/CourseRerun.test.jsx | 11 ++++++++--- src/studio-home/StudioHome.test.jsx | 11 ++++++++--- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/CourseAuthoringPage.test.jsx b/src/CourseAuthoringPage.test.jsx index c7eeeb9be8..e43af91de4 100644 --- a/src/CourseAuthoringPage.test.jsx +++ b/src/CourseAuthoringPage.test.jsx @@ -7,6 +7,7 @@ import MockAdapter from 'axios-mock-adapter'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { AppProvider } from '@edx/frontend-platform/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import initializeStore from './store'; import CourseAuthoringPage from './CourseAuthoringPage'; import PagesAndResources from './pages-and-resources/PagesAndResources'; @@ -38,6 +39,8 @@ beforeEach(() => { axiosMock = new MockAdapter(getAuthenticatedHttpClient()); }); +const queryClient = new QueryClient(); + describe('Editor Pages Load no header', () => { const mockStoreSuccess = async () => { const apiBaseUrl = getConfig().STUDIO_BASE_URL; @@ -53,9 +56,11 @@ describe('Editor Pages Load no header', () => { const wrapper = render( - - - + + + + + , diff --git a/src/CourseAuthoringRoutes.test.jsx b/src/CourseAuthoringRoutes.test.jsx index 3a38fe7c24..953174a8ab 100644 --- a/src/CourseAuthoringRoutes.test.jsx +++ b/src/CourseAuthoringRoutes.test.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { AppProvider } from '@edx/frontend-platform/react'; import { initializeMockApp } from '@edx/frontend-platform'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import { render, screen } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import CourseAuthoringRoutes from './CourseAuthoringRoutes'; @@ -48,6 +49,8 @@ jest.mock('./custom-pages/CustomPages', () => (props) => { return customPagesMockText; }); +const queryClient = new QueryClient(); + describe('', () => { beforeEach(() => { initializeMockApp({ @@ -65,7 +68,9 @@ describe('', () => { render( - + + + , ); @@ -82,7 +87,9 @@ describe('', () => { render( - + + + , ); @@ -100,7 +107,9 @@ describe('', () => { render( - + + + , ); diff --git a/src/accessibility-page/AccessibilityPage.test.jsx b/src/accessibility-page/AccessibilityPage.test.jsx index f686daf4d5..d974a5989a 100644 --- a/src/accessibility-page/AccessibilityPage.test.jsx +++ b/src/accessibility-page/AccessibilityPage.test.jsx @@ -5,6 +5,7 @@ import { import { AppProvider } from '@edx/frontend-platform/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { initializeMockApp } from '@edx/frontend-platform'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import initializeStore from '../store'; import AccessibilityPage from './index'; @@ -15,11 +16,15 @@ const initialState = { }; let store; +const queryClient = new QueryClient(); + const renderComponent = () => { render( - + + + , ); diff --git a/src/course-rerun/CourseRerun.test.jsx b/src/course-rerun/CourseRerun.test.jsx index 9c403b368b..85d9073044 100644 --- a/src/course-rerun/CourseRerun.test.jsx +++ b/src/course-rerun/CourseRerun.test.jsx @@ -3,6 +3,7 @@ import { useSelector } from 'react-redux'; import { MemoryRouter } from 'react-router-dom'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { initializeMockApp } from '@edx/frontend-platform'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import { IntlProvider, injectIntl } from '@edx/frontend-platform/i18n'; import { AppProvider } from '@edx/frontend-platform/react'; import { @@ -33,12 +34,16 @@ jest.mock('react-router-dom', () => ({ }), })); +const queryClient = new QueryClient(); + const RootWrapper = () => ( - - - + + + + + ); diff --git a/src/studio-home/StudioHome.test.jsx b/src/studio-home/StudioHome.test.jsx index 7286acda0f..5b103263b4 100644 --- a/src/studio-home/StudioHome.test.jsx +++ b/src/studio-home/StudioHome.test.jsx @@ -3,6 +3,7 @@ import { useSelector } from 'react-redux'; import { initializeMockApp } from '@edx/frontend-platform'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { IntlProvider, injectIntl } from '@edx/frontend-platform/i18n'; +import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import { AppProvider } from '@edx/frontend-platform/react'; import { act, fireEvent, render, waitFor, @@ -41,11 +42,15 @@ jest.mock('react-router-dom', () => ({ }), })); +const queryClient = new QueryClient(); + const RootWrapper = () => ( - - - + + + + + );