Skip to content

Commit 5cefccb

Browse files
Replaced repeated form selectors with custom getter commands
1 parent 12fb846 commit 5cefccb

File tree

1 file changed

+67
-44
lines changed

1 file changed

+67
-44
lines changed

cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js

Lines changed: 67 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ function addSchedule() {
125125
alias: 'addScheduleApi',
126126
urlPattern: '/ops/schedule_edit/new?button=save',
127127
triggerFn: () =>
128-
cy.contains('#main-content .bx--btn-set button[type="submit"]', saveButton)
128+
cy
129+
.getFormFooterButtonByTypeWithText({
130+
buttonText: SAVE_BUTTON_TEXT,
131+
buttonType: 'submit',
132+
})
129133
.should('be.enabled') // Checks if Save button is enabled once all required fields are filled
130134
.click(),
131135
});
@@ -171,37 +175,40 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
171175
cy.getFormLabelByForAttribute({ forValue: 'description' })
172176
.should('be.visible')
173177
.and('contain.text', DESCRIPTION_FIELD_LABEL);
174-
cy.getFormInputFieldById('description')
178+
cy.getFormInputFieldByIdAndType({ inputId: 'description' })
175179
.should('be.visible')
176180
.and('be.enabled');
177181
cy.getFormLabelByForAttribute({ forValue: 'enabled' })
178182
.should('be.visible')
179183
.and('contain.text', ACTIVE_CHECKBOX_FIELD_LABEL);
180-
cy.getFormInputFieldById('enabled', 'checkbox')
184+
cy.getFormInputFieldByIdAndType({
185+
inputId: 'enabled',
186+
inputType: 'checkbox',
187+
})
181188
.should('be.visible')
182189
.and('be.enabled');
183190

184191
/* ===== Selecting any option other than "Automation Tasks" from "Action" dropdown does not hide the Filter dropdown ===== */
185192
cy.getFormLabelByForAttribute({ forValue: 'action_typ' })
186193
.should('be.visible')
187194
.and('contain.text', ACTION_TYPE_FIELD_LABEL);
188-
cy.getFormSelectFieldById('action_typ')
195+
cy.getFormSelectFieldById({ selectId: 'action_typ' })
189196
.should('be.visible')
190197
.and('be.enabled')
191198
.select(ACTION_TYPE_VM_ANALYSIS);
192-
cy.getFormLabelByInputId('filter_typ')
199+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
193200
.should('be.visible')
194201
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
195-
cy.getFormSelectFieldById('filter_typ')
202+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
196203
.should('be.visible')
197204
.and('be.enabled');
198205
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
199206
ACTION_TYPE_TEMPLATE_ANALYSIS
200207
);
201-
cy.getFormLabelByInputId('filter_typ')
208+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
202209
.should('be.visible')
203210
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
204-
cy.getFormSelectFieldById('filter_typ')
211+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
205212
.should('be.visible')
206213
.and('be.enabled');
207214
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
@@ -210,61 +217,61 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
210217
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
211218
.should('be.visible')
212219
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
213-
cy.getFormSelectFieldById('filter_typ')
220+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
214221
.should('be.visible')
215222
.and('be.enabled');
216223
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
217224
ACTION_TYPE_CONTAINER_ANALYSIS
218225
);
219-
cy.getFormLabelByInputId('filter_typ')
226+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
220227
.should('be.visible')
221228
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
222-
cy.getFormSelectFieldById('filter_typ')
229+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
223230
.should('be.visible')
224231
.and('be.enabled');
225232
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
226233
ACTION_TYPE_CLUSTER_ANALYSIS
227234
);
228-
cy.getFormLabelByInputId('filter_typ')
235+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
229236
.should('be.visible')
230237
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
231-
cy.getFormSelectFieldById('filter_typ')
238+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
232239
.should('be.visible')
233240
.and('be.enabled');
234241
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
235242
ACTION_TYPE_DATA_STORE_ANALYSIS
236243
);
237-
cy.getFormLabelByInputId('filter_typ')
244+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
238245
.should('be.visible')
239246
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
240-
cy.getFormSelectFieldById('filter_typ')
247+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
241248
.should('be.visible')
242249
.and('be.enabled');
243250
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
244251
ACTION_TYPE_VM_COMPILANCE_CHECK
245252
);
246-
cy.getFormLabelByInputId('filter_typ')
253+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
247254
.should('be.visible')
248255
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
249-
cy.getFormSelectFieldById('filter_typ')
256+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
250257
.should('be.visible')
251258
.and('be.enabled');
252259
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
253260
ACTION_TYPE_HOST_COMPILANCE_CHECK
254261
);
255-
cy.getFormLabelByInputId('filter_typ')
262+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
256263
.should('be.visible')
257264
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
258-
cy.getFormSelectFieldById('filter_typ')
265+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
259266
.should('be.visible')
260267
.and('be.enabled');
261268
cy.getFormSelectFieldById({ selectId: 'action_typ' }).select(
262269
ACTION_TYPE_CONTAINER_COMPILANCE_CHECK
263270
);
264-
cy.getFormLabelByInputId('filter_typ')
271+
cy.getFormLabelByForAttribute({ forValue: 'filter_typ' })
265272
.should('be.visible')
266273
.and('contain.text', FILTER_TYPE_FIELD_LABEL);
267-
cy.getFormSelectFieldById('filter_typ')
274+
cy.getFormSelectFieldById({ selectId: 'filter_typ' })
268275
.should('be.visible')
269276
.and('be.enabled');
270277

