@@ -10,185 +10,120 @@ describe('Overview > Reports Tests', () => {
10
10
cy . expect_show_list_title ( 'All Saved Reports' ) ;
11
11
} ) ;
12
12
13
- it ( 'Can add, edit and delete a report' , ( ) => {
14
- cy . get ( '#control_reports_accord > .panel-title > .collapsed' ) . click ( ) ; // Navigate to reports section of explorer page
13
+ context ( 'With cleanup of saved reports' , ( ) => {
14
+ afterEach ( ( ) => {
15
+ // Delete report and verify that it was deleted
16
+ cy . get ( 'li.node-treeview-reports_tree' ) . contains ( 'My Company' ) . click ( ) ;
17
+ cy . expect_show_list_title ( 'My Company (All Groups) Reports' ) ;
18
+ cy . get ( '.clickable-row' ) . contains ( 'Custom' ) . click ( { force : true } ) ;
19
+ cy . expect_show_list_title ( 'Custom Reports' ) ;
20
+ cy . get ( '.list-group-item' ) . contains ( 'Cypress Test Report' ) . click ( ) ;
15
21
16
- // Click add report
17
- cy . get ( '#report_vmdb_choice' ) . click ( ) . then ( ( ) => {
18
- cy . get ( '.bx--overflow-menu-options__btn' ) . then ( ( list ) => {
19
- cy . get ( list . children ( ) [ 0 ] ) . click ( ) ;
22
+ cy . intercept ( / \/ r e p o r t \/ x _ b u t t o n \/ [ 0 - 9 ] + \? p r e s s e d = m i q _ r e p o r t _ d e l e t e / ) . as ( 'delete' ) ;
23
+ cy . get ( '#report_vmdb_choice' ) . click ( ) . then ( ( ) => {
24
+ cy . get ( '.bx--overflow-menu-options__btn' ) . then ( ( list ) => {
25
+ cy . get ( list . children ( ) [ 4 ] ) . click ( ) ;
26
+ } ) ;
20
27
} ) ;
28
+ cy . wait ( '@delete' ) ;
29
+ cy . get ( '.alert-success' ) ;
30
+ cy . get ( '.list-group-item' ) . should ( 'not.contain' , 'Cypress Test Report Edit' ) ;
21
31
} ) ;
22
32
23
- // Fill out report information
24
- cy . get ( '#name' ) . type ( 'Cypress Test Report' , { force : true } ) ;
25
- cy . get ( '#title' ) . type ( 'Cypress test report title' , { force : true } ) ;
26
-
27
- let basedOn = '' ;
28
- let columns = [ ] ;
29
- let tableName = '' ;
33
+ it ( 'Can add, edit and delete a report' , ( ) => {
34
+ cy . get ( '#control_reports_accord > .panel-title > .collapsed' ) . click ( ) ; // Navigate to reports section of explorer page
30
35
31
- cy . get ( ':nth-child(3) > .col-md-8 > .btn-group > .btn' ) . click ( { force : true } ) ;
32
- cy . get ( ':nth-child(3) > .col-md-8 > .btn-group > .open > .dropdown-menu > [data-original-index="1"] > a' ) . then ( ( option ) => {
33
- cy . get ( option ) . click ( { force : true } ) ;
34
- basedOn = option [ 0 ] . innerText ;
35
- tableName = basedOn . substring ( 0 , basedOn . length - 1 ) . replace ( ' ' , '' ) ;
36
- } ) ;
37
- cy . get ( '[align="left"] > .btn-group > .btn' ) . click ( { force : true } ) ;
38
- cy . get ( '[align="left"] > .btn-group > .open > .dropdown-menu > [data-original-index="0"] > a > .text' ) . then ( ( option ) => {
39
- cy . get ( option ) . click ( { force : true } ) ;
40
- columns . push ( option [ 0 ] . innerText . trim ( ) ) ;
41
- } ) ;
42
- cy . get ( '[align="left"] > .btn-group > .open > .dropdown-menu > [data-original-index="1"] > a > .text' ) . then ( ( option ) => {
43
- cy . get ( option ) . click ( { force : true } ) ;
44
- columns . push ( option [ 0 ] . innerText . trim ( ) ) ;
45
- } ) ;
46
- cy . get ( '[align="left"] > .btn-group > .btn > .filter-option' ) . click ( { force : true } ) ;
47
- cy . intercept ( '/report/form_field_changed/new?button=right' ) . as ( 'fieldsChanged' ) ;
48
- cy . get ( '[alt="Move selected fields down"]' ) . click ( { force : true } ) ;
49
- cy . wait ( '@fieldsChanged' ) . then ( ( ) => {
50
- // Verify all report page tabs load correctly
51
- cy . get ( '#Consolidation_tab > a' ) . click ( { force : true } ) ;
52
- cy . get ( '#consolidate_div > h3' ) . contains ( 'Group Records by up to 3 Columns' ) ;
53
- cy . get ( '#Formatting_tab > a' ) . click ( { force : true } ) ;
54
- cy . get ( '#formatting_div > h3' ) . contains ( 'PDF Output' ) ;
55
- cy . get ( '#Styling_tab > a' ) . click ( { force : true } ) ;
56
- cy . get ( '#styling_div > h3' ) . contains ( 'Specify Column Styles' ) ;
57
- cy . get ( '#Filter_tab > a' ) . click ( { force : true } ) ;
58
- cy . get ( '#filter_div > h3' ) . contains ( `Primary (Record) Filter - Filters the ${ tableName } table records` ) ;
59
- } ) ;
36
+ // Click add report
37
+ cy . get ( '#report_vmdb_choice' ) . click ( ) . then ( ( ) => {
38
+ cy . get ( '.bx--overflow-menu-options__btn' ) . then ( ( list ) => {
39
+ cy . get ( list . children ( ) [ 0 ] ) . click ( ) ;
40
+ } ) ;
41
+ } ) ;
60
42
61
- // Set chart type and make sure chart loads correctly
62
- let sortBy = '' ;
63
- let chartType = '' ;
64
- cy . get ( '#Summary_tab > a' ) . click ( { force : true } ) ;
65
- cy . get ( '#sort_div' ) . get ( '.btn-group > .btn' ) . click ( { force : true } ) ;
66
- cy . get ( '[data-original-index="1"] > a' ) . then ( ( option ) => {
67
- cy . get ( option ) . click ( { force : true } ) ;
68
- sortBy = option [ 0 ] . innerText ;
69
- } ) ;
70
- cy . get ( '#Charts_tab > a' ) . click ( { force : true } ) ;
71
- cy . get ( '#chart_div' ) . get ( '.btn-group > .btn' ) . click ( { force : true } ) ;
72
- cy . get ( '[data-original-index="1"] > a' ) . then ( ( option ) => {
73
- cy . get ( option ) . click ( { force : true } ) ;
74
- chartType = option [ 0 ] . innerText ;
75
- } ) ;
76
- cy . get ( '#chart_sample_div > fieldset' ) ;
77
-
78
- // Load report preview and verify column values
79
- cy . get ( '#Preview_tab > a' ) . click ( { force : true } ) ;
80
- cy . get ( '#form_preview > h3' ) . get ( 'a > .fa' ) . click ( { force : true } ) ;
81
- cy . get ( '#form_preview' ) . get ( 'h3' ) . contains ( 'Chart Preview (up to 50 rows)' ) ;
82
- cy . get ( '#form_preview' ) . get ( 'h3' ) . contains ( 'Report Preview (up to 50 rows)' ) ;
83
- cy . get ( '#form_preview' ) . get ( 'th' ) . then ( ( result ) => {
84
- expect ( result [ 0 ] . innerText ) . to . eq ( columns [ 0 ] ) ;
85
- expect ( result [ 1 ] . innerText ) . to . eq ( columns [ 1 ] ) ;
86
- } ) ;
43
+ // Fill out report information, wait for fields changed
44
+ cy . intercept ( '/report/form_field_changed/new' ) . as ( 'fieldsChanged' ) ;
45
+ cy . get ( '#name' ) . type ( 'Cypress Test Report' , { force : true } ) ;
46
+ cy . wait ( '@fieldsChanged' ) ;
87
47
88
- cy . get ( '#buttons_on > .btn-primary' ) . click ( { force : true } ) ; // Click Add button
48
+ cy . get ( '#title' ) . type ( 'Cypress test report title' , { force : true } )
49
+ cy . wait ( '@fieldsChanged' ) ;
89
50
90
- // Navigate to the report that was just added
91
- cy . expect_show_list_title ( 'All Reports' ) ;
92
- cy . get ( '.clickable-row' ) . contains ( 'My Company' ) . click ( ) ;
93
- cy . expect_show_list_title ( 'My Company (All Groups) Reports' ) ;
94
- cy . get ( '.clickable-row' ) . contains ( 'Custom' ) . click ( { force : true } ) ;
95
- cy . expect_show_list_title ( 'Custom Reports' ) ;
96
- cy . get ( '.list-group-item' ) . contains ( 'Cypress Test Report' ) . click ( ) ;
51
+ let basedOn = '' ;
52
+ let columns = [ ] ;
53
+ let tableName = '' ;
97
54
98
- // Verify report was added with correct values on summary page
99
- let tableHeaders = [ ] ;
100
- let tableValues = [ ] ;
101
- let id ;
102
- cy . get ( '.label_header' ) . then ( ( headers ) => {
103
- const nums = [ ...Array ( headers . length ) . keys ( ) ] ;
104
- nums . forEach ( ( index ) => {
105
- tableHeaders . push ( headers [ index ] . innerText ) ;
106
- } ) ;
107
- } ) . then ( ( ) => {
108
- expect ( tableHeaders [ 0 ] ) . to . eq ( 'ID' ) ;
109
- expect ( tableHeaders [ 1 ] ) . to . eq ( 'Title' ) ;
110
- expect ( tableHeaders [ 2 ] ) . to . eq ( 'Sort By' ) ;
111
- expect ( tableHeaders [ 3 ] ) . to . eq ( 'Chart' ) ;
112
- expect ( tableHeaders [ 4 ] ) . to . eq ( 'Based On' ) ;
113
- expect ( tableHeaders [ 5 ] ) . to . eq ( 'User' ) ;
114
- expect ( tableHeaders [ 6 ] ) . to . eq ( 'EVM Group' ) ;
115
- expect ( tableHeaders [ 7 ] ) . to . eq ( 'Updated On' ) ;
116
- } ) ;
117
- cy . get ( '.content_value' ) . then ( ( values ) => {
118
- const nums = [ ...Array ( values . length ) . keys ( ) ] ;
119
- id = values [ 0 ] . innerText ;
120
- nums . forEach ( ( index ) => {
121
- tableValues . push ( values [ index ] . innerText ) ;
55
+ cy . get ( '.btn[data-id="chosen_model"]' ) . click ( { force : true } ) ;
56
+ cy . get ( '.btn[data-id="chosen_model"] ~ .dropdown-menu [data-original-index="1"] > a' ) . then ( ( option ) => {
57
+ cy . get ( option ) . click ( { force : true } ) ;
58
+ basedOn = option [ 0 ] . innerText ;
59
+ tableName = basedOn . substring ( 0 , basedOn . length - 1 ) . replace ( ' ' , '' ) ;
122
60
} ) ;
123
- } ) . then ( ( ) => {
124
- expect ( tableValues [ 1 ] ) . to . eq ( 'Cypress test report title' ) ;
125
- expect ( tableValues [ 2 ] ) . to . eq ( sortBy ) ;
126
- expect ( chartType ) . to . include ( tableValues [ 3 ] ) ;
127
- expect ( basedOn ) . to . include ( tableValues [ 4 ] ) ;
128
- expect ( tableValues [ 5 ] ) . to . eq ( 'admin' ) ;
129
- } ) . then ( ( ) => {
130
- // Click edit report
131
- cy . get ( '#report_vmdb_choice' ) . click ( ) . then ( ( ) => {
132
- cy . get ( '.bx--overflow-menu-options__btn' ) . then ( ( list ) => {
133
- cy . get ( list . children ( ) [ 1 ] ) . click ( ) ;
134
- } ) ;
61
+ cy . get ( '.btn[data-id="available_fields"]' ) . click ( { force : true } ) ;
62
+ cy . get ( '.btn[data-id="available_fields"] ~ .dropdown-menu [data-original-index="0"] > a > .text' ) . then ( ( option ) => {
63
+ cy . get ( option ) . click ( { force : true } ) ;
64
+ columns . push ( option [ 0 ] . innerText . trim ( ) ) ;
135
65
} ) ;
136
- // Edit report information
137
- cy . get ( '#name' ) . clear ( { force : true } ) . type ( 'Cypress Test Report Edit' , { force : true } ) ;
138
- cy . get ( '#title' ) . clear ( { force : true } ) . type ( 'Cypress test report title edit' , { force : true } ) ;
139
-
140
- cy . get ( '[align="left"] > .btn-group > .btn' ) . click ( { force : true } ) ;
141
- cy . get ( '[align="left"] > .btn-group > .open > .dropdown-menu > [data-original-index="24"] > a' ) . then ( ( option ) => {
66
+ cy . get ( '.btn[data-id="available_fields"] ~ .dropdown-menu [data-original-index="1"] > a > .text' ) . then ( ( option ) => {
142
67
cy . get ( option ) . click ( { force : true } ) ;
143
68
columns . push ( option [ 0 ] . innerText . trim ( ) ) ;
144
69
} ) ;
145
- cy . get ( '[align="left"] > .btn-group > .btn > .filter-option' ) . click ( { force : true } ) ;
146
- cy . intercept ( `/report/form_field_changed/${ id } ?button=right` ) . as ( 'fieldsChanged' ) ;
147
- cy . get ( '.text-center > [alt="Move selected fields down"]' ) . click ( { force : true } ) ;
148
- cy . wait ( '@fieldsChanged' ) ;
149
-
70
+ cy . get ( '.btn[data-id="available_fields"]' ) . click ( { force : true } ) ;
71
+ cy . intercept ( '/report/form_field_changed/new?button=right' ) . as ( 'fieldsChanged' ) ;
72
+ cy . get ( '[alt="Move selected fields down"]' ) . click ( { force : true } ) ;
73
+ cy . wait ( '@fieldsChanged' ) . then ( ( ) => {
150
74
// Verify all report page tabs load correctly
151
- cy . get ( '#Consolidation_tab > a' ) . click ( { force : true } ) ;
152
- cy . get ( '#consolidate_div > h3' ) . contains ( 'Group Records by up to 3 Columns' ) ;
153
- cy . get ( '#Formatting_tab > a' ) . click ( { force : true } ) ;
154
- cy . get ( '#formatting_div > h3' ) . contains ( 'PDF Output' ) ;
155
- cy . get ( '#Styling_tab > a' ) . click ( { force : true } ) ;
156
- cy . get ( '#styling_div > h3' ) . contains ( 'Specify Column Styles' ) ;
157
- cy . get ( '#Filter_tab > a' ) . click ( { force : true } ) ;
158
- cy . get ( '#filter_div > h3' ) . contains ( `Primary (Record) Filter - Filters the ${ tableName } table records` ) ;
159
-
160
- // Edit report chart values and verify chart and report are correctly created
161
- sortBy = '' ;
162
- chartType = '' ;
75
+ cy . get ( '#Consolidation_tab > a' ) . click ( { force : true } ) ;
76
+ cy . get ( '#consolidate_div > h3' ) . contains ( 'Group Records by up to 3 Columns' ) ;
77
+ cy . get ( '#Formatting_tab > a' ) . click ( { force : true } ) ;
78
+ cy . get ( '#formatting_div > h3' ) . contains ( 'PDF Output' ) ;
79
+ cy . get ( '#Styling_tab > a' ) . click ( { force : true } ) ;
80
+ cy . get ( '#styling_div > h3' ) . contains ( 'Specify Column Styles' ) ;
81
+ cy . get ( '#Filter_tab > a' ) . click ( { force : true } ) ;
82
+ cy . get ( '#filter_div > h3' ) . contains ( `Primary (Record) Filter - Filters the ${ tableName } table records` ) ;
83
+ } ) ;
84
+
85
+ // Set chart type and make sure chart loads correctly
86
+ let sortBy = '' ;
87
+ let chartType = '' ;
163
88
cy . get ( '#Summary_tab > a' ) . click ( { force : true } ) ;
164
- cy . get ( ':nth-child(2) > :nth-child(1) > .col-md-8 > .btn-group > .btn' ) . click ( { force : true } ) ;
165
- cy . get ( ':nth-child(1) > .col-md-8 > . btn-group > .open > . dropdown-menu > [data-original-index="3 "] > a' ) . then ( ( option ) => {
89
+ cy . get ( '#sort_div .btn' ) . click ( { force : true } ) ;
90
+ cy . get ( '#sort_div . btn ~ . dropdown-menu [data-original-index="1 "] > a' ) . then ( ( option ) => {
166
91
cy . get ( option ) . click ( { force : true } ) ;
167
92
sortBy = option [ 0 ] . innerText ;
168
93
} ) ;
169
94
cy . get ( '#Charts_tab > a' ) . click ( { force : true } ) ;
170
- cy . get ( '#chart_div' ) . get ( ':nth-child(1) > .col-md-8 > .btn-group > .btn') . click ( { force : true } ) ;
171
- cy . get ( ':nth-child(1) > .col-md-8 > . btn-group > .open > . dropdown-menu > [data-original-index="3 "] > a' ) . then ( ( option ) => {
95
+ cy . get ( '#chart_div .btn' ) . click ( { force : true } ) ;
96
+ cy . get ( '#chart_div . btn ~ . dropdown-menu [data-original-index="1 "] > a' ) . then ( ( option ) => {
172
97
cy . get ( option ) . click ( { force : true } ) ;
173
98
chartType = option [ 0 ] . innerText ;
174
99
} ) ;
175
100
cy . get ( '#chart_sample_div > fieldset' ) ;
176
101
102
+ // Load report preview and verify column values
177
103
cy . get ( '#Preview_tab > a' ) . click ( { force : true } ) ;
178
- cy . get ( '#form_preview > h3' ) . get ( 'a > .fa ') . click ( { force : true } ) ;
179
- cy . get ( '#form_preview' ) . get ( ' h3') . contains ( 'Chart Preview (up to 50 rows)' ) ;
180
- cy . get ( '#form_preview' ) . get ( ' h3') . contains ( 'Report Preview (up to 50 rows)' ) ;
181
- cy . get ( '#form_preview' ) . get ( ' th') . then ( ( result ) => {
104
+ cy . get ( '#form_preview a ' ) . click ( { force : true } ) ;
105
+ cy . get ( '#form_preview h3' ) . contains ( 'Chart Preview (up to 50 rows)' ) ;
106
+ cy . get ( '#form_preview h3' ) . contains ( 'Report Preview (up to 50 rows)' ) ;
107
+ cy . get ( '#form_preview table th' ) . then ( ( result ) => {
182
108
expect ( result [ 0 ] . innerText ) . to . eq ( columns [ 0 ] ) ;
183
109
expect ( result [ 1 ] . innerText ) . to . eq ( columns [ 1 ] ) ;
184
- expect ( result [ 2 ] . innerText ) . to . eq ( columns [ 2 ] ) ;
185
110
} ) ;
186
- cy . get ( '#buttons_on > .btn-primary' ) . click ( { force : true } ) ; // Click save button
187
- } ) . then ( ( ) => {
188
- // Verify report was edited with correct values on summary page
189
- tableHeaders = [ ] ;
190
- tableValues = [ ] ;
191
- cy . get ( '.list-group-item' ) . contains ( 'Cypress Test Report Edit' ) . click ( ) ;
111
+
112
+ cy . get ( '#buttons_on > .btn-primary' ) . click ( { force : true } ) ; // Click Add button
113
+ cy . get ( '.alert-success' ) ;
114
+
115
+ // Navigate to the report that was just added
116
+ cy . expect_show_list_title ( 'All Reports' ) ;
117
+ cy . get ( '.clickable-row' ) . contains ( 'My Company' ) . click ( ) ;
118
+ cy . expect_show_list_title ( 'My Company (All Groups) Reports' ) ;
119
+ cy . get ( '.clickable-row' ) . contains ( 'Custom' ) . click ( { force : true } ) ;
120
+ cy . expect_show_list_title ( 'Custom Reports' ) ;
121
+ cy . get ( '.list-group-item' ) . contains ( 'Cypress Test Report' ) . click ( ) ;
122
+
123
+ // Verify report was added with correct values on summary page
124
+ let tableHeaders = [ ] ;
125
+ let tableValues = [ ] ;
126
+ let id ;
192
127
cy . get ( '.label_header' ) . then ( ( headers ) => {
193
128
const nums = [ ...Array ( headers . length ) . keys ( ) ] ;
194
129
nums . forEach ( ( index ) => {
@@ -212,24 +147,111 @@ describe('Overview > Reports Tests', () => {
212
147
tableValues . push ( values [ index ] . innerText ) ;
213
148
} ) ;
214
149
} ) . then ( ( ) => {
215
- expect ( tableValues [ 0 ] ) . to . eq ( `${ id } ` ) ;
216
- expect ( tableValues [ 1 ] ) . to . eq ( 'Cypress test report title edit' ) ;
150
+ expect ( tableValues [ 1 ] ) . to . eq ( 'Cypress test report title' ) ;
217
151
expect ( tableValues [ 2 ] ) . to . eq ( sortBy ) ;
218
152
expect ( chartType ) . to . include ( tableValues [ 3 ] ) ;
219
153
expect ( basedOn ) . to . include ( tableValues [ 4 ] ) ;
220
154
expect ( tableValues [ 5 ] ) . to . eq ( 'admin' ) ;
221
- } ) ;
155
+ } ) . then ( ( ) => {
156
+ // Click edit report
157
+ cy . get ( '#report_vmdb_choice' ) . click ( ) . then ( ( ) => {
158
+ cy . get ( '.bx--overflow-menu-options__btn' ) . then ( ( list ) => {
159
+ cy . get ( list . children ( ) [ 1 ] ) . click ( ) ;
160
+ } ) ;
161
+ } ) ;
162
+ // Edit report information
163
+ cy . intercept ( / \/ r e p o r t \/ f o r m _ f i e l d _ c h a n g e d \/ [ 0 - 9 ] + / ) . as ( 'fieldsUpdated' ) ;
164
+ cy . get ( '#name' ) . clear ( { force : true } ) . type ( 'Cypress Test Report Edit' , { force : true } ) ;
165
+ cy . wait ( '@fieldsUpdated' ) ;
166
+
167
+ cy . get ( '#title' ) . clear ( { force : true } ) . type ( 'Cypress test report title edit' , { force : true } ) ;
168
+ cy . wait ( '@fieldsUpdated' ) ;
169
+
170
+ cy . get ( '.btn[data-id="available_fields"]' ) . click ( { force : true } ) ;
171
+ cy . get ( '.btn[data-id="available_fields"] ~ .dropdown-menu [data-original-index="3"] > a > .text' ) . then ( ( option ) => {
172
+ cy . get ( option ) . click ( { force : true } ) ;
173
+ columns . push ( option [ 0 ] . innerText . trim ( ) ) ;
174
+ } ) ;
175
+ cy . get ( '.btn[data-id="available_fields"] > .filter-option' ) . click ( { force : true } ) ;
176
+ cy . intercept ( `/report/form_field_changed/${ id } ?button=right` ) . as ( 'fieldsChanged' ) ;
177
+ cy . get ( '.text-center > [alt="Move selected fields down"]' ) . click ( { force : true } ) ;
178
+ cy . wait ( '@fieldsChanged' ) ;
179
+
180
+ // Verify all report page tabs load correctly
181
+ cy . get ( '#Consolidation_tab > a' ) . click ( { force : true } ) ;
182
+ cy . get ( '#consolidate_div > h3' ) . contains ( 'Group Records by up to 3 Columns' ) ;
183
+ cy . get ( '#Formatting_tab > a' ) . click ( { force : true } ) ;
184
+ cy . get ( '#formatting_div > h3' ) . contains ( 'PDF Output' ) ;
185
+ cy . get ( '#Styling_tab > a' ) . click ( { force : true } ) ;
186
+ cy . get ( '#styling_div > h3' ) . contains ( 'Specify Column Styles' ) ;
187
+ cy . get ( '#Filter_tab > a' ) . click ( { force : true } ) ;
188
+ cy . get ( '#filter_div > h3' ) . contains ( `Primary (Record) Filter - Filters the ${ tableName } table records` ) ;
189
+
190
+ // Edit report chart values and verify chart and report are correctly created
191
+ sortBy = '' ;
192
+ chartType = '' ;
193
+ cy . get ( '#Summary_tab > a' ) . click ( { force : true } ) ;
194
+ cy . get ( ':nth-child(2) > :nth-child(1) > .col-md-8 > .btn-group > .btn' ) . click ( { force : true } ) ;
195
+ cy . get ( ':nth-child(1) > .col-md-8 > .btn-group > .open > .dropdown-menu > [data-original-index="3"] > a' ) . then ( ( option ) => {
196
+ cy . get ( option ) . click ( { force : true } ) ;
197
+ sortBy = option [ 0 ] . innerText ;
198
+ } ) ;
199
+ cy . get ( '#Charts_tab > a' ) . click ( { force : true } ) ;
200
+ cy . get ( '#chart_div' ) . get ( ':nth-child(1) > .col-md-8 > .btn-group > .btn' ) . click ( { force : true } ) ;
201
+ cy . get ( ':nth-child(1) > .col-md-8 > .btn-group > .open > .dropdown-menu > [data-original-index="3"] > a' ) . then ( ( option ) => {
202
+ cy . get ( option ) . click ( { force : true } ) ;
203
+ chartType = option [ 0 ] . innerText ;
204
+ } ) ;
205
+ cy . get ( '#chart_sample_div > fieldset' ) ;
206
+
207
+ cy . get ( '#Preview_tab > a' ) . click ( { force : true } ) ;
208
+ cy . get ( '#form_preview > h3' ) . get ( 'a > .fa' ) . click ( { force : true } ) ;
209
+ cy . get ( '#form_preview' ) . get ( 'h3' ) . contains ( 'Chart Preview (up to 50 rows)' ) ;
210
+ cy . get ( '#form_preview' ) . get ( 'h3' ) . contains ( 'Report Preview (up to 50 rows)' ) ;
211
+ cy . get ( '#form_preview' ) . get ( 'th' ) . then ( ( result ) => {
212
+ expect ( result [ 0 ] . innerText ) . to . eq ( columns [ 0 ] ) ;
213
+ expect ( result [ 1 ] . innerText ) . to . eq ( columns [ 1 ] ) ;
214
+ expect ( result [ 2 ] . innerText ) . to . eq ( columns [ 2 ] ) ;
215
+ } ) ;
216
+ cy . get ( '#buttons_on > .btn-primary' ) . click ( { force : true } ) ; // Click save button
217
+ } ) . then ( ( ) => {
218
+ cy . get ( '.alert-success' ) ;
219
+ // Verify report was edited with correct values on summary page
220
+ tableHeaders = [ ] ;
221
+ tableValues = [ ] ;
222
+ cy . get ( '.list-group-item' ) . contains ( 'Cypress Test Report Edit' ) . click ( ) ;
223
+ cy . get ( '.label_header' ) . then ( ( headers ) => {
224
+ const nums = [ ...Array ( headers . length ) . keys ( ) ] ;
225
+ nums . forEach ( ( index ) => {
226
+ tableHeaders . push ( headers [ index ] . innerText ) ;
227
+ } ) ;
228
+ } ) . then ( ( ) => {
229
+ expect ( tableHeaders [ 0 ] ) . to . eq ( 'ID' ) ;
230
+ expect ( tableHeaders [ 1 ] ) . to . eq ( 'Title' ) ;
231
+ expect ( tableHeaders [ 2 ] ) . to . eq ( 'Sort By' ) ;
232
+ expect ( tableHeaders [ 3 ] ) . to . eq ( 'Chart' ) ;
233
+ expect ( tableHeaders [ 4 ] ) . to . eq ( 'Based On' ) ;
234
+ expect ( tableHeaders [ 5 ] ) . to . eq ( 'User' ) ;
235
+ expect ( tableHeaders [ 6 ] ) . to . eq ( 'EVM Group' ) ;
236
+ expect ( tableHeaders [ 7 ] ) . to . eq ( 'Updated On' ) ;
237
+ } ) ;
222
238
223
- // Delete report and verify that it was deleted
224
- cy . intercept ( `/report/x_button/${ id } ?pressed=miq_report_delete` ) . as ( 'delete' ) ;
225
- cy . get ( '#report_vmdb_choice' ) . click ( ) . then ( ( ) => {
226
- cy . get ( '.bx--overflow-menu-options__btn' ) . then ( ( list ) => {
227
- cy . get ( list . children ( ) [ 4 ] ) . click ( ) ;
239
+ cy . get ( '.content_value' ) . then ( ( values ) => {
240
+ const nums = [ ...Array ( values . length ) . keys ( ) ] ;
241
+ id = values [ 0 ] . innerText ;
242
+ nums . forEach ( ( index ) => {
243
+ tableValues . push ( values [ index ] . innerText ) ;
244
+ } ) ;
245
+ } ) . then ( ( ) => {
246
+ expect ( tableValues [ 0 ] ) . to . eq ( `${ id } ` ) ;
247
+ expect ( tableValues [ 1 ] ) . to . eq ( 'Cypress test report title edit' ) ;
248
+ expect ( tableValues [ 2 ] ) . to . eq ( sortBy ) ;
249
+ expect ( chartType ) . to . include ( tableValues [ 3 ] ) ;
250
+ expect ( basedOn ) . to . include ( tableValues [ 4 ] ) ;
251
+ expect ( tableValues [ 5 ] ) . to . eq ( 'admin' ) ;
228
252
} ) ;
229
253
} ) ;
230
- cy . wait ( '@delete' ) ;
231
- cy . get ( '.list-group-item' ) . should ( 'not.contain' , 'Cypress Test Report Edit' ) ;
232
- } ) ;
254
+ } ) ;
233
255
} ) ;
234
256
235
257
it ( 'Can add, edit and delete a schedule' , ( ) => {
0 commit comments