@@ -4,9 +4,9 @@ import CourseAuthoringPage from './CourseAuthoringPage';
44import PagesAndResources from './pages-and-resources/PagesAndResources' ;
55import { executeThunk } from './utils' ;
66import { fetchCourseApps } from './pages-and-resources/data/thunks' ;
7- import { fetchCourseDetail } from './data/thunks' ;
87import { getApiWaffleFlagsUrl } from './data/api' ;
98import { initializeMocks , render } from './testUtils' ;
9+ import { CourseAuthoringProvider } from './CourseAuthoringContext' ;
1010
1111const courseId = 'course-v1:edX+TestX+Test_Course' ;
1212let mockPathname = '/evilguy/' ;
@@ -19,6 +19,12 @@ jest.mock('react-router-dom', () => ({
1919let axiosMock ;
2020let store ;
2121
22+ const renderComponent = children => render (
23+ < CourseAuthoringProvider courseId = { courseId } >
24+ { children }
25+ </ CourseAuthoringProvider > ,
26+ ) ;
27+
2228beforeEach ( async ( ) => {
2329 const mocks = initializeMocks ( ) ;
2430 store = mocks . reduxStore ;
@@ -35,14 +41,13 @@ describe('Editor Pages Load no header', () => {
3541 axiosMock . onGet ( `${ courseAppsApiUrl } /${ courseId } ` ) . reply ( 200 , {
3642 response : { status : 200 } ,
3743 } ) ;
38- await executeThunk ( fetchCourseApps ( courseId ) , store . dispatch ) ;
3944 } ;
4045 test ( 'renders no loading wheel on editor pages' , async ( ) => {
4146 mockPathname = '/editor/' ;
4247 await mockStoreSuccess ( ) ;
43- const wrapper = render (
44- < CourseAuthoringPage courseId = { courseId } >
45- < PagesAndResources courseId = { courseId } />
48+ const wrapper = renderComponent (
49+ < CourseAuthoringPage >
50+ < PagesAndResources />
4651 </ CourseAuthoringPage >
4752 ,
4853 ) ;
@@ -51,9 +56,9 @@ describe('Editor Pages Load no header', () => {
5156 test ( 'renders loading wheel on non editor pages' , async ( ) => {
5257 mockPathname = '/evilguy/' ;
5358 await mockStoreSuccess ( ) ;
54- const wrapper = render (
55- < CourseAuthoringPage courseId = { courseId } >
56- < PagesAndResources courseId = { courseId } />
59+ const wrapper = renderComponent (
60+ < CourseAuthoringPage >
61+ < PagesAndResources />
5762 </ CourseAuthoringPage >
5863 ,
5964 ) ;
@@ -70,19 +75,17 @@ describe('Course authoring page', () => {
7075 ) . reply ( 404 , {
7176 response : { status : 404 } ,
7277 } ) ;
73- await executeThunk ( fetchCourseDetail ( courseId ) , store . dispatch ) ;
7478 } ;
7579 const mockStoreError = async ( ) => {
7680 axiosMock . onGet (
7781 `${ courseDetailApiUrl } /${ courseId } ?username=abc123` ,
7882 ) . reply ( 500 , {
7983 response : { status : 500 } ,
8084 } ) ;
81- await executeThunk ( fetchCourseDetail ( courseId ) , store . dispatch ) ;
8285 } ;
8386 test ( 'renders not found page on non-existent course key' , async ( ) => {
8487 await mockStoreNotFound ( ) ;
85- const wrapper = render ( < CourseAuthoringPage courseId = { courseId } /> ) ;
88+ const wrapper = renderComponent ( < CourseAuthoringPage /> ) ;
8689 expect ( await wrapper . findByTestId ( 'notFoundAlert' ) ) . toBeInTheDocument ( ) ;
8790 } ) ;
8891 test ( 'does not render not found page on other kinds of error' , async ( ) => {
@@ -92,8 +95,8 @@ describe('Course authoring page', () => {
9295 // IN_PROGRESS but also not NOT_FOUND or DENIED- then check that the not
9396 // found alert is not present.
9497 const contentTestId = 'courseAuthoringPageContent' ;
95- const wrapper = render (
96- < CourseAuthoringPage courseId = { courseId } >
98+ const wrapper = renderComponent (
99+ < CourseAuthoringPage >
97100 < div data-testid = { contentTestId } />
98101 </ CourseAuthoringPage >
99102 ,
@@ -114,7 +117,7 @@ describe('Course authoring page', () => {
114117 mockPathname = '/editor/' ;
115118 await mockStoreDenied ( ) ;
116119
117- const wrapper = render ( < CourseAuthoringPage courseId = { courseId } /> ) ;
120+ const wrapper = renderComponent ( < CourseAuthoringPage /> ) ;
118121 expect ( await wrapper . findByTestId ( 'permissionDeniedAlert' ) ) . toBeInTheDocument ( ) ;
119122 } ) ;
120123} ) ;
0 commit comments