@@ -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
@@ -108,10 +102,7 @@ const {
108
102
allocatedStorageQuota,
109
103
allocatedVmQuota,
110
104
nameAlreadyTakenError,
111
- buttonSelector,
112
- inputFieldSelector,
113
105
submitButtonType,
114
- normalButtonType,
115
106
resetButtonType,
116
107
nameInputFieldId,
117
108
descriptionInputFieldId,
@@ -139,10 +130,10 @@ function addOrEditOperation(
139
130
isEditOperation = false
140
131
) {
141
132
// Check if button is disabled initially
142
- cy . contains ( buttonSelector ( submitButtonType ) , button ) . should ( 'be.disabled' ) ;
133
+ cy . getFormFooterButtonByType ( button , submitButtonType ) . should ( 'be.disabled' ) ;
143
134
// Add or edit name and description
144
- const nameField = cy . get ( inputFieldSelector ( nameInputFieldId ) ) ;
145
- const descriptionField = cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) ;
135
+ const nameField = cy . getFormInputFieldById ( nameInputFieldId ) ;
136
+ const descriptionField = cy . getFormInputFieldById ( descriptionInputFieldId ) ;
146
137
if ( isEditOperation ) {
147
138
nameField . clear ( ) . type ( name ) ;
148
139
descriptionField . clear ( ) . type ( description ) ;
@@ -151,7 +142,7 @@ function addOrEditOperation(
151
142
descriptionField . type ( description ) ;
152
143
}
153
144
// Save the form
154
- cy . contains ( buttonSelector ( submitButtonType ) , button )
145
+ cy . getFormFooterButtonByType ( button , submitButtonType )
155
146
. should ( 'be.enabled' )
156
147
. click ( ) ;
157
148
cy . expect_flash ( flashTypeSuccess , flashMessageSnippet ) ;
@@ -254,13 +245,13 @@ function editQuotasTable(quotaName = allocatedStorageQuota) {
254
245
255
246
function quotasResetOperation ( quotaName = allocatedStorageQuota ) {
256
247
// Check if Reset button is disabled initially
257
- cy . contains ( buttonSelector ( resetButtonType ) , resetButton ) . should (
248
+ cy . getFormFooterButtonByType ( resetButton , resetButtonType ) . should (
258
249
'be.disabled'
259
250
) ;
260
251
// Editing the quota table
261
252
editQuotasTable ( quotaName ) ;
262
253
// Confirm Reset button is enabled once table values are updated and then click on Reset
263
- cy . contains ( buttonSelector ( resetButtonType ) , resetButton )
254
+ cy . getFormFooterButtonByType ( resetButton , resetButtonType )
264
255
. should ( 'be.enabled' )
265
256
. click ( ) ;
266
257
cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
@@ -270,7 +261,7 @@ function updateQuotas(quotaName = allocatedStorageQuota) {
270
261
// Opting for the desired quota in the table
271
262
editQuotasTable ( quotaName ) ;
272
263
// Saving the form
273
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
264
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
274
265
cy . expect_flash ( flashTypeSuccess , flashMessageSaved ) ;
275
266
}
276
267
@@ -288,12 +279,12 @@ function rollbackQuotas() {
288
279
}
289
280
} ) ;
290
281
// Saving the form
291
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
282
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
292
283
}
293
284
294
285
function cancelOperation ( flashMessageSnippet = flashMessageOperationCanceled ) {
295
286
// Cancel the form
296
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
287
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
297
288
cy . expect_flash ( flashTypeWarning , flashMessageSnippet ) ;
298
289
}
299
290
@@ -302,20 +293,18 @@ function resetOperation(
302
293
oldDescription = initialParentTenantDescription
303
294
) {
304
295
// Check if Reset button is disabled initially
305
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
306
- 'be.disabled'
307
- ) ;
296
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
308
297
// Editing name and description fields
309
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( editedTenantNameValue ) ;
310
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . type ( editedDescriptionValue ) ;
298
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( editedTenantNameValue ) ;
299
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . type (
300
+ editedDescriptionValue
301
+ ) ;
311
302
// 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 ( ) ;
303
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
315
304
cy . expect_flash ( flashTypeWarning , flashMessageOperationReset ) ;
316
305
// Confirm name and description has old values
317
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . should ( 'have.value' , oldName ) ;
318
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . should (
306
+ cy . getFormInputFieldById ( nameInputFieldId ) . should ( 'have.value' , oldName ) ;
307
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . should (
319
308
'have.value' ,
320
309
oldDescription
321
310
) ;
@@ -446,7 +435,7 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc
446
435
// Open the Add child tenant form again
447
436
cy . toolbar ( configToolbarButton , addChildTenantConfigOption ) ;
448
437
// Trying to add a child tenant with the same name
449
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( initialChildTenantName ) ;
438
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( initialChildTenantName ) ;
450
439
cy . get ( '#rbac_details #name-error-msg' ) . contains ( nameAlreadyTakenError ) ;
451
440
// Cancel the add form
452
441
cancelOperation ( ) ;
0 commit comments