@@ -17,6 +17,14 @@ jest.mock('@edx/frontend-lib-special-exams/dist/data/thunks.js', () => ({
17
17
...jest . requireActual ( '@edx/frontend-lib-special-exams/dist/data/thunks.js' ) ,
18
18
checkExamEntry : ( ) => jest . fn ( ) ,
19
19
} ) ) ;
20
+ const mockChatTestId = 'fake-chat' ;
21
+ jest . 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
+ } ,
27
+ ) ;
20
28
21
29
const recordFirstSectionCelebration = jest . fn ( ) ;
22
30
// eslint-disable-next-line no-import-assign
@@ -317,4 +325,41 @@ describe('Course', () => {
317
325
await waitFor ( ( ) => expect ( screen . getByText ( 'To access course materials, you must score 70% or higher on this exam. Your current score is 30%.' ) ) . toBeInTheDocument ( ) ) ;
318
326
} ) ;
319
327
} ) ;
328
+
329
+ it ( 'displays chat when screen is wide enough (browser)' , async ( ) => {
330
+ const courseMetadata = Factory . build ( 'courseMetadata' , {
331
+ learning_assistant_enabled : true ,
332
+ enrollment : { mode : 'verified' } ,
333
+ } ) ;
334
+ const testStore = await initializeTestStore ( { courseMetadata } , false ) ;
335
+ const { courseware } = testStore . getState ( ) ;
336
+ const { courseId, sequenceId } = courseware ;
337
+ const testData = {
338
+ ...mockData ,
339
+ courseId,
340
+ sequenceId,
341
+ } ;
342
+ render ( < Course { ...testData } /> , { store : testStore , wrapWithRouter : true } ) ;
343
+ const chat = screen . queryByTestId ( mockChatTestId ) ;
344
+ await expect ( chat ) . toBeInTheDocument ( ) ;
345
+ } ) ;
346
+
347
+ it ( 'does not display chat when screen is too narrow (mobile)' , async ( ) => {
348
+ global . innerWidth = breakpoints . extraSmall . minWidth ;
349
+ const courseMetadata = Factory . build ( 'courseMetadata' , {
350
+ learning_assistant_enabled : true ,
351
+ enrollment : { mode : 'verified' } ,
352
+ } ) ;
353
+ const testStore = await initializeTestStore ( { courseMetadata } , false ) ;
354
+ const { courseware } = testStore . getState ( ) ;
355
+ const { courseId, sequenceId } = courseware ;
356
+ const testData = {
357
+ ...mockData ,
358
+ courseId,
359
+ sequenceId,
360
+ } ;
361
+ render ( < Course { ...testData } /> , { store : testStore , wrapWithRouter : true } ) ;
362
+ const chat = screen . queryByTestId ( mockChatTestId ) ;
363
+ await expect ( chat ) . not . toBeInTheDocument ( ) ;
364
+ } ) ;
320
365
} ) ;
0 commit comments