@@ -20,14 +20,8 @@ const textConstants = {
20
20
initialChildTenantName : 'Child-Tenant' ,
21
21
initialChildTenantDescription : 'Child Tenant description' ,
22
22
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
-
28
23
// Button types
29
24
submitButtonType : 'submit' ,
30
- normalButtonType : 'button' ,
31
25
resetButtonType : 'reset' ,
32
26
33
27
// Element ids
@@ -104,10 +98,7 @@ const {
104
98
allocatedStorageQuota,
105
99
allocatedVmQuota,
106
100
nameAlreadyTakenError,
107
- buttonSelector,
108
- inputFieldSelector,
109
101
submitButtonType,
110
- normalButtonType,
111
102
resetButtonType,
112
103
nameInputFieldId,
113
104
descriptionInputFieldId,
@@ -135,10 +126,10 @@ function addOrEditOperation(
135
126
isEditOperation = false
136
127
) {
137
128
// Check if button is disabled initially
138
- cy . contains ( buttonSelector ( submitButtonType ) , button ) . should ( 'be.disabled' ) ;
129
+ cy . getFormFooterButtonByType ( button , submitButtonType ) . should ( 'be.disabled' ) ;
139
130
// 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 ) ;
142
133
if ( isEditOperation ) {
143
134
nameField . clear ( ) . type ( name ) ;
144
135
descriptionField . clear ( ) . type ( description ) ;
@@ -147,7 +138,7 @@ function addOrEditOperation(
147
138
descriptionField . type ( description ) ;
148
139
}
149
140
// Save the form
150
- cy . contains ( buttonSelector ( submitButtonType ) , button )
141
+ cy . getFormFooterButtonByType ( button , submitButtonType )
151
142
. should ( 'be.enabled' )
152
143
. click ( ) ;
153
144
cy . expect_flash ( flashTypeSuccess , flashMessageSnippet ) ;
@@ -250,13 +241,13 @@ function editQuotasTable(quotaName = allocatedStorageQuota) {
250
241
251
242
function quotasResetOperation ( quotaName = allocatedStorageQuota ) {
252
243
// Check if Reset button is disabled initially
253
- cy . contains ( buttonSelector ( resetButtonType ) , resetButton ) . should (
244
+ cy . getFormFooterButtonByType ( resetButton , resetButtonType ) . should (
254
245
'be.disabled'
255
246
) ;
256
247
// Editing the quota table
257
248
editQuotasTable ( quotaName ) ;
258
249
// 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 )
260
251
. should ( 'be.enabled' )
261
252
. click ( ) ;
262
253
cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
@@ -266,7 +257,7 @@ function updateQuotas(quotaName = allocatedStorageQuota) {
266
257
// Opting for the desired quota in the table
267
258
editQuotasTable ( quotaName ) ;
268
259
// Saving the form
269
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
260
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
270
261
cy . expect_flash ( flashTypeSuccess , flashMessageSaved ) ;
271
262
}
272
263
@@ -284,12 +275,12 @@ function rollbackQuotas() {
284
275
}
285
276
} ) ;
286
277
// Saving the form
287
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
278
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
288
279
}
289
280
290
281
function cancelOperation ( flashMessageSnippet = flashMessageOperationCanceled ) {
291
282
// Cancel the form
292
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
283
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
293
284
cy . expect_flash ( flashTypeWarning , flashMessageSnippet ) ;
294
285
}
295
286
@@ -298,20 +289,18 @@ function resetOperation(
298
289
oldDescription = initialParentTenantDescription
299
290
) {
300
291
// 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' ) ;
304
293
// 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
+ ) ;
307
298
// 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 ( ) ;
311
300
cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
312
301
// 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 (
315
304
'have.value' ,
316
305
oldDescription
317
306
) ;
@@ -442,7 +431,7 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
442
431
// Open the Add child tenant form again
443
432
cy . toolbar ( configToolbarButton , addChildTenantConfigOption ) ;
444
433
// Trying to add a child tenant with the same name
445
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( initialChildTenantName ) ;
434
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( initialChildTenantName ) ;
446
435
cy . get ( '#rbac_details #name-error-msg' ) . contains ( nameAlreadyTakenError ) ;
447
436
// Cancel the add form
448
437
cancelOperation ( ) ;
0 commit comments