1+ const { takeSnapshots } = Cypress . expose ( ) ;
2+
13// For ARIA-based checks
24const BE_SELECTED = [ 'have.attr' , 'aria-selected' , 'true' ] as const ;
35const BE_CHECKED = [ 'have.attr' , 'aria-checked' , 'true' ] as const ;
@@ -18,7 +20,7 @@ describe('/mock', () => {
1820 'be.visible' ,
1921 ) ;
2022
21- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
23+ if ( takeSnapshots ) {
2224 cy . matchImageSnapshot ( 'line_1D' ) ;
2325 }
2426 } ) ;
@@ -33,7 +35,7 @@ describe('/mock', () => {
3335 'be.visible' ,
3436 ) ;
3537
36- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
38+ if ( takeSnapshots ) {
3739 cy . matchImageSnapshot ( 'line_complex_1D' ) ;
3840 }
3941 } ) ;
@@ -53,7 +55,7 @@ describe('/mock', () => {
5355 . should ( 'have.attr' , 'role' , 'row' )
5456 . and ( 'have.attr' , 'aria-rowindex' , 1 ) ;
5557
56- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
58+ if ( takeSnapshots ) {
5759 cy . matchImageSnapshot ( 'matrix_1D' ) ;
5860 }
5961 } ) ;
@@ -78,7 +80,7 @@ describe('/mock', () => {
7880 . should ( 'have.attr' , 'aria-colindex' , 1 )
7981 . and ( 'have.text' , 'string' ) ;
8082
81- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
83+ if ( takeSnapshots ) {
8284 cy . matchImageSnapshot ( 'compound_1D' ) ;
8385 }
8486 } ) ;
@@ -93,15 +95,15 @@ describe('/mock', () => {
9395 'be.visible' ,
9496 ) ;
9597
96- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
98+ if ( takeSnapshots ) {
9799 cy . matchImageSnapshot ( 'heatmap_2D' ) ;
98100 }
99101
100102 cy . findByRole ( 'button' , { name : 'More controls' } ) . click ( ) ;
101103 cy . findByRole ( 'button' , { name : 'Invert' } ) . click ( ) ;
102104 cy . waitForStableDOM ( ) ;
103105
104- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
106+ if ( takeSnapshots ) {
105107 cy . matchImageSnapshot ( 'heatmap_2D_inverted_cmap' ) ;
106108 }
107109 } ) ;
@@ -118,7 +120,7 @@ describe('/mock', () => {
118120 'be.visible' ,
119121 ) ;
120122
121- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
123+ if ( takeSnapshots ) {
122124 cy . matchImageSnapshot ( 'heatmap_2D_complex' ) ;
123125 }
124126 } ) ;
@@ -129,14 +131,14 @@ describe('/mock', () => {
129131 cy . selectExplorerNode ( '_FillValue' ) ;
130132 cy . findByRole ( 'figure' , { name : '_FillValue' } ) . should ( 'be.visible' ) ;
131133
132- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
134+ if ( takeSnapshots ) {
133135 cy . matchImageSnapshot ( 'fillvalue_2D' ) ;
134136 }
135137
136138 cy . selectVisTab ( 'Line' ) ;
137139 cy . waitForStableDOM ( ) ;
138140
139- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
141+ if ( takeSnapshots ) {
140142 cy . matchImageSnapshot ( 'fillvalue_1D' ) ;
141143 }
142144 } ) ;
@@ -167,7 +169,7 @@ describe('/mock', () => {
167169 cy . get ( '@xAxis' ) . should ( 'have.text' , [ 0 , 10 , 20 , 30 , 40 ] . join ( '' ) ) ;
168170 cy . get ( '@yAxis' ) . should ( 'have.text' , [ '−10' , 0 , 10 , 20 , 30 ] . join ( '' ) ) ; // minus sign − (U+2212), not hyphen - (U+002D)
169171
170- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
172+ if ( takeSnapshots ) {
171173 cy . matchImageSnapshot ( 'heatmap_4d_default' ) ;
172174 }
173175
@@ -181,7 +183,7 @@ describe('/mock', () => {
181183 cy . findByRole ( 'radio' , { name : 'D1' } ) . should ( ...BE_CHECKED ) ;
182184 } ) ;
183185
184- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
186+ if ( takeSnapshots ) {
185187 cy . matchImageSnapshot ( 'heatmap_4d_remapped' ) ;
186188 }
187189 } ) ;
@@ -210,7 +212,7 @@ describe('/mock', () => {
210212 . should ( 'contain.text' , '9.996e-1' )
211213 . and ( 'contain.text' , '−1e+0' ) ;
212214
213- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
215+ if ( takeSnapshots ) {
214216 cy . matchImageSnapshot ( 'heatmap_4d_sliced' ) ;
215217 }
216218
@@ -222,7 +224,7 @@ describe('/mock', () => {
222224 cy . get ( '@d1Slider' ) . should ( 'have.attr' , 'aria-valuenow' , 4 ) ;
223225 cy . get ( '@vis' ) . should ( 'contain.text' , '+∞' ) . and ( 'contain.text' , '−∞' ) ;
224226
225- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
227+ if ( takeSnapshots ) {
226228 cy . matchImageSnapshot ( 'heatmap_4d_zeros' ) ;
227229 }
228230 } ) ;
@@ -236,14 +238,14 @@ describe('/mock', () => {
236238 cy . findByLabelText ( 'Constant' ) . click ( ) ;
237239 cy . waitForStableDOM ( ) ;
238240
239- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
241+ if ( takeSnapshots ) {
240242 cy . matchImageSnapshot ( 'line_constant' ) ;
241243 }
242244
243245 cy . selectExplorerNode ( 'oneD_cplx' ) ;
244246 cy . waitForStableDOM ( ) ;
245247
246- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
248+ if ( takeSnapshots ) {
247249 cy . matchImageSnapshot ( 'line_complex_constant' ) ;
248250 }
249251 } ) ;
@@ -266,7 +268,7 @@ describe('/mock', () => {
266268 cy . findByText ( '4e+2' ) . should ( 'be.visible' ) ;
267269 } ) ;
268270
269- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
271+ if ( takeSnapshots ) {
270272 cy . matchImageSnapshot ( 'heatmap_domain' ) ;
271273 }
272274 } ) ;
@@ -287,7 +289,7 @@ describe('/mock', () => {
287289
288290 cy . waitForStableDOM ( ) ;
289291
290- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
292+ if ( takeSnapshots ) {
291293 cy . matchImageSnapshot ( 'heatmap_flip' ) ;
292294 }
293295 } ) ;
@@ -302,14 +304,14 @@ describe('/mock', () => {
302304 'be.visible' ,
303305 ) ;
304306
305- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
307+ if ( takeSnapshots ) {
306308 cy . matchImageSnapshot ( 'rgb_image' ) ;
307309 }
308310
309311 cy . findByRole ( 'radio' , { name : 'BGR' } ) . click ( ) ;
310312 cy . waitForStableDOM ( ) ;
311313
312- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
314+ if ( takeSnapshots ) {
313315 cy . matchImageSnapshot ( 'bgr_image' ) ;
314316 }
315317 } ) ;
@@ -365,7 +367,7 @@ describe('/mock', () => {
365367
366368 cy . get ( 'svg[data-type="abscissa"] svg' ) . should ( 'have.text' , 'X (nm)' ) ;
367369
368- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
370+ if ( takeSnapshots ) {
369371 cy . matchImageSnapshot ( 'nxline' ) ;
370372 }
371373 } ) ;
@@ -387,7 +389,7 @@ describe('/mock', () => {
387389 'Angle (degrees)' ,
388390 ) ;
389391
390- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
392+ if ( takeSnapshots ) {
391393 cy . matchImageSnapshot ( 'nxheatmap' ) ;
392394 }
393395 } ) ;
@@ -423,7 +425,7 @@ describe('/mock', () => {
423425 2 ,
424426 ) ;
425427
426- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
428+ if ( takeSnapshots ) {
427429 cy . matchImageSnapshot ( 'default_slice' ) ;
428430 }
429431 } ) ;
@@ -439,7 +441,7 @@ describe('/mock', () => {
439441
440442 cy . findAllByRole ( 'combobox' , { name : / L o g / u } ) . should ( 'have.length' , 2 ) ;
441443
442- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
444+ if ( takeSnapshots ) {
443445 cy . waitForStableDOM ( ) ;
444446 cy . matchImageSnapshot ( 'logspectrum' ) ;
445447 }
@@ -453,7 +455,7 @@ describe('/mock', () => {
453455 name : 'nexus_entry / spectrum_with_aux' ,
454456 } ) . should ( 'be.visible' ) ;
455457
456- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
458+ if ( takeSnapshots ) {
457459 cy . matchImageSnapshot ( 'auxspectrum' ) ;
458460 }
459461 } ) ;
@@ -474,7 +476,7 @@ describe('/mock', () => {
474476 . should ( 'be.visible' )
475477 . and ( 'contain.text' , '−4.75e+1' ) ; // color bar min
476478
477- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
479+ if ( takeSnapshots ) {
478480 cy . matchImageSnapshot ( 'auximage' ) ;
479481 }
480482 } ) ;
@@ -487,7 +489,7 @@ describe('/mock', () => {
487489 name : 'nexus_entry / complex_spectrum' ,
488490 } ) . should ( 'be.visible' ) ;
489491
490- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
492+ if ( takeSnapshots ) {
491493 cy . matchImageSnapshot ( 'nxline_complex_2d_aux' ) ;
492494 }
493495 } ) ;
@@ -500,7 +502,7 @@ describe('/mock', () => {
500502 name : 'nexus_entry / complex_image' ,
501503 } ) . should ( 'be.visible' ) ;
502504
503- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
505+ if ( takeSnapshots ) {
504506 cy . matchImageSnapshot ( 'nxheatmap_complex_2d' ) ;
505507 }
506508
@@ -511,7 +513,7 @@ describe('/mock', () => {
511513 cy . findByRole ( 'figure' , { name : 'tertiary_float' } ) . should ( 'be.visible' ) ;
512514 cy . waitForStableDOM ( ) ;
513515
514- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
516+ if ( takeSnapshots ) {
515517 cy . matchImageSnapshot ( 'nxheatmap_complex_2d_float_aux' ) ;
516518 }
517519 } ) ;
@@ -527,7 +529,7 @@ describe('/mock', () => {
527529 ) ;
528530 cy . waitForStableDOM ( ) ;
529531
530- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
532+ if ( takeSnapshots ) {
531533 cy . matchImageSnapshot ( 'nxrgb' ) ;
532534 }
533535 } ) ;
@@ -542,7 +544,7 @@ describe('/mock', () => {
542544 'be.visible' ,
543545 ) ;
544546
545- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
547+ if ( takeSnapshots ) {
546548 cy . matchImageSnapshot ( 'nxscatter' ) ;
547549 }
548550 } ) ;
@@ -558,7 +560,7 @@ describe('/mock?wide', () => {
558560 it ( 'start with sidebar closed' , ( ) => {
559561 cy . findByRole ( 'tree' ) . should ( 'not.exist' ) ;
560562
561- if ( Cypress . env ( 'TAKE_SNAPSHOTS' ) ) {
563+ if ( takeSnapshots ) {
562564 cy . matchImageSnapshot ( 'wide' ) ;
563565 }
564566 } ) ;
0 commit comments