@@ -275,7 +282,9 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
275282
cy.getFormLabelByForAttribute({ forValue: 'zone_id' })
276283
.should('be.visible')
277284
.and('contain.text', ZONE_FIELD_LABEL);
278-
cy.getFormSelectFieldById('zone_id').should('be.visible').and('be.enabled');
285+
cy.getFormSelectFieldById({ selectId: 'zone_id' })
286+
.should('be.visible')
287+
.and('be.enabled');
279288

280289
// Verifying Object Details fields
281290
cy.contains('h3[name="object_details"]', OBJECT_DETAILS_SUB_HEADER).should(
@@ -284,7 +293,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
284293
cy.getFormLabelByForAttribute({ forValue: 'instance_name' })
285294
.should('be.visible')
286295
.and('contain.text', SYSTEM_FIELD_LABEL);
287-
cy.getFormSelectFieldById('instance_name')
296+
cy.getFormSelectFieldById({ selectId: 'instance_name' })
288297
.should('be.visible')
289298
.and('be.enabled');
290299
cy.getFormLabelByForAttribute({ forValue: 'message' })
@@ -296,7 +305,9 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
296305
cy.getFormLabelByForAttribute({ forValue: 'request' })
297306
.should('be.visible')
298307
.and('contain.text', REQUEST_FIELD_LABEL);
299-
cy.getFormInputFieldById('request').should('be.visible').and('be.enabled');
308+
cy.getFormInputFieldByIdAndType({ inputId: 'request' })
309+
.should('be.visible')
310+
.and('be.enabled');
300311

301312
// Verifying Object fields
302313
cy.contains('h3[name="object_attributes"]', OBJECT_LABEL_TEXT).should(
@@ -305,15 +316,15 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
305316
cy.getFormLabelByForAttribute({ forValue: 'target_class' })
306317
.should('be.visible')
307318
.and('contain.text', OBJECT_TYPE_FIELD_LABEL);
308-
cy.getFormInputFieldById('target_class')
319+
cy.getFormInputFieldByIdAndType({ inputId: 'target_class' })
309320
.should('be.visible')
310321
.and('be.enabled')
311322
.click();
312323
cy.contains('[role="option"]', OBJECT_TYPE_CLOUD_NETWORK).click();
313324
cy.getFormLabelByForAttribute({ forValue: 'target_id' })
314325
.should('be.visible')
315326
.and('contain.text', OBJECT_LABEL_TEXT);
316-
cy.getFormInputFieldById('target_id')
327+
cy.getFormInputFieldByIdAndType({ inputId: 'target_id' })
317328
.should('be.visible')
318329
.and('be.enabled');
319330

@@ -322,29 +333,39 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
322333
cy.getFormInputFieldByIdAndType({ inputId: 'attribute_1' })
323334
.should('be.visible')
324335
.and('be.enabled');
325-
cy.getFormInputFieldById('value_1').should('be.visible').and('be.enabled');
326-
cy.getFormInputFieldById('attribute_2')
336+
cy.getFormInputFieldByIdAndType({ inputId: 'value_1' })
327337
.should('be.visible')
328338
.and('be.enabled');
329-
cy.getFormInputFieldById('value_2').should('be.visible').and('be.enabled');
330-
cy.getFormInputFieldById('attribute_3')
339+
cy.getFormInputFieldByIdAndType({ inputId: 'attribute_2' })
331340
.should('be.visible')
332341
.and('be.enabled');
333-
cy.getFormInputFieldById('value_3').should('be.visible').and('be.enabled');
334-
cy.getFormInputFieldById('attribute_4')
342+
cy.getFormInputFieldByIdAndType({ inputId: 'value_2' })
335343
.should('be.visible')
336344
.and('be.enabled');
337-
cy.getFormInputFieldById('value_4').should('be.visible').and('be.enabled');
338-
cy.getFormInputFieldById('attribute_5')
345+
cy.getFormInputFieldByIdAndType({ inputId: 'attribute_3' })
346+
.should('be.visible')
347+
.and('be.enabled');
348+
cy.getFormInputFieldByIdAndType({ inputId: 'value_3' })
349+
.should('be.visible')
350+
.and('be.enabled');
351+
cy.getFormInputFieldByIdAndType({ inputId: 'attribute_4' })
352+
.should('be.visible')
353+
.and('be.enabled');
354+
cy.getFormInputFieldByIdAndType({ inputId: 'value_4' })
355+
.should('be.visible')
356+
.and('be.enabled');
357+
cy.getFormInputFieldByIdAndType({ inputId: 'attribute_5' })
358+
.should('be.visible')
359+
.and('be.enabled');
360+
cy.getFormInputFieldByIdAndType({ inputId: 'value_5' })
339361
.should('be.visible')
340362
.and('be.enabled');
341-
cy.getFormInputFieldById('value_5').should('be.visible').and('be.enabled');
342363

343364
/* ===== Selecting "Once" option from "Run" dropdown should not show "Every" dropdown ===== */
344365
cy.getFormLabelByForAttribute({ forValue: 'timer_typ' })
345366
.should('be.visible')
346367
.and('contain.text', TIMER_TYPE_FIELD_LABEL);
347-
cy.getFormSelectFieldById('timer_typ')
368+
cy.getFormSelectFieldById({ selectId: 'timer_typ' })
348369
.should('be.visible')
349370
.and('be.enabled')
350371
.select(TIMER_TYPE_ONCE);
@@ -359,7 +380,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
359380
cy.getFormLabelByForAttribute({ forValue: 'timer_value' })
360381
.should('be.visible')
361382
.and('contain.text', TIMER_VALUE_FIELD_LABEL);
362-
cy.getFormSelectFieldById('timer_value')
383+
cy.getFormSelectFieldById({ selectId: 'timer_value' })
363384
.should('be.visible')
364385
.and('be.enabled');
365386
cy.getFormSelectFieldById({ selectId: 'timer_typ' }).select(
@@ -368,7 +389,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
368389
cy.getFormLabelByForAttribute({ forValue: 'timer_value' })
369390
.should('be.visible')
370391
.and('contain.text', TIMER_VALUE_FIELD_LABEL);
371-
cy.getFormSelectFieldById('timer_value')
392+
cy.getFormSelectFieldById({ selectId: 'timer_value' })
372393
.should('be.visible')
373394
.and('be.enabled');
374395
cy.getFormSelectFieldById({ selectId: 'timer_typ' }).select(
@@ -377,7 +398,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
377398
cy.getFormLabelByForAttribute({ forValue: 'timer_value' })
378399
.should('be.visible')
379400
.and('contain.text', TIMER_VALUE_FIELD_LABEL);
380-
cy.getFormSelectFieldById('timer_value')
401+
cy.getFormSelectFieldById({ selectId: 'timer_value' })
381402
.should('be.visible')
382403
.and('be.enabled');
383404
cy.getFormSelectFieldById({ selectId: 'timer_typ' }).select(
@@ -386,26 +407,26 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
386407
cy.getFormLabelByForAttribute({ forValue: 'timer_value' })
387408
.should('be.visible')
388409
.and('contain.text', TIMER_VALUE_FIELD_LABEL);
389-
cy.getFormSelectFieldById('timer_value')
410+
cy.getFormSelectFieldById({ selectId: 'timer_value' })
390411
.should('be.visible')
391412
.and('be.enabled');
392413

393414
cy.getFormLabelByForAttribute({ forValue: 'time_zone' })
394415
.should('be.visible')
395416
.and('contain.text', TIME_ZONE_FIELD_LABEL);
396-
cy.getFormInputFieldById('time_zone')
417+
cy.getFormInputFieldByIdAndType({ inputId: 'time_zone' })
397418
.should('be.visible')
398419
.and('be.enabled');
399420
cy.getFormLabelByForAttribute({ forValue: 'start_date' })
400421
.should('be.visible')
401422
.and('contain.text', START_DATE_FIELD_LABEL);
402-
cy.getFormInputFieldById('start_date')
423+
cy.getFormInputFieldByIdAndType({ inputId: 'start_date' })
403424
.should('be.visible')
404425
.and('be.enabled');
405426
cy.getFormLabelByForAttribute({ forValue: 'start_time' })
406427
.should('be.visible')
407428
.and('contain.text', START_TIME_FIELD_LABEL);
408-
cy.getFormInputFieldById('start_time')
429+
cy.getFormInputFieldByIdAndType({ inputId: 'start_time' })
409430
.should('be.visible')
410431
.and('be.enabled');
411432
cy.getFormFooterButtonByTypeWithText({
@@ -480,7 +501,9 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
480501
);
481502

482503
/* ===== Checking whether Cancel button works ===== */
483-
cy.getFormFooterButtonByType(CANCEL_BUTTON_TEXT).click();
504+
cy.getFormFooterButtonByTypeWithText({
505+
buttonText: CANCEL_BUTTON_TEXT,
506+
}).click();
484507
cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_OPERATION_CANCELED);
485508
});
486509

0 commit comments

Comments
 (0)