@@ -37,13 +37,6 @@ const textConstants = {
37
37
ipInputFieldId : 'settings\\.proxy_server_ip' ,
38
38
maxScanSelectFieldId : 'settings\\.concurrent_vm_scans' ,
39
39
40
- // Common selectors
41
- inputFieldLabelSelector : ( forValue ) =>
42
- `#main-content .bx--form label[for="${ forValue } "]` ,
43
- inputFieldSelector : ( inputId ) => `#main-content .bx--form input#${ inputId } ` ,
44
- selectFieldSelector : ( selectId ) => `#main-content .bx--form select#${ selectId } ` ,
45
- buttonSelector : ( type ) => `#main-content .bx--btn-set button[type="${ type } "]` ,
46
-
47
40
// Buttons
48
41
saveButton : 'Save' ,
49
42
cancelButton : 'Cancel' ,
@@ -110,8 +103,8 @@ function addZone() {
110
103
// Open add form
111
104
cy . toolbar ( configToolbarButton , addZoneConfigOption ) ;
112
105
// Adding name, description, ip and scan limit
113
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( zoneName ) ;
114
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . type (
106
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( zoneName ) ;
107
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . type (
115
108
initialZoneDescription
116
109
) ;
117
110
cy . getFormInputFieldById ( ipInputFieldId ) . type ( initialServerIp ) ;
@@ -133,9 +126,9 @@ function validateFormElements(isEditForm = false) {
133
126
// Assert Info sub header is visible
134
127
cy . get ( '#main-content .bx--form h3' ) . contains ( infoSubHeader ) ;
135
128
// Assert name field label is visible
136
- cy . get ( inputFieldLabelSelector ( nameInputFieldId ) ) . should ( 'be.visible' ) ;
129
+ cy . getFormLabelByInputId ( nameInputFieldId ) . should ( 'be.visible' ) ;
137
130
// Assert name field is visible and enabled
138
- cy . get ( inputFieldSelector ( nameInputFieldId ) )
131
+ cy . getFormInputFieldById ( nameInputFieldId )
139
132
. should ( 'be.visible' )
140
133
. then ( ( nameField ) => {
141
134
if ( isEditForm ) {
@@ -145,32 +138,32 @@ function validateFormElements(isEditForm = false) {
145
138
}
146
139
} ) ;
147
140
// Assert description field label is visible
148
- cy . get ( inputFieldLabelSelector ( descriptionInputFieldId ) ) . should ( 'be.visible' ) ;
141
+ cy . getFormLabelByInputId ( descriptionInputFieldId ) . should ( 'be.visible' ) ;
149
142
// Assert description field is visible and enabled
150
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) )
143
+ cy . getFormInputFieldById ( descriptionInputFieldId )
151
144
. should ( 'be.visible' )
152
145
. and ( 'be.enabled' ) ;
153
146
// Assert IP field label is visible
154
- cy . get ( inputFieldLabelSelector ( ipInputFieldId ) ) . should ( 'be.visible' ) ;
147
+ cy . getFormLabelByInputId ( ipInputFieldId ) . should ( 'be.visible' ) ;
155
148
// Assert IP field is visible and enabled
156
- cy . get ( inputFieldSelector ( ipInputFieldId ) )
149
+ cy . getFormInputFieldById ( ipInputFieldId )
157
150
. should ( 'be.visible' )
158
151
. and ( 'be.enabled' ) ;
159
152
// Assert Settings sub header is visible
160
153
cy . get ( '#main-content .bx--form h3' ) . contains ( settingsSubHeader ) ;
161
154
// Assert max scan field label is visible
162
- cy . get ( inputFieldLabelSelector ( maxScanSelectFieldId ) ) . should ( 'be.visible' ) ;
155
+ cy . getFormLabelByInputId ( maxScanSelectFieldId ) . should ( 'be.visible' ) ;
163
156
// Assert max scan field is visible and enabled
164
- cy . get ( selectFieldSelector ( maxScanSelectFieldId ) )
157
+ cy . getFormSelectFieldById ( maxScanSelectFieldId )
165
158
. should ( 'be.visible' )
166
159
. and ( 'be.enabled' ) ;
167
160
// Assert cancel button is visible and enabled
168
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton )
161
+ cy . getFormFooterButtonByType ( cancelButton )
169
162
. should ( 'be.visible' )
170
163
. and ( 'be.enabled' ) ;
171
164
if ( isEditForm ) {
172
165
// Assert reset button is visible and disabled
173
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton )
166
+ cy . getFormFooterButtonByType ( resetButton )
174
167
. should ( 'be.visible' )
175
168
. and ( 'be.disabled' ) ;
176
169
}
@@ -252,12 +245,10 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
252
245
// Open edit form
253
246
cy . toolbar ( configToolbarButton , editZoneConfigOption ) ;
254
247
// Update IP & scan limit
255
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) )
248
+ cy . getFormInputFieldById ( descriptionInputFieldId )
256
249
. clear ( )
257
250
. type ( updatedServerIp ) ;
258
- cy . get ( selectFieldSelector ( maxScanSelectFieldId ) ) . select (
259
- updatedMaxScanLimit
260
- ) ;
251
+ cy . getFormSelectFieldById ( maxScanSelectFieldId ) . select ( updatedMaxScanLimit ) ;
261
252
// Save the form
262
253
cy . getFormFooterButtonByType ( saveButton , 'submit' )
263
254
. should ( 'be.enabled' )
@@ -285,7 +276,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
285
276
// Validate fields
286
277
validateFormElements ( true ) ;
287
278
// Cancelling the form
288
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
279
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
289
280
} ) ;
290
281
291
282
it ( 'Checking whether cancel & reset buttons work on the edit form' , ( ) => {
@@ -299,19 +290,19 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
299
290
cy . toolbar ( configToolbarButton , editZoneConfigOption ) ;
300
291
/* ===== Reset ===== */
301
292
// Update description & IP
302
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) )
293
+ cy . getFormInputFieldById ( descriptionInputFieldId )
303
294
. clear ( )
304
295
. type ( updatedZoneDescription ) ;
305
- cy . get ( inputFieldSelector ( ipInputFieldId ) ) . clear ( ) . type ( updatedServerIp ) ;
296
+ cy . getFormInputFieldById ( ipInputFieldId ) . clear ( ) . type ( updatedServerIp ) ;
306
297
// Resetting the form
307
298
cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
308
299
cy . expect_flash ( flashClassMap . warning , flashMessageOperationReset ) ;
309
300
// Confirming the edited fields contain the old values after resetting
310
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . should (
301
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . should (
311
302
'have.value' ,
312
303
initialZoneDescription
313
304
) ;
314
- cy . get ( inputFieldSelector ( ipInputFieldId ) ) . should (
305
+ cy . getFormInputFieldById ( ipInputFieldId ) . should (
315
306
'have.value' ,
316
307
initialServerIp
317
308
) ;
0 commit comments