1
1
/* eslint-disable no-undef */
2
2
3
- function selectConfigMenu ( configuration = 'Add a new Schedule' ) {
3
+ const textConstants = {
4
+ // Field values
5
+ initialScheduleName : 'Test name' ,
6
+ editedScheduleName : 'Dummy name' ,
7
+ initialDescription : 'Test description' ,
8
+ editedDescription : 'Dummy description' ,
9
+ actionTypeVmAnalysis : 'vm' ,
10
+ actionTypeTemplateAnalysis : 'miq_template' ,
11
+ actionTypeHostAnalysis : 'host' ,
12
+ actionTypeContainerAnalysis : 'container_image' ,
13
+ actionTypeClusterAnalysis : 'emscluster' ,
14
+ actionTypeDataStoreAnalysis : 'storage' ,
15
+ actionTypeVmCompilanceCheck : 'vm_check_compliance' ,
16
+ actionTypeHostCompilanceCheck : 'host_check_compliance' ,
17
+ actionTypeContainerCompilanceCheck : 'container_image_check_compliance' ,
18
+ actionTypeAutomationTasks : 'automation_request' ,
19
+ filterTypeVmCluster : 'cluster' ,
20
+ timerTypeOnce : 'Once' ,
21
+ timerTypeHourly : 'Hourly' ,
22
+ timerTypeDaily : 'Daily' ,
23
+ timerTypeWeekly : 'Weekly' ,
24
+ timerTypeMonthly : 'Monthly' ,
25
+ frequencyTypeHour : '1 Hour' ,
26
+ timezoneTypeHawaii : '(GMT-10:00) Hawaii' ,
27
+ initialStartDate : '06/30/2025' ,
28
+ editedStartDate : '07/21/2025' ,
29
+ startTime : '11:23' ,
30
+
31
+ // Buttons
32
+ saveButton : 'Save' ,
33
+ cancelButton : 'Cancel' ,
34
+ resetButton : 'Reset' ,
35
+
36
+ // Config options
37
+ addScheduleConfigOption : 'Add a new Schedule' ,
38
+ deleteScheduleConfigOption : 'Delete this Schedule from the Database' ,
39
+ editScheduleConfigOption : 'Edit this Schedule' ,
40
+ disableScheduleConfigOption : 'Disable this Schedule' ,
41
+ enableScheduleConfigOption : 'Enable this Schedule' ,
42
+ queueScheduleConfigOption : 'Queue up this Schedule to run now' ,
43
+
44
+ // Menu options
45
+ settingsMenuOption : 'Settings' ,
46
+ appSettingsMenuOption : 'Application Settings' ,
47
+ } ;
48
+
49
+ const {
50
+ settingsMenuOption,
51
+ appSettingsMenuOption,
52
+ actionTypeVmAnalysis,
53
+ actionTypeTemplateAnalysis,
54
+ actionTypeHostAnalysis,
55
+ actionTypeContainerAnalysis,
56
+ actionTypeClusterAnalysis,
57
+ actionTypeDataStoreAnalysis,
58
+ actionTypeVmCompilanceCheck,
59
+ actionTypeHostCompilanceCheck,
60
+ actionTypeContainerCompilanceCheck,
61
+ actionTypeAutomationTasks,
62
+ timerTypeOnce,
63
+ timerTypeHourly,
64
+ timerTypeDaily,
65
+ timerTypeWeekly,
66
+ timerTypeMonthly,
67
+ cancelButton,
68
+ saveButton,
69
+ initialScheduleName,
70
+ editScheduleConfigOption,
71
+ editedScheduleName,
72
+ editedDescription,
73
+ editedStartDate,
74
+ resetButton,
75
+ initialDescription,
76
+ initialStartDate,
77
+ disableScheduleConfigOption,
78
+ enableScheduleConfigOption,
79
+ queueScheduleConfigOption,
80
+ addScheduleConfigOption,
81
+ frequencyTypeHour,
82
+ timezoneTypeHawaii,
83
+ startTime,
84
+ deleteScheduleConfigOption,
85
+ } = textConstants ;
86
+
87
+ function selectConfigMenu ( configuration = addScheduleConfigOption ) {
4
88
cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
5
89
cy . get ( `ul[aria-label="Configuration"] [title="${ configuration } "]` ) . click ( ) ;
6
90
}
@@ -10,31 +94,36 @@ function addSchedule() {
10
94
// Checks if Save button is disabled initially
11
95
cy . contains (
12
96
'#main-content .bx--btn-set button[type="submit"]' ,
13
- 'Save'
97
+ saveButton
14
98
) . should ( 'be.disabled' ) ;
15
99
// Adding data
16
- cy . get ( 'input#name' ) . type ( 'Test name' ) ;
17
- cy . get ( 'input#description' ) . type ( 'Test description' ) ;
100
+ cy . get ( 'input#name' ) . type ( initialScheduleName ) ;
101
+ cy . get ( 'input#description' ) . type ( initialDescription ) ;
18
102
cy . get ( 'input[type="checkbox"]#enabled' ) . check ( { force : true } ) ;
19
- cy . get ( 'select#action_typ' ) . select ( 'VM Analysis' ) ;
20
- cy . get ( 'select#filter_typ' ) . select ( 'A single VM' ) ;
21
- cy . get ( 'select#timer_typ' ) . select ( 'Hourly' ) ;
22
- cy . get ( 'select#timer_value' ) . select ( '1 Hour' ) ;
103
+ // Select Action type option: 'VM Analysis'
104
+ cy . get ( 'select#action_typ' ) . select ( actionTypeVmAnalysis ) ;
105
+ // Select Filter type option: 'A Single VM'
106
+ cy . get ( 'select#filter_typ' ) . select ( actionTypeVmAnalysis ) ;
107
+ // Select Run option: 'Hours'
108
+ cy . get ( 'select#timer_typ' ) . select ( timerTypeHourly ) ;
109
+ // Select Every option: '1 Hour'
110
+ cy . get ( 'select#timer_value' ) . select ( frequencyTypeHour ) ;
111
+ // Select Time zone option: '(GMT-10:00) Hawaii'
23
112
cy . get ( 'input[role="combobox"]#time_zone' ) . click ( ) ;
24
- cy . contains ( '[role="option"]' , '(GMT-10:00) Hawaii' )
113
+ cy . contains ( '[role="option"]' , timezoneTypeHawaii )
25
114
. should ( 'be.visible' )
26
115
. click ( ) ;
27
- cy . get ( 'input#start_date' ) . type ( '06/30/2025' ) ;
28
- cy . get ( 'input#start_time' ) . type ( '11:23' ) ;
116
+ cy . get ( 'input#start_date' ) . type ( initialStartDate ) ;
117
+ cy . get ( 'input#start_time' ) . type ( startTime ) ;
29
118
// Checks if Save button is enabled once all required fields are filled
30
- cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , 'Save' )
119
+ cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , saveButton )
31
120
. should ( 'be.enabled' )
32
121
. click ( ) ;
33
122
}
34
123
35
- function deleteSchedule ( scheduleName = 'Test name' ) {
124
+ function deleteSchedule ( scheduleName = initialScheduleName ) {
36
125
// Selecting the schedule
37
- cy . contains ( 'li.list-group-item' , scheduleName ) . click ( ) ;
126
+ cy . accordionItem ( scheduleName ) ;
38
127
// Listening for the browser confirm alert and confirming
39
128
cy . listen_for_browser_confirm_alert ( ) ;
40
129
selectConfigMenu ( deleteScheduleConfigOption ) ;
@@ -45,12 +134,12 @@ function invokeCleanupDeletion() {
45
134
// Iterate and clean up any leftover schedules created during the test
46
135
cy . get ( 'li.list-group-item' ) . each ( ( $el ) => {
47
136
const text = $el ?. text ( ) ?. trim ( ) ;
48
- if ( text === 'Test name' ) {
137
+ if ( text === initialScheduleName ) {
49
138
deleteSchedule ( ) ;
50
139
return false ;
51
140
}
52
- if ( text === 'Dummy name' ) {
53
- deleteSchedule ( 'Dummy name' ) ;
141
+ if ( text === editedScheduleName ) {
142
+ deleteSchedule ( editedScheduleName ) ;
54
143
return false ;
55
144
}
56
145
return true ;
@@ -83,67 +172,73 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
83
172
84
173
/* ===== Selecting any option other than "Automation Tasks" from "Action" dropdown does not hide the Filter dropdown ===== */
85
174
86
- cy . get ( 'select#action_typ' ) . select ( 'VM Analysis' ) ;
87
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'vm' ) ;
175
+ cy . get ( 'select#action_typ' ) . select ( actionTypeVmAnalysis ) ;
176
+ cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeVmAnalysis ) ;
88
177
// Checking for Filter type dropdown
89
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
90
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
178
+ verifyFilterTypeDropdownExists ( ) ;
91
179
92
- cy . get ( 'select#action_typ' ) . select ( 'Template Analysis' ) ;
93
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'miq_template' ) ;
180
+ cy . get ( 'select#action_typ' ) . select ( actionTypeTemplateAnalysis ) ;
181
+ cy . get ( 'select#action_typ' ) . should (
182
+ 'have.value' ,
183
+ actionTypeTemplateAnalysis
184
+ ) ;
94
185
// Checking for Filter type dropdown
95
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
96
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
186
+ verifyFilterTypeDropdownExists ( ) ;
97
187
98
- cy . get ( 'select#action_typ' ) . select ( 'Host Analysis' ) ;
99
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'host' ) ;
188
+ cy . get ( 'select#action_typ' ) . select ( actionTypeHostAnalysis ) ;
189
+ cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeHostAnalysis ) ;
100
190
// Checking for Filter type dropdown
101
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
102
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
191
+ verifyFilterTypeDropdownExists ( ) ;
103
192
104
- cy . get ( 'select#action_typ' ) . select ( 'Container Image Analysis' ) ;
105
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'container_image' ) ;
193
+ cy . get ( 'select#action_typ' ) . select ( actionTypeContainerAnalysis ) ;
194
+ cy . get ( 'select#action_typ' ) . should (
195
+ 'have.value' ,
196
+ actionTypeContainerAnalysis
197
+ ) ;
106
198
// Checking for Filter type dropdown
107
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
108
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
199
+ verifyFilterTypeDropdownExists ( ) ;
109
200
110
- cy . get ( 'select#action_typ' ) . select ( 'Cluster Analysis' ) ;
111
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'emscluster' ) ;
201
+ cy . get ( 'select#action_typ' ) . select ( actionTypeClusterAnalysis ) ;
202
+ cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeClusterAnalysis ) ;
112
203
// Checking for Filter type dropdown
113
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
114
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
204
+ verifyFilterTypeDropdownExists ( ) ;
115
205
116
- cy . get ( 'select#action_typ' ) . select ( 'Datastore Analysis' ) ;
117
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'storage' ) ;
206
+ cy . get ( 'select#action_typ' ) . select ( actionTypeDataStoreAnalysis ) ;
207
+ cy . get ( 'select#action_typ' ) . should (
208
+ 'have.value' ,
209
+ actionTypeDataStoreAnalysis
210
+ ) ;
118
211
// Checking for Filter type dropdown
119
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
120
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
212
+ verifyFilterTypeDropdownExists ( ) ;
121
213
122
- cy . get ( 'select#action_typ' ) . select ( 'VM Compliance Check' ) ;
123
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'vm_check_compliance' ) ;
214
+ cy . get ( 'select#action_typ' ) . select ( actionTypeVmCompilanceCheck ) ;
215
+ cy . get ( 'select#action_typ' ) . should (
216
+ 'have.value' ,
217
+ actionTypeVmCompilanceCheck
218
+ ) ;
124
219
// Checking for Filter type dropdown
125
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
126
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
220
+ verifyFilterTypeDropdownExists ( ) ;
127
221
128
- cy . get ( 'select#action_typ' ) . select ( 'Host Compliance Check' ) ;
129
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'host_check_compliance' ) ;
222
+ cy . get ( 'select#action_typ' ) . select ( actionTypeHostCompilanceCheck ) ;
223
+ cy . get ( 'select#action_typ' ) . should (
224
+ 'have.value' ,
225
+ actionTypeHostCompilanceCheck
226
+ ) ;
130
227
// Checking for Filter type dropdown
131
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
132
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
228
+ verifyFilterTypeDropdownExists ( ) ;
133
229
134
- cy . get ( 'select#action_typ' ) . select ( 'Container Image Compliance Check' ) ;
230
+ cy . get ( 'select#action_typ' ) . select ( actionTypeContainerCompilanceCheck ) ;
135
231
cy . get ( 'select#action_typ' ) . should (
136
232
'have.value' ,
137
- 'container_image_check_compliance'
233
+ actionTypeContainerCompilanceCheck
138
234
) ;
139
235
// Checking for Filter type dropdown
140
- cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
141
- cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
236
+ verifyFilterTypeDropdownExists ( ) ;
142
237
143
238
/* ===== Selecting "Automation Tasks" option from "Action" dropdown shows Zone, Object details & Object fields ===== */
144
239
145
- cy . get ( 'select#action_typ' ) . select ( 'Automation Tasks' ) ;
146
- cy . get ( 'select#action_typ' ) . should ( 'have.value' , 'automation_request' ) ;
240
+ cy . get ( 'select#action_typ' ) . select ( actionTypeAutomationTasks ) ;
241
+ cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeAutomationTasks ) ;
147
242
148
243
// Checking for Zone dropdown
149
244
cy . get ( 'label[for="zone_id"]' ) . should ( 'exist' ) ;
@@ -186,36 +281,35 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
186
281
187
282
/* ===== Selecting "Once" option from "Run" dropdown does not show the "Every" dropdown ===== */
188
283
189
- cy . get ( 'select#timer_typ' ) . select ( 'Once' ) ;
284
+ cy . get ( 'select#timer_typ' ) . select ( timerTypeOnce ) ;
190
285
// Checking whether the Every dropdown is hidden
191
286
cy . get ( 'input#timer_value' ) . should ( 'not.exist' ) ;
192
287
193
288
/* ===== Selecting any other option other than "Once" from "Run" dropdown shows the "Every" dropdown ===== */
194
289
195
- cy . get ( 'select#timer_typ' ) . select ( 'Hours' ) ;
290
+ cy . get ( 'select#timer_typ' ) . select ( timerTypeHourly ) ;
196
291
// Checking whether the "Every" dropdown exist
197
- cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
198
- cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
292
+ verifyTimerDropdownExists ( ) ;
199
293
200
- cy . get ( 'select#timer_typ' ) . select ( 'Days' ) ;
294
+ cy . get ( 'select#timer_typ' ) . select ( timerTypeDaily ) ;
201
295
// Checking whether the "Every" dropdown exist
202
- cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
203
- cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
296
+ verifyTimerDropdownExists ( ) ;
204
297
205
- cy . get ( 'select#timer_typ' ) . select ( 'Weeks' ) ;
298
+ cy . get ( 'select#timer_typ' ) . select ( timerTypeWeekly ) ;
206
299
// Checking whether the "Every" dropdown exist
207
- cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
208
- cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
300
+ verifyTimerDropdownExists ( ) ;
209
301
210
- cy . get ( 'select#timer_typ' ) . select ( 'Months' ) ;
302
+ cy . get ( 'select#timer_typ' ) . select ( timerTypeMonthly ) ;
211
303
// Checking whether the "Every" dropdown exist
212
- cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
213
- cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
304
+ verifyTimerDropdownExists ( ) ;
214
305
} ) ;
215
306
216
307
it ( 'Checking whether Cancel button works on the Add form' , ( ) => {
217
308
selectConfigMenu ( ) ;
218
- cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Cancel' )
309
+ cy . contains (
310
+ '#main-content .bx--btn-set button[type="button"]' ,
311
+ cancelButton
312
+ )
219
313
. should ( 'be.enabled' )
220
314
. click ( ) ;
221
315
cy . expect_flash ( 'success' ) ;
@@ -228,13 +322,13 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
228
322
229
323
/* ===== Editing a schedule ===== */
230
324
// Selecting the created schedule
231
- cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
232
- selectConfigMenu ( 'Edit this Schedule' ) ;
325
+ cy . accordionItem ( initialScheduleName ) ;
326
+ selectConfigMenu ( editScheduleConfigOption ) ;
233
327
// Editing name and description
234
- cy . get ( 'input#name' ) . clear ( ) . type ( 'Dummy name' ) ;
235
- cy . get ( 'input#description' ) . clear ( ) . type ( 'Dummy description' ) ;
328
+ cy . get ( 'input#name' ) . clear ( ) . type ( editedScheduleName ) ;
329
+ cy . get ( 'input#description' ) . clear ( ) . type ( editedDescription ) ;
236
330
// Confirms Save button is enabled after making edits
237
- cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , 'Save' )
331
+ cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , saveButton )
238
332
. should ( 'be.enabled' )
239
333
. click ( ) ;
240
334
cy . expect_flash ( 'success' ) ;
@@ -248,27 +342,30 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
248
342
249
343
/* ===== Checking whether Cancel button works ===== */
250
344
// Selecting the created schedule
251
- cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
252
- selectConfigMenu ( 'Edit this Schedule' ) ;
253
- cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Cancel' )
345
+ cy . accordionItem ( initialScheduleName ) ;
346
+ selectConfigMenu ( editScheduleConfigOption ) ;
347
+ cy . contains (
348
+ '#main-content .bx--btn-set button[type="button"]' ,
349
+ cancelButton
350
+ )
254
351
. should ( 'be.enabled' )
255
352
. click ( ) ;
256
353
cy . expect_flash ( 'success' ) ;
257
354
258
355
/* ===== Checking whether Reset button works ===== */
259
356
// Selecting the created schedule
260
- cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
261
- selectConfigMenu ( 'Edit this Schedule' ) ;
357
+ cy . accordionItem ( initialScheduleName ) ;
358
+ selectConfigMenu ( editScheduleConfigOption ) ;
262
359
// Editing description and start date
263
- cy . get ( 'input#description' ) . clear ( ) . type ( 'Dummy description' ) ;
264
- cy . get ( 'input#start_date' ) . clear ( ) . type ( '07/21/2025' ) ;
265
- cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Reset' )
360
+ cy . get ( 'input#description' ) . clear ( ) . type ( editedDescription ) ;
361
+ cy . get ( 'input#start_date' ) . clear ( ) . type ( editedStartDate ) ;
362
+ cy . contains ( '#main-content .bx--btn-set button[type="button"]' , resetButton )
266
363
. should ( 'be.enabled' )
267
364
. click ( ) ;
268
365
cy . expect_flash ( 'warning' ) ;
269
366
// Confirming the edited fields contain the old values after resetting
270
- cy . get ( 'input#description' ) . should ( 'have.value' , 'Test description' ) ;
271
- cy . get ( 'input#start_date' ) . should ( 'have.value' , '06/30/2025' ) ;
367
+ cy . get ( 'input#description' ) . should ( 'have.value' , initialDescription ) ;
368
+ cy . get ( 'input#start_date' ) . should ( 'have.value' , initialStartDate ) ;
272
369
273
370
// Selecting Schedules menu item to bypass a bug, can be removed once #9505 is merged
274
371
cy . get ( '[title="Schedules"]' ) . click ( ) ;
@@ -287,7 +384,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
287
384
/* ===== Adding a schedule ===== */
288
385
addSchedule ( ) ;
289
386
// Selecting the created schedule
290
- cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
387
+ cy . accordionItem ( initialScheduleName ) ;
291
388
292
389
/* ===== Disabling the schedule ===== */
293
390
selectConfigMenu ( disableScheduleConfigOption ) ;
@@ -309,7 +406,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
309
406
invokeCleanupDeletion ( ) ;
310
407
} else {
311
408
// Navigate to Settings -> Application-Settings before looking out for Schedules created during test
312
- cy . menu ( 'Settings' , 'Application Settings' ) ;
409
+ cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
313
410
invokeCleanupDeletion ( ) ;
314
411
}
315
412
} ) ;
0 commit comments