@@ -23,14 +23,8 @@ const textConstants = {
23
23
initialChildTenantName : 'Child-Tenant' ,
24
24
initialChildTenantDescription : 'Child Tenant description' ,
25
25
26
- // Common selectors
27
- inputFieldSelector : ( inputId ) =>
28
- `#main-content .bx--form-item input#${ inputId } ` ,
29
- buttonSelector : ( type ) => `#main-content .bx--btn-set button[type="${ type } "]` ,
30
-
31
26
// Button types
32
27
submitButtonType : 'submit' ,
33
- normalButtonType : 'button' ,
34
28
resetButtonType : 'reset' ,
35
29
36
30
// Element ids
@@ -154,8 +148,8 @@ function addOrEditOperation(
154
148
// Check if button is disabled initially
155
149
cy . getFormFooterButtonByType ( button , 'submit' ) . should ( 'be.disabled' ) ;
156
150
// Add or edit name and description
157
- const nameField = cy . get ( inputFieldSelector ( nameInputFieldId ) ) ;
158
- const descriptionField = cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) ;
151
+ const nameField = cy . getFormInputFieldById ( nameInputFieldId ) ;
152
+ const descriptionField = cy . getFormInputFieldById ( descriptionInputFieldId ) ;
159
153
if ( isEditOperation ) {
160
154
nameField . clear ( ) . type ( name ) ;
161
155
descriptionField . clear ( ) . type ( description ) ;
@@ -293,7 +287,7 @@ function rollbackQuotas() {
293
287
294
288
function cancelOperation ( flashMessageSnippet = flashMessageOperationCanceled ) {
295
289
// Cancel the form
296
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
290
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
297
291
cy . expect_flash ( flashTypeWarning , flashMessageSnippet ) ;
298
292
}
299
293
@@ -302,20 +296,18 @@ function resetOperation(
302
296
oldDescription = initialParentTenantDescription
303
297
) {
304
298
// Check if Reset button is disabled initially
305
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
306
- 'be.disabled'
307
- ) ;
299
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
308
300
// Editing name and description fields
309
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( editedTenantNameValue ) ;
310
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . type ( editedDescriptionValue ) ;
301
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( editedTenantNameValue ) ;
302
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . type (
303
+ editedDescriptionValue
304
+ ) ;
311
305
// Confirm Reset button is enabled once dropdown value is changed and then click on Reset
312
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton )
313
- . should ( 'be.enabled' )
314
- . click ( ) ;
306
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
315
307
cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
316
308
// Confirm name and description has old values
317
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . should ( 'have.value' , oldName ) ;
318
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . should (
309
+ cy . getFormInputFieldById ( nameInputFieldId ) . should ( 'have.value' , oldName ) ;
310
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . should (
319
311
'have.value' ,
320
312
oldDescription
321
313
) ;
@@ -458,7 +450,7 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
458
450
// Open the Add child tenant form again
459
451
cy . toolbar ( configToolbarButton , addChildTenantConfigOption ) ;
460
452
// Trying to add a child tenant with the same name
461
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( initialChildTenantName ) ;
453
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( initialChildTenantName ) ;
462
454
cy . get ( '#rbac_details #name-error-msg' ) . contains ( nameAlreadyTakenError ) ;
463
455
// Cancel the add form
464
456
cancelOperation ( ) ;
0 commit comments