2020 *
2121 */
2222
23- describe ( 'Visual regression tests ' , function ( ) {
23+ describe ( 'Visual regression tests' , function ( ) {
2424 let randUser
2525
2626 before ( function ( ) {
@@ -36,18 +36,28 @@ describe('Visual regression tests ', function() {
3636 cy . login ( user )
3737 cy . visit ( '/apps/files' )
3838 } )
39+
40+ cy . window ( ) . then ( ( win ) => {
41+ // Load roboto font for visual regression consistency
42+ win . loadRoboto = true
43+ win . document . body . style . fontFamily = 'Roboto'
44+ } )
3945 } )
4046
4147 it ( 'See files in the list' , function ( ) {
42- // TODO: Do we care about the file name being split by a ' ' in the text property?
4348 cy . getFile ( 'test-card.mp4' , { timeout : 10000 } )
4449 . should ( 'contain' , 'test-card .mp4' )
4550 cy . getFile ( 'test-card.png' , { timeout : 10000 } )
4651 . should ( 'contain' , 'test-card .png' )
4752 } )
4853
4954 it ( 'Open the viewer on file click' , function ( ) {
55+ cy . intercept ( 'GET' , '**/core/preview*' ) . as ( 'image1' )
56+ cy . intercept ( 'GET' , '/remote.php/dav/files/*/test-card.mp4' ) . as ( 'video' )
5057 cy . openFile ( 'test-card.mp4' )
58+ cy . wait ( '@video' )
59+ // We preload images, so we can check its loading here and not when clicking next
60+ cy . wait ( '@image1' )
5161 cy . get ( 'body > .viewer' ) . should ( 'be.visible' )
5262 } )
5363
@@ -73,7 +83,7 @@ describe('Visual regression tests ', function() {
7383 . and ( 'not.have.class' , 'icon-loading' )
7484 } )
7585
76- it ( 'Take test-card.mp4 screenshot' , function ( ) {
86+ it ( 'Take test-card.mp4 screenshot' , { retries : 0 } , function ( ) {
7787 cy . get ( 'body > .viewer .modal-container .viewer__file.viewer__file--active video' ) . then ( video => {
7888 video . get ( 0 ) . pause ( )
7989 video . get ( 0 ) . currentTime = 1
@@ -99,14 +109,17 @@ describe('Visual regression tests ', function() {
99109 . and ( 'not.have.class' , 'icon-loading' )
100110 } )
101111
102- it ( 'Take test-card.png screenshot' , function ( ) {
112+ it ( 'Take test-card.png screenshot' , { retries : 0 } , function ( ) {
103113 cy . compareSnapshot ( 'image' )
104114 } )
105115
106116 it ( 'Close and open image again' , function ( ) {
107117 cy . get ( 'body > .viewer button.header-close' ) . click ( )
108118 cy . get ( 'body > .viewer' ) . should ( 'not.exist' )
119+
120+ // No need to intercept the request again, it's cached
109121 cy . openFile ( 'test-card.png' )
122+
110123 cy . get ( 'body > .viewer' ) . should ( 'be.visible' )
111124 cy . get ( 'body > .viewer .modal-header__name' ) . should ( 'contain' , 'test-card.png' )
112125 cy . get ( 'body > .viewer .modal-container img' ) . should ( 'have.length' , 1 )
@@ -122,7 +135,7 @@ describe('Visual regression tests ', function() {
122135 . and ( 'not.have.class' , 'icon-loading' )
123136 } )
124137
125- it ( 'Take test-card.png screenshot 2' , function ( ) {
138+ it ( 'Take test-card.png screenshot 2' , { retries : 0 } , function ( ) {
126139 cy . compareSnapshot ( 'image2' )
127140 } )
128141
@@ -136,13 +149,14 @@ describe('Visual regression tests ', function() {
136149 hasPreview : false ,
137150 fileid : 123 ,
138151 }
139-
152+ cy . intercept ( 'GET' , '/core/img/favicon.png' ) . as ( 'favicon' )
140153 cy . window ( ) . then ( ( win ) => {
141154 win . OCA . Viewer . open ( {
142155 fileInfo,
143156 list : [ fileInfo ] ,
144157 } )
145158 } )
159+ cy . wait ( '@favicon' )
146160
147161 cy . get ( 'body > .viewer .modal-container img' ) . should ( 'have.length' , 1 )
148162 cy . get ( 'body > .viewer .modal-container img' ) . should ( 'have.attr' , 'src' )
@@ -157,7 +171,7 @@ describe('Visual regression tests ', function() {
157171 . and ( 'not.have.class' , 'icon-loading' )
158172 } )
159173
160- it ( 'Take non-dav logo.png screenshot' , function ( ) {
174+ it ( 'Take non-dav logo.png screenshot' , { retries : 0 } , function ( ) {
161175 cy . compareSnapshot ( 'non-dav' )
162176 } )
163177} )
0 commit comments