@@ -10,6 +10,7 @@ import {
1010 manifestWoStructure ,
1111 manifestWithInvalidStruct ,
1212 manifestWEmptyCanvas ,
13+ manifestWEmptyRanges ,
1314} from './services/testing-helpers' ;
1415import mockAxios from 'axios' ;
1516import Peaks from 'peaks.js' ;
@@ -289,8 +290,9 @@ describe('App component', () => {
289290 await act ( ( ) => Promise . resolve ( ) ) ;
290291
291292 expect ( app . queryByTestId ( 'waveform-container' ) ) . toBeInTheDocument ( ) ;
292- expect ( app . queryByTestId ( 'alert-container' ) ) . toBeInTheDocument ( ) ;
293- expect ( app . getByTestId ( 'alert-message' ) . innerHTML ) . toBe (
293+ // Display 2 alerts for empty media and invalid structure
294+ expect ( app . queryAllByTestId ( 'alert-container' ) . length ) . toEqual ( 2 ) ;
295+ expect ( app . getAllByTestId ( 'alert-message' ) [ 1 ] . innerHTML ) . toBe (
294296 'No available media. Editing structure is disabled.'
295297 ) ;
296298 } ) ;
@@ -432,39 +434,79 @@ describe('App component', () => {
432434 } ) ;
433435 } ) ;
434436
435- test ( 'when structure has invalid timespans' , async ( ) => {
436- mockAxios . get . mockImplementationOnce ( ( ) => {
437- return Promise . resolve ( {
438- status : 200 ,
439- data : manifestWithInvalidStruct
437+ describe ( 'when structure has' , ( ) => {
438+ test ( 'invalid timespans' , async ( ) => {
439+ mockAxios . get . mockImplementationOnce ( ( ) => {
440+ return Promise . resolve ( {
441+ status : 200 ,
442+ data : manifestWithInvalidStruct
443+ } ) ;
440444 } ) ;
441- } ) ;
442- mockAxios . head . mockImplementationOnce ( ( ) => {
443- return Promise . resolve ( {
444- status : 200 ,
445- request : {
446- responseURL : 'https://example.com/lunchroom_manners/waveform.json' ,
445+ mockAxios . head . mockImplementationOnce ( ( ) => {
446+ return Promise . resolve ( {
447+ status : 200 ,
448+ request : {
449+ responseURL : 'https://example.com/lunchroom_manners/waveform.json' ,
450+ } ,
451+ } ) ;
452+ } ) ;
453+ const initialState = {
454+ manifest : {
455+ manifestFetched : true ,
456+ manifest : manifestWithInvalidStruct ,
457+ mediaInfo : {
458+ src : 'http://example.com/volleyball-for-boys/high/volleyball-for-boys.mp4' ,
459+ duration : 662.037 ,
460+ } ,
447461 } ,
462+ } ;
463+ const app = renderWithRedux ( < App { ...props } /> , { initialState } ) ;
464+
465+ await waitFor ( ( ) => {
466+ expect ( app . queryAllByTestId ( 'list-item' ) . length ) . toBeGreaterThan ( 0 ) ;
467+ expect ( app . getAllByTestId ( 'heading-label' ) [ 0 ] . innerHTML ) . toEqual ( 'Lunchroom Manners' ) ;
468+ expect ( app . getByTestId ( 'alert-container' ) ) . toBeInTheDocument ( ) ;
469+ expect ( app . getByTestId ( 'alert-message' ) . innerHTML )
470+ . toEqual ( 'Please check the marked invalid timespan(s)/heading(s).' ) ;
471+ expect ( app . getByTestId ( 'structure-save-button' ) ) . not . toBeEnabled ( ) ;
448472 } ) ;
449473 } ) ;
450- const initialState = {
451- manifest : {
452- manifestFetched : true ,
453- manifest : manifestWithInvalidStruct ,
454- mediaInfo : {
455- src : 'http://example.com/volleyball-for-boys/high/volleyball-for-boys.mp4' ,
456- duration : 662.037 ,
474+
475+ test ( 'invalid headings (empty)' , async ( ) => {
476+ mockAxios . get . mockImplementationOnce ( ( ) => {
477+ return Promise . resolve ( {
478+ status : 200 ,
479+ data : manifestWEmptyRanges
480+ } ) ;
481+ } ) ;
482+ mockAxios . head . mockImplementationOnce ( ( ) => {
483+ return Promise . resolve ( {
484+ status : 200 ,
485+ request : {
486+ responseURL : 'https://example.com/lunchroom_manners/waveform.json' ,
487+ } ,
488+ } ) ;
489+ } ) ;
490+ const initialState = {
491+ manifest : {
492+ manifestFetched : true ,
493+ manifest : manifestWEmptyRanges ,
494+ mediaInfo : {
495+ src : 'http://example.com/volleyball-for-boys/high/volleyball-for-boys.mp4' ,
496+ duration : 662.037 ,
497+ } ,
457498 } ,
458- } ,
459- } ;
460- const app = renderWithRedux ( < App { ...props } /> , { initialState } ) ;
499+ } ;
500+ const app = renderWithRedux ( < App { ...props } /> , { initialState } ) ;
461501
462- await waitFor ( ( ) => {
463- expect ( app . queryAllByTestId ( 'list-item' ) . length ) . toBeGreaterThan ( 0 ) ;
464- expect ( app . getAllByTestId ( 'heading-label' ) [ 0 ] . innerHTML ) . toEqual ( 'Lunchroom Manners' ) ;
465- expect ( app . getByTestId ( 'alert-container' ) ) . toBeInTheDocument ( ) ;
466- expect ( app . getByTestId ( 'alert-message' ) . innerHTML )
467- . toEqual ( 'Please check start/end times of the marked invalid timespan(s).' ) ;
502+ await waitFor ( ( ) => {
503+ expect ( app . queryAllByTestId ( 'list-item' ) . length ) . toBeGreaterThan ( 0 ) ;
504+ expect ( app . getAllByTestId ( 'heading-label' ) [ 0 ] . innerHTML ) . toEqual ( 'Root' ) ;
505+ expect ( app . getByTestId ( 'alert-container' ) ) . toBeInTheDocument ( ) ;
506+ expect ( app . getByTestId ( 'alert-message' ) . innerHTML )
507+ . toEqual ( 'Please check the marked invalid timespan(s)/heading(s).' ) ;
508+ expect ( app . getByTestId ( 'structure-save-button' ) ) . not . toBeEnabled ( ) ;
509+ } ) ;
468510 } ) ;
469511 } ) ;
470512 } ) ;
0 commit comments