1
1
import * as Base64 from "@frsource/base64" ;
2
2
import "./commands" ;
3
- import { FILE_SUFFIX , LINK_PREFIX , OVERLAY_CLASS , TASK } from "./constants" ;
3
+ import { LINK_PREFIX , OVERLAY_CLASS , TASK } from "./constants" ;
4
4
5
5
/* c8 ignore start */
6
6
function queueClear ( ) {
@@ -29,7 +29,7 @@ export const generateOverlayTemplate = ({
29
29
imgOldBase64 : string ;
30
30
imgDiffBase64 : string ;
31
31
wasImageNotUpdatedYet : boolean ;
32
- error : boolean
32
+ error : boolean ;
33
33
} ) => `<div class="${ OVERLAY_CLASS } runner" style="position:fixed;z-index:10;top:0;bottom:0;left:0;right:0;display:flex;flex-flow:column">
34
34
<header style="position:static">
35
35
<nav style="display:flex;width:100%;align-items:center;justify-content:space-between;padding:10px 15px;">
@@ -38,7 +38,9 @@ export const generateOverlayTemplate = ({
38
38
${
39
39
wasImageNotUpdatedYet
40
40
? `<button type="submit"><i class="fa fa-check"></i> Update screenshot</button>`
41
- : error ? "Image was already updated, rerun test to see new comparison" : ""
41
+ : error
42
+ ? "Image was already updated, rerun test to see new comparison"
43
+ : ""
42
44
}
43
45
<button type="button" data-type="close"><i class="fa fa-times"></i> Close</button>
44
46
<form>
@@ -82,7 +84,14 @@ after(() => {
82
84
e . preventDefault ( ) ;
83
85
if ( ! top ) return false ;
84
86
85
- const { title, imgPath, imgDiffBase64, imgNewBase64, imgOldBase64, error } = JSON . parse (
87
+ const {
88
+ title,
89
+ imgPath,
90
+ imgDiffBase64,
91
+ imgNewBase64,
92
+ imgOldBase64,
93
+ error,
94
+ } = JSON . parse (
86
95
decodeURIComponent (
87
96
Base64 . decode (
88
97
e . currentTarget . getAttribute ( "href" ) . substring ( LINK_PREFIX . length )
@@ -91,40 +100,40 @@ after(() => {
91
100
) ;
92
101
queueClear ( ) ;
93
102
94
- cy
95
- . task < boolean > ( TASK . doesFileExist , { path : imgPath } , { log : false } )
96
- . then (
97
- ( wasImageNotUpdatedYet ) => {
98
- if ( ! top ) return false ;
99
- queueClear ( ) ;
103
+ cy . task < boolean > (
104
+ TASK . doesFileExist ,
105
+ { path : imgPath } ,
106
+ { log : false }
107
+ ) . then ( ( wasImageNotUpdatedYet ) => {
108
+ if ( ! top ) return false ;
109
+ queueClear ( ) ;
100
110
101
- Cypress . $ (
102
- generateOverlayTemplate ( {
103
- title,
104
- imgNewBase64,
105
- imgOldBase64,
106
- imgDiffBase64,
107
- error,
108
- wasImageNotUpdatedYet,
109
- } )
110
- ) . appendTo ( top . document . body ) ;
111
+ Cypress . $ (
112
+ generateOverlayTemplate ( {
113
+ title,
114
+ imgNewBase64,
115
+ imgOldBase64,
116
+ imgDiffBase64,
117
+ error,
118
+ wasImageNotUpdatedYet,
119
+ } )
120
+ ) . appendTo ( top . document . body ) ;
111
121
112
- const wrapper = Cypress . $ ( `.${ OVERLAY_CLASS } ` , top . document . body ) ;
113
- wrapper . on ( "click" , 'button[data-type="close"]' , function ( ) {
114
- wrapper . remove ( ) ;
115
- } ) ;
122
+ const wrapper = Cypress . $ ( `.${ OVERLAY_CLASS } ` , top . document . body ) ;
123
+ wrapper . on ( "click" , 'button[data-type="close"]' , function ( ) {
124
+ wrapper . remove ( ) ;
125
+ } ) ;
116
126
117
- wrapper . on ( "submit" , "form" , function ( e ) {
118
- e . preventDefault ( ) ;
127
+ wrapper . on ( "submit" , "form" , function ( e ) {
128
+ e . preventDefault ( ) ;
119
129
120
- cy . task ( TASK . approveImage , { img : imgPath } ) . then ( ( ) =>
121
- wrapper . remove ( )
122
- ) ;
130
+ cy . task ( TASK . approveImage , { img : imgPath } ) . then ( ( ) =>
131
+ wrapper . remove ( )
132
+ ) ;
123
133
124
- queueRun ( ) ;
125
- } ) ;
126
- }
127
- ) ;
134
+ queueRun ( ) ;
135
+ } ) ;
136
+ } ) ;
128
137
129
138
queueRun ( ) ;
130
139
0 commit comments