1
1
describe ( 'Media' , function ( ) {
2
2
beforeEach ( function ( ) {
3
- cy . getData ( )
3
+ cy . getData ( ) ;
4
4
} ) ;
5
5
6
6
it ( 'should display the media component' , function ( ) {
7
- const mediaComponents = this . data . components . filter ( ( component ) => component . _component === 'media' )
8
- mediaComponents . forEach ( ( mediaComponent ) => {
7
+ const mediaComponents = this . data . components . filter ( component => component . _component === 'media' ) ;
8
+ const stripHtml = cy . helpers . stripHtml ;
9
+ mediaComponents . forEach ( mediaComponent => {
9
10
cy . visit ( `/#/preview/${ mediaComponent . _id } ` ) ;
10
- const bodyWithoutHtml = mediaComponent . body . replace ( / < [ ^ > ] * > / g, '' ) ;
11
-
12
- // Test basic media component
13
- cy . testContainsOrNotExists ( '.media__title' , mediaComponent . displayTitle )
14
- cy . testContainsOrNotExists ( '.media__body' , bodyWithoutHtml )
15
- cy . testContainsOrNotExists ( '.media__instruction' , mediaComponent . instruction )
11
+
12
+ cy . testContainsOrNotExists ( '.media__body' , stripHtml ( mediaComponent . body ) ) ;
13
+ cy . testContainsOrNotExists ( '.media__title' , stripHtml ( mediaComponent . displayTitle ) ) ;
14
+ cy . testContainsOrNotExists ( '.media__instruction' , stripHtml ( mediaComponent . instruction ) ) ;
16
15
17
16
if ( mediaComponent . _media . mp4 ) {
18
- cy . get ( '.mejs-mediaelement video' ) . should ( 'have.attr' , 'src' , mediaComponent . _media . mp4 )
19
- }
17
+ cy . get ( '.mejs-mediaelement video' ) . should ( 'have.attr' , 'src' , mediaComponent . _media . mp4 ) ;
18
+ } ;
20
19
if ( mediaComponent . _media . poster ) {
21
- cy . get ( '.mejs-poster img' ) . should ( 'have.attr' , 'src' , mediaComponent . _media . poster )
22
- }
20
+ cy . get ( '.mejs-poster img' ) . should ( 'have.attr' , 'src' , mediaComponent . _media . poster ) ;
21
+ } ;
23
22
24
23
if ( mediaComponent . _transcript ) {
25
- cy . get ( '.media__transcript-body-inline' ) . should ( 'not.be.visible' )
26
- cy . get ( 'button.media__transcript-btn' ) . should ( 'contain' , mediaComponent . _transcript . inlineTranscriptButton ) . click ( )
27
- cy . get ( '.media__transcript-body-inline-inner' ) . should ( 'be.visible' ) . should ( 'contain' , mediaComponent . _transcript . inlineTranscriptBody )
28
- cy . get ( 'button.media__transcript-btn' ) . should ( 'contain' , mediaComponent . _transcript . inlineTranscriptCloseButton ) . click ( )
29
- cy . get ( '.media__transcript-body-inline' ) . should ( 'not.be.visible' )
30
- }
24
+ cy . get ( '.media__transcript-body-inline' ) . should ( 'not.be.visible' ) ;
25
+ cy . get ( 'button.media__transcript-btn' ) . should ( 'contain' , mediaComponent . _transcript . inlineTranscriptButton ) . click ( ) ;
26
+ cy . get ( '.media__transcript-body-inline-inner' ) . should ( 'be.visible' ) . should ( 'contain' , mediaComponent . _transcript . inlineTranscriptBody ) ;
27
+ cy . get ( 'button.media__transcript-btn' ) . should ( 'contain' , mediaComponent . _transcript . inlineTranscriptCloseButton ) . click ( ) ;
28
+ cy . get ( '.media__transcript-body-inline' ) . should ( 'not.be.visible' ) ;
29
+ } ;
31
30
32
31
// Allow the component to load and run external custom tests
33
- cy . wait ( 1000 )
32
+ cy . wait ( 1000 ) ;
34
33
} ) ;
35
34
} ) ;
36
35
} ) ;
0 commit comments