1
1
/* eslint-disable no-undef */
2
2
3
- function addSchedule ( ) {
3
+ function selectConfigMenu ( configuration = 'Add a new Schedule' ) {
4
4
cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
5
- cy . get ( 'ul[aria-label="Configuration"] [title="Add a new Schedule"]' ) . click ( ) ;
5
+ cy . get ( `ul[aria-label="Configuration"] [title="${ configuration } "]` ) . click ( ) ;
6
+ }
7
+
8
+ function addSchedule ( ) {
9
+ selectConfigMenu ( ) ;
6
10
// Checks if Save button is disabled initially
7
11
cy . contains (
8
12
'#main-content .bx--btn-set button[type="submit"]' ,
@@ -28,19 +32,30 @@ function addSchedule() {
28
32
. click ( ) ;
29
33
}
30
34
35
+ function deleteSchedule ( scheduleName = 'Test name' ) {
36
+ // Selecting the schedule
37
+ cy . contains ( 'li.list-group-item' , scheduleName ) . click ( ) ;
38
+ cy . on ( 'window:confirm' , ( text ) => {
39
+ expect ( text ) . to . eq (
40
+ 'Warning: This Schedule and ALL of its components will be permanently removed!'
41
+ ) ;
42
+ return true ;
43
+ } ) ;
44
+ selectConfigMenu ( 'Delete this Schedule from the Database' ) ;
45
+ cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
46
+ `Schedule "${ scheduleName } ": Delete successful`
47
+ ) ;
48
+ }
49
+
31
50
describe ( 'Automate Schedule form operations: Settings > Application Settings > Settings > Schedules > Configuration > Add a new schedule' , ( ) => {
32
51
beforeEach ( ( ) => {
33
52
cy . login ( ) ;
34
53
cy . menu ( 'Settings' , 'Application Settings' ) ;
35
- cy . get ( '[title="Schedules"]' )
36
- . click ( ) ;
54
+ cy . get ( '[title="Schedules"]' ) . click ( ) ;
37
55
} ) ;
38
56
39
57
it ( 'Validate visibility of elements based on dropdown selections' , ( ) => {
40
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
41
- cy . get (
42
- 'ul[aria-label="Configuration"] [title="Add a new Schedule"]'
43
- ) . click ( ) ;
58
+ selectConfigMenu ( ) ;
44
59
45
60
/* ===== Selecting any option other than "Automation Tasks" from "Action" dropdown does not hide the Filter dropdown ===== */
46
61
@@ -175,10 +190,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
175
190
} ) ;
176
191
177
192
it ( 'Checking whether Cancel button works on the Add form' , ( ) => {
178
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
179
- cy . get (
180
- 'ul[aria-label="Configuration"] [title="Add a new Schedule"]'
181
- ) . click ( ) ;
193
+ selectConfigMenu ( ) ;
182
194
cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Cancel' )
183
195
. should ( 'be.enabled' )
184
196
. click ( ) ;
@@ -187,42 +199,51 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
187
199
) ;
188
200
} ) ;
189
201
190
- it ( 'Checking whether adding a schedule works' , ( ) => {
202
+ it ( 'Checking whether add, edit & delete schedule works' , ( ) => {
203
+ /* ===== Adding a schedule ===== */
191
204
addSchedule ( ) ;
192
205
cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
193
206
'Schedule "Test name" was saved'
194
207
) ;
195
- } ) ;
196
208
197
- it ( 'Checking whether creating a duplicate record is restricted' , ( ) => {
198
- addSchedule ( ) ;
199
- cy . get ( '#main_div #flash_msg_div .alert-danger' ) . contains (
200
- 'Error when adding a new schedule: Validation failed: MiqSchedule: Name has already been taken'
209
+ /* ===== Editing a schedule ===== */
210
+ // Selecting the created schedule
211
+ cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
212
+ selectConfigMenu ( 'Edit this Schedule' ) ;
213
+ // Editing name and description
214
+ cy . get ( 'input#name' ) . clear ( ) . type ( 'Dummy name' ) ;
215
+ cy . get ( 'input#description' ) . clear ( ) . type ( 'Dummy description' ) ;
216
+ // Confirms Save button is enabled after making edits
217
+ cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , 'Save' )
218
+ . should ( 'be.enabled' )
219
+ . click ( ) ;
220
+ cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
221
+ 'Schedule "Dummy name" was saved'
201
222
) ;
223
+
224
+ /* ===== Deleting schedule ===== */
225
+ deleteSchedule ( 'Dummy name' ) ;
202
226
} ) ;
203
227
204
- it ( 'Checking whether Cancel button works on the Edit form' , ( ) => {
228
+ it ( 'Checking whether Cancel & Reset buttons work fine in the Edit form' , ( ) => {
229
+ /* ===== Adding a schedule ===== */
230
+ addSchedule ( ) ;
231
+
232
+ /* ===== Checking whether Cancel button works ===== */
205
233
// Selecting the created schedule
206
234
cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
207
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
208
- cy . get (
209
- 'ul[aria-label="Configuration"] [title="Edit this Schedule"]'
210
- ) . click ( ) ;
235
+ selectConfigMenu ( 'Edit this Schedule' ) ;
211
236
cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Cancel' )
212
237
. should ( 'be.enabled' )
213
238
. click ( ) ;
214
239
cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
215
240
'Edit of "Test name" was cancelled by the user'
216
241
) ;
217
- } ) ;
218
242
219
- it ( ' Checking whether Reset button works on the Edit form' , ( ) => {
243
+ /* ===== Checking whether Reset button works ===== */
220
244
// Selecting the created schedule
221
245
cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
222
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
223
- cy . get (
224
- 'ul[aria-label="Configuration"] [title="Edit this Schedule"]'
225
- ) . click ( ) ;
246
+ selectConfigMenu ( 'Edit this Schedule' ) ;
226
247
// Editing description and start date
227
248
cy . get ( 'input#description' ) . clear ( ) . type ( 'Dummy description' ) ;
228
249
cy . get ( 'input#start_date' ) . clear ( ) . type ( '07/21/2025' , { force : true } ) ;
@@ -235,77 +256,51 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
235
256
// Confirming the edited fields contain the old values after resetting
236
257
cy . get ( 'input#description' ) . should ( 'have.value' , 'Test description' ) ;
237
258
cy . get ( 'input#start_date' ) . should ( 'have.value' , '06/30/2025' ) ;
259
+
260
+ /* ===== Deleting schedule ===== */
261
+ cy . get ( '[title="Schedules"]' ) . click ( ) ;
262
+ deleteSchedule ( ) ;
238
263
} ) ;
239
264
240
- it ( 'Checking whether Edit functionality works' , ( ) => {
241
- // Selecting the created schedule
242
- cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
243
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
244
- cy . get (
245
- 'ul[aria-label="Configuration"] [title="Edit this Schedule"]'
246
- ) . click ( ) ;
247
- // Editing name and description
248
- cy . get ( 'input#name' ) . clear ( ) . type ( 'Dummy name' ) ;
249
- cy . get ( 'input#description' ) . clear ( ) . type ( 'Dummy description' ) ;
250
- // Confirms Save button is enabled after making edits
251
- cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , 'Save' )
252
- . should ( 'be.enabled' )
253
- . click ( ) ;
254
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
255
- 'Schedule "Dummy name" was saved'
265
+ it ( 'Checking whether creating a duplicate record is restricted' , ( ) => {
266
+ /* ===== Adding schedule ===== */
267
+ addSchedule ( ) ;
268
+
269
+ /* ===== Trying to add the same schedule again ===== */
270
+ addSchedule ( ) ;
271
+ cy . get ( '#main_div #flash_msg_div .alert-danger' ) . contains (
272
+ 'Error when adding a new schedule: Validation failed: MiqSchedule: Name has already been taken'
256
273
) ;
274
+
275
+ /* ===== Deleting schedule ===== */
276
+ deleteSchedule ( ) ;
257
277
} ) ;
258
278
259
279
it ( 'Checking whether Disabling, Enabling & Queueing up the schedule works' , ( ) => {
260
- // Selecting the schedule
261
- cy . contains ( 'li.list-group-item' , 'Dummy name' ) . click ( ) ;
262
-
263
- /* ===== Disabling the Schedule ===== */
280
+ /* ===== Adding a schedule ===== */
281
+ addSchedule ( ) ;
282
+ // Selecting the created schedule
283
+ cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
264
284
265
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
266
- cy . get (
267
- 'ul[aria-label="Configuration"] [title="Disable this Schedule"]'
268
- ) . click ( ) ;
285
+ /* ===== Disabling the schedule ===== */
286
+ selectConfigMenu ( 'Disable this Schedule' ) ;
269
287
cy . get ( '#main_div #flash_msg_div .alert-info' ) . contains (
270
288
'The selected Schedules were disabled'
271
289
) ;
272
290
273
- /* ===== Enabling the Schedule ===== */
274
-
275
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
276
- cy . get (
277
- 'ul[aria-label="Configuration"] [title="Enable this Schedule"]'
278
- ) . click ( ) ;
291
+ /* ===== Enabling the schedule ===== */
292
+ selectConfigMenu ( 'Enable this Schedule' ) ;
279
293
cy . get ( '#main_div #flash_msg_div .alert-info' ) . contains (
280
294
'The selected Schedules were enabled'
281
295
) ;
282
296
283
- /* ===== Queueing-up the Schedule ===== */
284
-
285
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
286
- cy . get (
287
- 'ul[aria-label="Configuration"] [title="Queue up this Schedule to run now"]'
288
- ) . click ( ) ;
297
+ /* ===== Queueing-up the schedule ===== */
298
+ selectConfigMenu ( 'Queue up this Schedule to run now' ) ;
289
299
cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
290
300
'The selected Schedule has been queued to run'
291
301
) ;
292
- } ) ;
293
302
294
- it ( 'Checking whether Deleting the schedule works' , ( ) => {
295
- // Selecting the schedule
296
- cy . contains ( 'li.list-group-item' , 'Dummy name' ) . click ( ) ;
297
- cy . get ( '#miq_schedule_vmdb_choice' ) . click ( ) ;
298
- cy . on ( 'window:confirm' , ( text ) => {
299
- expect ( text ) . to . eq (
300
- 'Warning: This Schedule and ALL of its components will be permanently removed!'
301
- ) ;
302
- return true ;
303
- } ) ;
304
- cy . get (
305
- 'ul[aria-label="Configuration"] [title="Delete this Schedule from the Database"]'
306
- ) . click ( ) ;
307
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
308
- 'Schedule "Dummy name": Delete successful'
309
- ) ;
303
+ /* ===== Deleting schedule ===== */
304
+ deleteSchedule ( ) ;
310
305
} ) ;
311
306
} ) ;
0 commit comments