1+ import VueUiVerticalBar from './vue-ui-vertical-bar.vue'
2+
3+ describe ( '<VueUiVerticalBar />' , ( ) => {
4+
5+ beforeEach ( function ( ) {
6+ cy . fixture ( 'vertical-bar.json' ) . as ( 'fixture' ) ;
7+ cy . viewport ( 1000 , 800 ) ;
8+ } ) ;
9+
10+ it ( 'renders' , ( ) => {
11+ cy . get ( '@fixture' ) . then ( ( fixture ) => {
12+ cy . mount ( VueUiVerticalBar , {
13+ props : {
14+ dataset : fixture . dataset ,
15+ config : fixture . config
16+ }
17+ } ) ;
18+
19+ cy . get ( `[data-cy="vertical-bar-div-title"]` )
20+ . should ( 'exist' )
21+ . contains ( fixture . config . style . chart . title . text ) ;
22+
23+ cy . get ( `[data-cy="vertical-bar-div-subtitle"]` )
24+ . should ( 'exist' )
25+ . contains ( fixture . config . style . chart . title . subtitle . text ) ;
26+
27+ for ( let i = 0 ; i < fixture . dataset . length ; i += 1 ) {
28+ cy . get ( `[data-cy="vertical-bar-div-legend-item-${ i } "]` ) . then ( ( $legend ) => {
29+ cy . wrap ( $legend )
30+ . should ( 'exist' )
31+ . contains ( `${ fixture . dataset [ i ] . name } : ${ fixture . dataset [ i ] . value } ` )
32+ . click ( )
33+ } )
34+ }
35+
36+ for ( let i = 0 ; i < fixture . dataset . length ; i += 1 ) {
37+ cy . get ( `[data-cy="vertical-bar-div-legend-item-${ i } "]` ) . then ( ( $legend ) => {
38+ cy . wrap ( $legend )
39+ . click ( )
40+ } )
41+ }
42+
43+ cy . get ( `[data-cy="vertical-bar-summary"]` ) . click ( ) ;
44+
45+ cy . get ( `[data-cy="vertical-bar-checkbox-title"]` ) . check ( ) ;
46+
47+ cy . get ( `[data-cy="vertical-bar-text-title"]` )
48+ . should ( 'exist' )
49+ . contains ( fixture . config . style . chart . title . text ) ;
50+
51+ cy . get ( `[data-cy="vertical-bar-text-subtitle"]` )
52+ . should ( 'exist' )
53+ . contains ( fixture . config . style . chart . title . subtitle . text ) ;
54+
55+ for ( let i = 0 ; i < fixture . dataset . length ; i += 1 ) {
56+ cy . get ( `[data-cy="vertical-bar-foreignObject-legend-item-${ i } "]` ) . then ( ( $legend ) => {
57+ cy . wrap ( $legend )
58+ . should ( 'exist' )
59+ . contains ( `${ fixture . dataset [ i ] . name } : ${ fixture . dataset [ i ] . value } ` )
60+ . click ( )
61+ } )
62+ }
63+
64+ for ( let i = 0 ; i < fixture . dataset . length ; i += 1 ) {
65+ cy . get ( `[data-cy="vertical-bar-foreignObject-legend-item-${ i } "]` ) . then ( ( $legend ) => {
66+ cy . wrap ( $legend )
67+ . click ( )
68+ } )
69+ }
70+
71+ cy . get ( `[data-cy="vertical-bar-checkbox-title"]` ) . uncheck ( { force : true } ) ;
72+ cy . get ( `[data-cy="vertical-bar-checkbox-table"]` ) . check ( { force : true } ) ;
73+ cy . viewport ( 1000 , 1050 ) ;
74+
75+ const bars = fixture . dataset . map ( d => {
76+ if ( d . children ) {
77+ return d . children . length ;
78+ }
79+ return 1 ;
80+ } ) . reduce ( ( a , b ) => a + b , 0 ) ;
81+
82+ for ( let i = 0 ; i < bars ; i += 1 ) {
83+ cy . get ( `[data-cy="vertical-bar-rect-underlayer-${ i } "]` )
84+ . should ( 'exist' )
85+ . invoke ( 'attr' , 'fill' )
86+ . should ( 'eq' , fixture . config . style . chart . layout . bars . underlayerColor ) ;
87+ cy . get ( `[data-cy="vertical-bar-datalabel-${ i } "]` )
88+ . should ( 'exist' ) ;
89+ }
90+
91+ cy . get ( `[data-cy="vertical-bar-trap-0"]` )
92+ . trigger ( 'mouseenter' ) ;
93+
94+ cy . get ( `[data-cy="vertical-bar-tooltip"]` )
95+ . should ( 'exist' ) ;
96+
97+ cy . get ( `[data-cy="vertical-bar-trap-0"]` )
98+ . trigger ( 'mouseleave' ) ;
99+
100+ cy . get ( `[data-cy="vertical-bar-tooltip"]` )
101+ . should ( 'not.exist' ) ;
102+
103+ cy . get ( `[data-cy="vertical-bar-thead"]` )
104+ . should ( 'exist' )
105+ . contains ( `${ fixture . config . style . chart . title . text } : ${ fixture . config . style . chart . title . subtitle . text } ` ) ;
106+
107+ cy . get ( `[data-cy="vertical-bar-thead-tr"]` )
108+ . should ( 'exist' )
109+ . find ( 'th' )
110+ . should ( 'have.length' , 7 )
111+ . each ( ( $th , index ) => {
112+ if ( index === 0 ) {
113+ cy . wrap ( $th )
114+ . should ( 'contain.text' , fixture . config . translations . parentName )
115+ }
116+ if ( [ 1 , 4 ] . includes ( index ) ) {
117+ cy . wrap ( $th )
118+ . should ( 'contain.text' , fixture . config . translations . value )
119+ }
120+ if ( [ 2 , 6 ] . includes ( index ) ) {
121+ cy . wrap ( $th )
122+ . should ( 'contain.text' , fixture . config . translations . percentageToTotal )
123+ }
124+ if ( index === 3 ) {
125+ cy . wrap ( $th )
126+ . should ( 'contain.text' , fixture . config . translations . childName )
127+ }
128+ if ( index === 5 ) {
129+ cy . wrap ( $th )
130+ . should ( 'contain.text' , fixture . config . translations . percentageToSerie )
131+ }
132+ } ) ;
133+
134+ cy . get ( `[data-cy="vertical-bar-summary"]` ) . click ( ) ;
135+
136+ cy . get ( `[data-cy="vertical-bar-pdf"]` ) . click ( ) ;
137+ cy . wait ( 3000 ) ;
138+ cy . readFile ( `cypress\\Downloads\\${ fixture . config . style . chart . title . text } .pdf` ) ;
139+ cy . get ( `[data-cy="vertical-bar-xls"]` ) . click ( ) ;
140+ cy . wait ( 3000 ) ;
141+ cy . readFile ( `cypress\\Downloads\\${ fixture . config . style . chart . title . text } .xlsx` ) ;
142+ cy . clearDownloads ( ) ;
143+ cy . get ( `[data-cy="vertical-bar-summary"]` ) . click ( ) ;
144+
145+ } ) ;
146+ } ) ;
147+ } ) ;
0 commit comments