@@ -20,14 +20,8 @@ const textConstants = {
2020 initialChildTenantName : 'Child-Tenant' ,
2121 initialChildTenantDescription : 'Child Tenant description' ,
2222
23- // Common selectors
24- inputFieldSelector : ( inputId ) =>
25- `#main-content .bx--form-item input#${ inputId } ` ,
26- buttonSelector : ( type ) => `#main-content .bx--btn-set button[type="${ type } "]` ,
27-
2823 // Button types
2924 submitButtonType : 'submit' ,
30- normalButtonType : 'button' ,
3125 resetButtonType : 'reset' ,
3226
3327 // Element ids
@@ -104,10 +98,7 @@ const {
10498 allocatedStorageQuota,
10599 allocatedVmQuota,
106100 nameAlreadyTakenError,
107- buttonSelector,
108- inputFieldSelector,
109101 submitButtonType,
110- normalButtonType,
111102 resetButtonType,
112103 nameInputFieldId,
113104 descriptionInputFieldId,
@@ -135,10 +126,10 @@ function addOrEditOperation(
135126 isEditOperation = false
136127) {
137128 // Check if button is disabled initially
138- cy . contains ( buttonSelector ( submitButtonType ) , button ) . should ( 'be.disabled' ) ;
129+ cy . getFormFooterButtonByType ( button , submitButtonType ) . should ( 'be.disabled' ) ;
139130 // Add or edit name and description
140- const nameField = cy . get ( inputFieldSelector ( nameInputFieldId ) ) ;
141- const descriptionField = cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) ;
131+ const nameField = cy . getFormInputFieldById ( nameInputFieldId ) ;
132+ const descriptionField = cy . getFormInputFieldById ( descriptionInputFieldId ) ;
142133 if ( isEditOperation ) {
143134 nameField . clear ( ) . type ( name ) ;
144135 descriptionField . clear ( ) . type ( description ) ;
@@ -147,7 +138,7 @@ function addOrEditOperation(
147138 descriptionField . type ( description ) ;
148139 }
149140 // Save the form
150- cy . contains ( buttonSelector ( submitButtonType ) , button )
141+ cy . getFormFooterButtonByType ( button , submitButtonType )
151142 . should ( 'be.enabled' )
152143 . click ( ) ;
153144 cy . expect_flash ( flashTypeSuccess , flashMessageSnippet ) ;
@@ -250,13 +241,13 @@ function editQuotasTable(quotaName = allocatedStorageQuota) {
250241
251242function quotasResetOperation ( quotaName = allocatedStorageQuota ) {
252243 // Check if Reset button is disabled initially
253- cy . contains ( buttonSelector ( resetButtonType ) , resetButton ) . should (
244+ cy . getFormFooterButtonByType ( resetButton , resetButtonType ) . should (
254245 'be.disabled'
255246 ) ;
256247 // Editing the quota table
257248 editQuotasTable ( quotaName ) ;
258249 // Confirm Reset button is enabled once table values are updated and then click on Reset
259- cy . contains ( buttonSelector ( resetButtonType ) , resetButton )
250+ cy . getFormFooterButtonByType ( resetButton , resetButtonType )
260251 . should ( 'be.enabled' )
261252 . click ( ) ;
262253 cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
@@ -266,7 +257,7 @@ function updateQuotas(quotaName = allocatedStorageQuota) {
266257 // Opting for the desired quota in the table
267258 editQuotasTable ( quotaName ) ;
268259 // Saving the form
269- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
260+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
270261 cy . expect_flash ( flashTypeSuccess , flashMessageSaved ) ;
271262}
272263
@@ -284,12 +275,12 @@ function rollbackQuotas() {
284275 }
285276 } ) ;
286277 // Saving the form
287- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
278+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
288279}
289280
290281function cancelOperation ( flashMessageSnippet = flashMessageOperationCanceled ) {
291282 // Cancel the form
292- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
283+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
293284 cy . expect_flash ( flashTypeWarning , flashMessageSnippet ) ;
294285}
295286
@@ -298,20 +289,18 @@ function resetOperation(
298289 oldDescription = initialParentTenantDescription
299290) {
300291 // Check if Reset button is disabled initially
301- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
302- 'be.disabled'
303- ) ;
292+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
304293 // Editing name and description fields
305- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( editedTenantNameValue ) ;
306- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . type ( editedDescriptionValue ) ;
294+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( editedTenantNameValue ) ;
295+ cy . getFormInputFieldById ( descriptionInputFieldId ) . type (
296+ editedDescriptionValue
297+ ) ;
307298 // Confirm Reset button is enabled once dropdown value is changed and then click on Reset
308- cy . contains ( buttonSelector ( normalButtonType ) , resetButton )
309- . should ( 'be.enabled' )
310- . click ( ) ;
299+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
311300 cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
312301 // Confirm name and description has old values
313- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . should ( 'have.value' , oldName ) ;
314- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . should (
302+ cy . getFormInputFieldById ( nameInputFieldId ) . should ( 'have.value' , oldName ) ;
303+ cy . getFormInputFieldById ( descriptionInputFieldId ) . should (
315304 'have.value' ,
316305 oldDescription
317306 ) ;
@@ -442,7 +431,7 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
442431 // Open the Add child tenant form again
443432 cy . toolbar ( configToolbarButton , addChildTenantConfigOption ) ;
444433 // Trying to add a child tenant with the same name
445- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( initialChildTenantName ) ;
434+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( initialChildTenantName ) ;
446435 cy . get ( '#rbac_details #name-error-msg' ) . contains ( nameAlreadyTakenError ) ;
447436 // Cancel the add form
448437 cancelOperation ( ) ;
0 commit comments