@@ -13,17 +13,25 @@ import Course from './Course';
1313import setupDiscussionSidebar from './test-utils' ;
1414
1515jest . mock ( '@edx/frontend-platform/analytics' ) ;
16- jest . mock ( '@edx/frontend-lib-special-exams/dist/data/thunks.js' , ( ) => ( {
17- ...jest . requireActual ( '@edx/frontend-lib-special-exams/dist/data/thunks.js' ) ,
18- checkExamEntry : ( ) => jest . fn ( ) ,
19- } ) ) ;
20- const mockChatTestId = 'fake-chat' ;
16+ jest . mock ( '@edx/frontend-lib-special-exams' , ( ) => {
17+ const actual = jest . requireActual ( '@edx/frontend-lib-special-exams' ) ;
18+ return {
19+ ...actual ,
20+ __esModule : true ,
21+ // Mock the default export (SequenceExamWrapper) to just render children
22+ // eslint-disable-next-line react/prop-types
23+ default : ( { children } ) => < div data-testid = "sequence-exam-wrapper" > { children } </ div > ,
24+ } ;
25+ } ) ;
26+ const mockLearnerToolsTestId = 'fake-learner-tools' ;
2127jest . mock (
22- './chat/Chat' ,
23- // eslint-disable-next-line react/prop-types
24- ( ) => function ( { courseId } ) {
25- return < div className = "fake-chat" data-testid = { mockChatTestId } > Chat contents { courseId } </ div > ;
26- } ,
28+ '../../plugin-slots/LearnerToolsSlot' ,
29+ ( ) => ( {
30+ // eslint-disable-next-line react/prop-types
31+ LearnerToolsSlot ( { courseId } ) {
32+ return < div className = "fake-learner-tools" data-testid = { mockLearnerToolsTestId } > LearnerTools contents { courseId } </ div > ;
33+ } ,
34+ } ) ,
2735) ;
2836
2937const recordFirstSectionCelebration = jest . fn ( ) ;
@@ -360,28 +368,27 @@ describe('Course', () => {
360368 } ) ;
361369 } ) ;
362370
363- it ( 'displays chat when screen is wide enough (browser)' , async ( ) => {
371+ it ( 'displays learner tools when screen is wide enough (browser)' , async ( ) => {
364372 const courseMetadata = Factory . build ( 'courseMetadata' , {
365- learning_assistant_enabled : true ,
366373 enrollment : { mode : 'verified' } ,
367374 } ) ;
368375 const testStore = await initializeTestStore ( { courseMetadata } , false ) ;
369- const { courseware } = testStore . getState ( ) ;
376+ const { courseware, models } = testStore . getState ( ) ;
370377 const { courseId, sequenceId } = courseware ;
371378 const testData = {
372379 ...mockData ,
373380 courseId,
374381 sequenceId,
382+ unitId : Object . values ( models . units ) [ 0 ] . id ,
375383 } ;
376384 render ( < Course { ...testData } /> , { store : testStore , wrapWithRouter : true } ) ;
377- const chat = screen . queryByTestId ( mockChatTestId ) ;
378- waitFor ( ( ) => expect ( chat ) . toBeInTheDocument ( ) ) ;
385+ const learnerTools = screen . queryByTestId ( mockLearnerToolsTestId ) ;
386+ await waitFor ( ( ) => expect ( learnerTools ) . toBeInTheDocument ( ) ) ;
379387 } ) ;
380388
381- it ( 'does not display chat when screen is too narrow (mobile)' , async ( ) => {
389+ it ( 'does not display learner tools when screen is too narrow (mobile)' , async ( ) => {
382390 global . innerWidth = breakpoints . extraSmall . minWidth ;
383391 const courseMetadata = Factory . build ( 'courseMetadata' , {
384- learning_assistant_enabled : true ,
385392 enrollment : { mode : 'verified' } ,
386393 } ) ;
387394 const testStore = await initializeTestStore ( { courseMetadata } , false ) ;
@@ -393,7 +400,7 @@ describe('Course', () => {
393400 sequenceId,
394401 } ;
395402 render ( < Course { ...testData } /> , { store : testStore , wrapWithRouter : true } ) ;
396- const chat = screen . queryByTestId ( mockChatTestId ) ;
397- await expect ( chat ) . not . toBeInTheDocument ( ) ;
403+ const learnerTools = screen . queryByTestId ( mockLearnerToolsTestId ) ;
404+ await expect ( learnerTools ) . not . toBeInTheDocument ( ) ;
398405 } ) ;
399406} ) ;
0 commit comments