@@ -74,35 +74,37 @@ function addSchedule() {
7474 // Open add schedule form
7575 selectConfigMenu ( ADD_SCHEDULE_CONFIG_OPTION ) ;
7676 // Checks if Save button is disabled initially
77- cy . contains (
78- '#main-content .bx--btn-set button[type="submit"]' ,
79- saveButton
80- ) . should ( 'be.disabled' ) ;
77+ cy . getFormFooterButtonByType ( SAVE_BUTTON_TEXT , 'submit' ) . should (
78+ 'be.disabled'
79+ ) ;
8180 // Adding data
82- cy . get ( 'input#name' ) . type ( initialScheduleName ) ;
83- cy . get ( 'input#description' ) . type ( initialDescription ) ;
84- cy . get ( 'input[type="checkbox"]#enabled' ) . check ( { force : true } ) ;
81+ cy . getFormInputFieldById ( 'name' ) . type ( INITIAL_SCHEDULE_NAME ) ;
82+ cy . getFormInputFieldById ( 'description' ) . type ( INITIAL_DESCRIPTION ) ;
83+ cy . getFormInputFieldById ( 'enabled' , 'checkbox' ) . check ( {
84+ force : true ,
85+ } ) ;
8586 // Select Action type option: 'VM Analysis'
86- cy . get ( 'select# action_typ') . select ( actionTypeVmAnalysis ) ;
87+ cy . getFormSelectFieldById ( ' action_typ') . select ( ACTION_TYPE_VM_ANALYSIS ) ;
8788 // Select Filter type option: 'A Single VM'
88- cy . get ( 'select# filter_typ') . select ( actionTypeVmAnalysis ) ;
89+ cy . getFormSelectFieldById ( ' filter_typ') . select ( ACTION_TYPE_VM_ANALYSIS ) ;
8990 // Select Run option: 'Hours'
90- cy . get ( 'select# timer_typ') . select ( timerTypeHourly ) ;
91+ cy . getFormSelectFieldById ( ' timer_typ') . select ( TIMER_TYPE_HOURLY ) ;
9192 // Select Every option: '1 Hour'
92- cy . get ( 'select# timer_value') . select ( frequencyTypeHour ) ;
93+ cy . getFormSelectFieldById ( ' timer_value') . select ( FREQUENCY_TYPE_HOUR ) ;
9394 // Select Time zone option: '(GMT-10:00) Hawaii'
94- cy . get ( 'input[role="combobox"]# time_zone') . click ( ) ;
95- cy . contains ( '[role="option"]' , timezoneTypeHawaii )
95+ cy . getFormInputFieldById ( ' time_zone') . click ( ) ;
96+ cy . contains ( '[role="option"]' , TIMEZONE_TYPE_HAWAII )
9697 . should ( 'be.visible' )
9798 . click ( ) ;
98- cy . get ( 'input# start_date') . type ( initialStartDate ) ;
99- cy . get ( 'input# start_time') . type ( startTime ) ;
99+ cy . getFormInputFieldById ( ' start_date') . type ( INITIAL_START_DATE ) ;
100+ cy . getFormInputFieldById ( ' start_time') . type ( START_TIME ) ;
100101 // Intercepting the API call for adding a new schedule
101102 cy . interceptApi ( {
102103 alias : 'addScheduleApi' ,
103104 urlPattern : '/ops/schedule_edit/new?button=save' ,
104105 triggerFn : ( ) =>
105- cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , saveButton )
106+ cy
107+ . getFormFooterButtonByType ( SAVE_BUTTON_TEXT , 'submit' )
106108 . should ( 'be.enabled' ) // Checks if Save button is enabled once all required fields are filled
107109 . click ( ) ,
108110 } ) ;
@@ -174,11 +176,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
174176 cy . interceptApi ( {
175177 alias : 'treeSelectApi' ,
176178 urlPattern : / \/ o p s \/ t r e e _ s e l e c t \? i d = .* & t e x t = .* / ,
177- triggerFn : ( ) =>
178- cy . selectAccordionItem ( [
179- MANAGEIQ_REGION_ACCORDION_ITEM ,
180- SCHEDULES_ACCORDION_ITEM ,
181- ] ) ,
179+ triggerFn : ( ) => cy . accordionItem ( SCHEDULES_ACCORDION_ITEM ) ,
182180 } ) ;
183181 } ) ;
184182
@@ -188,146 +186,139 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
188186
189187 /* ===== Selecting any option other than "Automation Tasks" from "Action" dropdown does not hide the Filter dropdown ===== */
190188
191- cy . get ( 'select#action_typ' ) . select ( actionTypeVmAnalysis ) ;
192- cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeVmAnalysis ) ;
193- // Checking for Filter type dropdown
194- verifyFilterTypeDropdownExists ( ) ;
195-
196- cy . get ( 'select#action_typ' ) . select ( actionTypeTemplateAnalysis ) ;
197- cy . get ( 'select#action_typ' ) . should (
198- 'have.value' ,
199- actionTypeTemplateAnalysis
189+ // Selecting "Vm Analysis" to verify filter type dropdown
190+ cy . getFormSelectFieldById ( 'action_typ' ) . select ( ACTION_TYPE_VM_ANALYSIS ) ;
191+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
192+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
193+ // Selecting "Template Analysis" to verify filter type dropdown
194+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
195+ ACTION_TYPE_TEMPLATE_ANALYSIS
200196 ) ;
201- // Checking for Filter type dropdown
202- verifyFilterTypeDropdownExists ( ) ;
203-
204- cy . get ( 'select#action_typ' ) . select ( actionTypeHostAnalysis ) ;
205- cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeHostAnalysis ) ;
206- // Checking for Filter type dropdown
207- verifyFilterTypeDropdownExists ( ) ;
208-
209- cy . get ( 'select#action_typ' ) . select ( actionTypeContainerAnalysis ) ;
210- cy . get ( 'select#action_typ' ) . should (
211- 'have.value' ,
212- actionTypeContainerAnalysis
197+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
198+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
199+ // Selecting "Host Analysis" to verify filter type dropdown
200+ cy . getFormSelectFieldById ( 'action_typ' ) . select ( ACTION_TYPE_HOST_ANALYSIS ) ;
201+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
202+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
203+ // Selecting "Container Analysis" to verify filter type dropdown
204+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
205+ ACTION_TYPE_CONTAINER_ANALYSIS
213206 ) ;
214- // Checking for Filter type dropdown
215- verifyFilterTypeDropdownExists ( ) ;
216-
217- cy . get ( 'select#action_typ' ) . select ( actionTypeClusterAnalysis ) ;
218- cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeClusterAnalysis ) ;
219- // Checking for Filter type dropdown
220- verifyFilterTypeDropdownExists ( ) ;
221-
222- cy . get ( 'select#action_typ' ) . select ( actionTypeDataStoreAnalysis ) ;
223- cy . get ( 'select#action_typ' ) . should (
224- 'have.value' ,
225- actionTypeDataStoreAnalysis
207+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
208+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
209+ // Selecting "Cluster Analysis" to verify filter type dropdown
210+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
211+ ACTION_TYPE_CLUSTER_ANALYSIS
226212 ) ;
227- // Checking for Filter type dropdown
228- verifyFilterTypeDropdownExists ( ) ;
229-
230- cy . get ( 'select#action_typ' ) . select ( actionTypeVmCompilanceCheck ) ;
231- cy . get ( 'select#action_typ' ) . should (
232- 'have.value' ,
233- actionTypeVmCompilanceCheck
213+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
214+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
215+ // Selecting "DataStore Analysis" to verify filter type dropdown
216+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
217+ ACTION_TYPE_DATA_STORE_ANALYSIS
234218 ) ;
235- // Checking for Filter type dropdown
236- verifyFilterTypeDropdownExists ( ) ;
237-
238- cy . get ( 'select#action_typ' ) . select ( actionTypeHostCompilanceCheck ) ;
239- cy . get ( 'select#action_typ' ) . should (
240- 'have.value' ,
241- actionTypeHostCompilanceCheck
219+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
220+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
221+ // Selecting "Vm Compilance Check" to verify filter type dropdown
222+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
223+ ACTION_TYPE_VM_COMPILANCE_CHECK
242224 ) ;
243- // Checking for Filter type dropdown
244- verifyFilterTypeDropdownExists ( ) ;
245-
246- cy . get ( 'select#action_typ' ) . select ( actionTypeContainerCompilanceCheck ) ;
247- cy . get ( 'select#action_typ' ) . should (
248- 'have.value' ,
249- actionTypeContainerCompilanceCheck
225+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
226+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
227+ // Selecting "Host Compilance Check" to verify filter type dropdown
228+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
229+ ACTION_TYPE_HOST_COMPILANCE_CHECK
250230 ) ;
251- // Checking for Filter type dropdown
252- verifyFilterTypeDropdownExists ( ) ;
231+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
232+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
233+ // Selecting "Container Compilance Check" to verify filter type dropdown
234+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
235+ ACTION_TYPE_CONTAINER_COMPILANCE_CHECK
236+ ) ;
237+ cy . getFormLabelByInputId ( 'filter_typ' ) . should ( 'exist' ) ;
238+ cy . getFormSelectFieldById ( 'filter_typ' ) . should ( 'exist' ) ;
253239
254240 /* ===== Selecting "Automation Tasks" option from "Action" dropdown shows Zone, Object details & Object fields ===== */
255241
256- cy . get ( 'select#action_typ' ) . select ( actionTypeAutomationTasks ) ;
257- cy . get ( 'select#action_typ' ) . should ( 'have.value' , actionTypeAutomationTasks ) ;
242+ cy . getFormSelectFieldById ( 'action_typ' ) . select (
243+ ACTION_TYPE_AUTOMATION_TASKS
244+ ) ;
245+ cy . getFormSelectFieldById ( 'action_typ' ) . should (
246+ 'have.value' ,
247+ ACTION_TYPE_AUTOMATION_TASKS
248+ ) ;
258249
259250 // Checking for Zone dropdown
260- cy . get ( 'label[for=" zone_id"] ') . should ( 'exist' ) ;
261- cy . get ( 'select# zone_id') . should ( 'exist' ) ;
251+ cy . getFormLabelByInputId ( ' zone_id') . should ( 'exist' ) ;
252+ cy . getFormSelectFieldById ( ' zone_id') . should ( 'exist' ) ;
262253
263254 // Checking for Object Details
264255 cy . get ( 'h3[name="object_details"]' ) . should ( 'exist' ) ;
265256 // Checking for System/Process dropdown
266- cy . get ( 'label[for=" instance_name"] ') . should ( 'exist' ) ;
267- cy . get ( 'select# instance_name') . should ( 'exist' ) ;
257+ cy . getFormLabelByInputId ( ' instance_name') . should ( 'exist' ) ;
258+ cy . getFormSelectFieldById ( ' instance_name') . should ( 'exist' ) ;
268259 // Checking for Messsage textfield
269- cy . get ( 'label[for=" message"] ') . should ( 'exist' ) ;
270- cy . get ( 'input# message') . should ( 'exist' ) ;
260+ cy . getFormLabelByInputId ( ' message') . should ( 'exist' ) ;
261+ cy . getFormInputFieldById ( ' message') . should ( 'exist' ) ;
271262 // Checking for Request textfield
272- cy . get ( 'label[for=" request"] ') . should ( 'exist' ) ;
273- cy . get ( 'input# request') . should ( 'exist' ) ;
263+ cy . getFormLabelByInputId ( ' request') . should ( 'exist' ) ;
264+ cy . getFormInputFieldById ( ' request') . should ( 'exist' ) ;
274265
275266 // Checking for Object
276267 cy . get ( 'h3[name="object_attributes"]' ) . should ( 'exist' ) ;
277268 // Checking for Type Combobox
278- cy . get ( 'label[for=" target_class"] ') . should ( 'exist' ) ;
279- cy . get ( 'input[role="combobox"]# target_class') . should ( 'exist' ) ;
269+ cy . getFormLabelByInputId ( ' target_class') . should ( 'exist' ) ;
270+ cy . getFormInputFieldById ( ' target_class') . should ( 'exist' ) ;
280271 // Checking for Object Combobox
281- cy . get ( 'label[for=" target_id"] ') . should ( 'exist' ) ;
282- cy . get ( 'input[role="combobox"]# target_id') . should ( 'exist' ) ;
272+ cy . getFormLabelByInputId ( ' target_id') . should ( 'exist' ) ;
273+ cy . getFormInputFieldById ( ' target_id') . should ( 'exist' ) ;
283274
284275 // Checking for Attribute/Value pairs
285276 cy . contains ( 'h3' , 'Attribute/Value Pairs' ) . should ( 'exist' ) ;
286277 // Checking for 5 attribute-value pairs text fields
287- cy . get ( 'input# attribute_1') . should ( 'exist' ) ;
288- cy . get ( 'input# value_1') . should ( 'exist' ) ;
289- cy . get ( 'input# attribute_2') . should ( 'exist' ) ;
290- cy . get ( 'input# value_2') . should ( 'exist' ) ;
291- cy . get ( 'input# attribute_3') . should ( 'exist' ) ;
292- cy . get ( 'input# value_3') . should ( 'exist' ) ;
293- cy . get ( 'input# attribute_4') . should ( 'exist' ) ;
294- cy . get ( 'input# value_4') . should ( 'exist' ) ;
295- cy . get ( 'input# attribute_5') . should ( 'exist' ) ;
296- cy . get ( 'input# value_5') . should ( 'exist' ) ;
278+ cy . getFormInputFieldById ( ' attribute_1') . should ( 'exist' ) ;
279+ cy . getFormInputFieldById ( ' value_1') . should ( 'exist' ) ;
280+ cy . getFormInputFieldById ( ' attribute_2') . should ( 'exist' ) ;
281+ cy . getFormInputFieldById ( ' value_2') . should ( 'exist' ) ;
282+ cy . getFormInputFieldById ( ' attribute_3') . should ( 'exist' ) ;
283+ cy . getFormInputFieldById ( ' value_3') . should ( 'exist' ) ;
284+ cy . getFormInputFieldById ( ' attribute_4') . should ( 'exist' ) ;
285+ cy . getFormInputFieldById ( ' value_4') . should ( 'exist' ) ;
286+ cy . getFormInputFieldById ( ' attribute_5') . should ( 'exist' ) ;
287+ cy . getFormInputFieldById ( ' value_5') . should ( 'exist' ) ;
297288
298289 /* ===== Selecting "Once" option from "Run" dropdown does not show the "Every" dropdown ===== */
299-
300- cy . get ( 'select#timer_typ' ) . select ( timerTypeOnce ) ;
290+ cy . getFormSelectFieldById ( 'timer_typ' ) . select ( TIMER_TYPE_ONCE ) ;
291+ cy . getFormSelectFieldById ( 'timer_typ' ) . should (
292+ 'have.value' ,
293+ TIMER_TYPE_ONCE
294+ ) ;
301295 // Checking whether the Every dropdown is hidden
302- cy . get ( 'input# timer_value') . should ( 'not.exist' ) ;
296+ cy . getFormInputFieldById ( ' timer_value') . should ( 'not.exist' ) ;
303297
304298 /* ===== Selecting any other option other than "Once" from "Run" dropdown shows the "Every" dropdown ===== */
305-
306- cy . get ( 'select# timer_typ') . select ( timerTypeHourly ) ;
307- // Checking whether the "Every" dropdown exist
308- verifyTimerDropdownExists ( ) ;
309-
310- cy . get ( 'select# timer_typ') . select ( timerTypeDaily ) ;
311- // Checking whether the "Every" dropdown exist
312- verifyTimerDropdownExists ( ) ;
313-
314- cy . get ( 'select# timer_typ') . select ( timerTypeWeekly ) ;
315- // Checking whether the "Every" dropdown exist
316- verifyTimerDropdownExists ( ) ;
317-
318- cy . get ( 'select# timer_typ') . select ( timerTypeMonthly ) ;
319- // Checking whether the "Every" dropdown exist
320- verifyTimerDropdownExists ( ) ;
299+ // Selecting "Hourly" to verify timer dropdown
300+ cy . getFormSelectFieldById ( ' timer_typ') . select ( TIMER_TYPE_HOURLY ) ;
301+ cy . getFormLabelByInputId ( 'timer_value' ) . should ( ' exist' ) ;
302+ cy . getFormSelectFieldById ( 'timer_value' ) . should ( 'exist' ) ;
303+ // Selecting "Daily" to verify timer dropdown
304+ cy . getFormSelectFieldById ( ' timer_typ') . select ( TIMER_TYPE_DAILY ) ;
305+ cy . getFormLabelByInputId ( 'timer_value' ) . should ( ' exist' ) ;
306+ cy . getFormSelectFieldById ( 'timer_value' ) . should ( 'exist' ) ;
307+ // Selecting "Weekly" to verify timer dropdown
308+ cy . getFormSelectFieldById ( ' timer_typ') . select ( TIMER_TYPE_WEEKLY ) ;
309+ cy . getFormLabelByInputId ( 'timer_value' ) . should ( ' exist' ) ;
310+ cy . getFormSelectFieldById ( 'timer_value' ) . should ( 'exist' ) ;
311+ // Selecting "Monthly" to verify timer dropdown
312+ cy . getFormSelectFieldById ( ' timer_typ') . select ( TIMER_TYPE_MONTHLY ) ;
313+ cy . getFormLabelByInputId ( 'timer_value' ) . should ( ' exist' ) ;
314+ cy . getFormSelectFieldById ( 'timer_value' ) . should ( 'exist' ) ;
321315 } ) ;
322316
323317 it ( 'Checking whether Cancel button works on the Add form' , ( ) => {
324318 // Open add schedule form
325319 selectConfigMenu ( ADD_SCHEDULE_CONFIG_OPTION ) ;
326320 // Cancel the form
327- cy . contains (
328- '#main-content .bx--btn-set button[type="button"]' ,
329- cancelButton
330- )
321+ cy . getFormFooterButtonByType ( CANCEL_BUTTON_TEXT )
331322 . should ( 'be.enabled' )
332323 . click ( ) ;
333324 cy . expect_flash ( flashClassMap . success , FLASH_MESSAGE_OPERATION_CANCELED ) ;
@@ -344,10 +335,10 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
344335 // Open edit schedule form
345336 selectConfigMenu ( EDIT_SCHEDULE_CONFIG_OPTION ) ;
346337 // Editing name and description
347- cy . get ( 'input# name') . clear ( ) . type ( editedScheduleName ) ;
348- cy . get ( 'input# description') . clear ( ) . type ( editedDescription ) ;
338+ cy . getFormInputFieldById ( ' name') . clear ( ) . type ( EDITED_SCHEDULE_NAME ) ;
339+ cy . getFormInputFieldById ( ' description') . clear ( ) . type ( EDITED_DESCRIPTION ) ;
349340 // Confirms Save button is enabled after making edits
350- cy . contains ( '#main-content .bx--btn-set button[type=" submit"]' , saveButton )
341+ cy . getFormFooterButtonByType ( SAVE_BUTTON_TEXT , ' submit' )
351342 . should ( 'be.enabled' )
352343 . click ( ) ;
353344 cy . expect_flash ( flashClassMap . success , FLASH_MESSAGE_SCHEDULE_SAVED ) ;
@@ -365,18 +356,25 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
365356 // Open edit schedule form
366357 selectConfigMenu ( EDIT_SCHEDULE_CONFIG_OPTION ) ;
367358 // Editing description and start date
368- cy . get ( 'input#description' ) . clear ( ) . type ( editedDescription ) ;
369- cy . get ( 'input#start_date' ) . clear ( ) . type ( editedStartDate ) ;
370- cy . contains ( '#main-content .bx--btn-set button[type="button"]' , resetButton )
359+ cy . getFormInputFieldById ( 'description' ) . clear ( ) . type ( EDITED_DESCRIPTION ) ;
360+ cy . getFormInputFieldById ( 'start_date' ) . clear ( ) . type ( EDITED_START_DATE ) ;
361+ // Resetting
362+ cy . getFormFooterButtonByType ( RESET_BUTTON_TEXT )
371363 . should ( 'be.enabled' )
372364 . click ( ) ;
373365 cy . expect_flash ( flashClassMap . warning , FLASH_MESSAGE_RESET_SCHEDULE ) ;
374366 // Confirming the edited fields contain the old values after resetting
375- cy . get ( 'input#description' ) . should ( 'have.value' , initialDescription ) ;
376- cy . get ( 'input#start_date' ) . should ( 'have.value' , initialStartDate ) ;
367+ cy . getFormInputFieldById ( 'description' ) . should (
368+ 'have.value' ,
369+ INITIAL_DESCRIPTION
370+ ) ;
371+ cy . getFormInputFieldById ( 'start_date' ) . should (
372+ 'have.value' ,
373+ INITIAL_START_DATE
374+ ) ;
377375
378376 /* ===== Checking whether Cancel button works ===== */
379- cy . contains ( '#main-content .bx--btn-set button[type="button"]' , CANCEL_BUTTON_TEXT )
377+ cy . getFormFooterButtonByType ( CANCEL_BUTTON_TEXT )
380378 . should ( 'be.enabled' )
381379 . click ( ) ;
382380 cy . expect_flash ( flashClassMap . success , FLASH_MESSAGE_OPERATION_CANCELED ) ;
0 commit comments