@@ -13,21 +13,13 @@ const textConstants = {
13
13
toolbarEditNamespace : 'Edit this Namespace' ,
14
14
toolbarRemoveNamespace : 'Remove this Namespace' ,
15
15
16
- // Common selectors
17
- inputFieldSelector : ( inputId ) =>
18
- `#main-content #datastore-form-wrapper input#${ inputId } ` ,
19
- buttonSelector : ( type ) => `#main-content .bx--btn-set button[type="${ type } "]` ,
20
- inputFieldLabelSelector : ( forValue ) =>
21
- `#main-content #datastore-form-wrapper label[for="${ forValue } "]` ,
22
-
23
16
// Element ids
24
17
nameInputFieldId : 'name' ,
25
18
descriptionInputFieldId : 'description' ,
26
19
namespacePathInputFieldId : 'namespacePath' ,
27
20
28
21
// Button types
29
22
submitButtonType : 'submit' ,
30
- normalButtonType : 'button' ,
31
23
32
24
// Field values
33
25
domainName : 'Test_Domain' ,
@@ -68,9 +60,6 @@ const {
68
60
automationMenuOption,
69
61
embeddedAutomationMenuOption,
70
62
explorerMenuOption,
71
- inputFieldSelector,
72
- buttonSelector,
73
- inputFieldLabelSelector,
74
63
addButton,
75
64
cancelButton,
76
65
resetButton,
@@ -104,16 +93,15 @@ const {
104
93
descriptionInputFieldId,
105
94
namespacePathInputFieldId,
106
95
submitButtonType,
107
- normalButtonType,
108
96
} = textConstants ;
109
97
110
98
function addNamespace ( nameFieldValue = namespaceName ) {
111
99
// Navigating to the Add Namespace form
112
100
cy . toolbar ( toolbarConfiguration , toolbarAddNewNamespace ) ;
113
101
// Creating a new namespace
114
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( nameFieldValue ) ;
115
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . type ( description ) ;
116
- cy . contains ( buttonSelector ( submitButtonType ) , addButton ) . click ( ) ;
102
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( nameFieldValue ) ;
103
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . type ( description ) ;
104
+ cy . getFormFooterButtonByType ( addButton , submitButtonType ) . click ( ) ;
117
105
cy . wait ( '@addNamespaceApi' ) ;
118
106
}
119
107
@@ -141,41 +129,39 @@ function validateNamespaceFormFields(isEditForm = false) {
141
129
namespaceFormSubHeader
142
130
) ;
143
131
// Assert name-space path field label is visible
144
- cy . get ( inputFieldLabelSelector ( namespacePathInputFieldId ) ) . should (
145
- 'be.visible'
146
- ) ;
132
+ cy . getFormLabelByInputId ( namespacePathInputFieldId ) . should ( 'be.visible' ) ;
147
133
// Assert name-space path field is visible and disabled
148
- cy . get ( inputFieldSelector ( namespacePathInputFieldId ) )
134
+ cy . getFormInputFieldById ( namespacePathInputFieldId )
149
135
. should ( 'be.visible' )
150
136
. and ( 'be.disabled' )
151
137
. invoke ( 'val' )
152
138
. should ( 'include' , domainName ) ;
153
139
// Assert name field label is visible
154
- cy . get ( inputFieldLabelSelector ( nameInputFieldId ) ) . should ( 'be.visible' ) ;
140
+ cy . getFormLabelByInputId ( nameInputFieldId ) . should ( 'be.visible' ) ;
155
141
// Assert name field is visible and enabled
156
- cy . get ( inputFieldSelector ( nameInputFieldId ) )
142
+ cy . getFormInputFieldById ( nameInputFieldId )
157
143
. should ( 'be.visible' )
158
144
. and ( 'be.enabled' ) ;
159
145
// Assert description field label is visible
160
- cy . get ( inputFieldLabelSelector ( descriptionInputFieldId ) ) . should ( 'be.visible' ) ;
146
+ cy . getFormLabelByInputId ( descriptionInputFieldId ) . should ( 'be.visible' ) ;
161
147
// Assert description field is visible and enabled
162
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) )
148
+ cy . getFormInputFieldById ( descriptionInputFieldId )
163
149
. should ( 'be.visible' )
164
150
. and ( 'be.enabled' ) ;
165
151
// Assert cancel button is visible and enabled
166
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton )
152
+ cy . getFormFooterButtonByType ( cancelButton )
167
153
. should ( 'be.visible' )
168
154
. and ( 'be.enabled' ) ;
169
155
// Assert add/save button is visible and disabled
170
- cy . contains (
171
- buttonSelector ( submitButtonType ) ,
172
- isEditForm ? saveButton : addButton
156
+ cy . getFormFooterButtonByType (
157
+ isEditForm ? saveButton : addButton ,
158
+ submitButtonType
173
159
)
174
160
. should ( 'be.visible' )
175
161
. and ( 'be.disabled' ) ;
176
162
if ( isEditForm ) {
177
163
// Assert reset button is visible and disabled
178
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton )
164
+ cy . getFormFooterButtonByType ( resetButton )
179
165
. should ( 'be.visible' )
180
166
. and ( 'be.disabled' ) ;
181
167
}
@@ -229,12 +215,12 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
229
215
/* TODO: DATA_SETUP - Refactor to use API for domain data setup */
230
216
// Creating a domain to test namespace operations
231
217
cy . toolbar ( toolbarConfiguration , toolbarAddNewDomain ) ;
232
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . type ( domainName ) ;
233
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . type ( description ) ;
218
+ cy . getFormInputFieldById ( nameInputFieldId ) . type ( domainName ) ;
219
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . type ( description ) ;
234
220
cy . intercept ( 'POST' , '/miq_ae_class/create_namespace/new?button=add' ) . as (
235
221
'addNamespaceApi'
236
222
) ;
237
- cy . contains ( buttonSelector ( submitButtonType ) , addButton ) . click ( ) ;
223
+ cy . getFormFooterButtonByType ( addButton , submitButtonType ) . click ( ) ;
238
224
cy . wait ( '@addNamespaceApi' ) . then ( ( interception ) => {
239
225
extractDomainIdAndTokenFromResponse ( interception ) ;
240
226
} ) ;
@@ -251,17 +237,15 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
251
237
validateNamespaceFormFields ( ) ;
252
238
253
239
// Cancelling the form
254
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
240
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
255
241
} ) ;
256
242
257
243
it ( 'Validate Cancel button' , ( ) => {
258
244
// Navigating to the Add Namespace form
259
245
cy . toolbar ( toolbarConfiguration , toolbarAddNewNamespace ) ;
260
246
261
247
// Cancelling the form
262
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton )
263
- . should ( 'be.enabled' )
264
- . click ( ) ;
248
+ cy . getFormFooterButtonByType ( cancelButton ) . should ( 'be.enabled' ) . click ( ) ;
265
249
cy . expect_flash ( flashTypeWarning , flashMessageCancelled ) ;
266
250
} ) ;
267
251
@@ -271,7 +255,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
271
255
cy . expect_flash ( flashTypeError , flashMessageInvalidNamespace ) ;
272
256
273
257
// Cancelling the form
274
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
258
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
275
259
} ) ;
276
260
277
261
it ( 'Validate Edit Namespace form fields' , ( ) => {
@@ -282,7 +266,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
282
266
validateNamespaceFormFields ( true ) ;
283
267
284
268
// Cancelling the form
285
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
269
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
286
270
} ) ;
287
271
288
272
it ( 'Checking whether add, edit & delete namespace works' , ( ) => {
@@ -295,13 +279,13 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
295
279
// Editing the namespace
296
280
cy . toolbar ( toolbarConfiguration , toolbarEditNamespace ) ;
297
281
// Checking if the Save button is disabled initially
298
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . should (
282
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . should (
299
283
'be.disabled'
300
284
) ;
301
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) )
285
+ cy . getFormInputFieldById ( descriptionInputFieldId )
302
286
. clear ( )
303
287
. type ( editedDescription ) ;
304
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton )
288
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType )
305
289
. should ( 'be.enabled' )
306
290
. click ( ) ;
307
291
cy . expect_flash ( flashTypeSuccess , flashMessageSaveSuccess ) ;
@@ -324,7 +308,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
324
308
cy . expect_flash ( flashTypeError , flashMessageNameAlreadyExists ) ;
325
309
326
310
// Cancelling the form
327
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
311
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
328
312
} ) ;
329
313
330
314
it ( 'Checking whether Cancel & Reset buttons work fine in the Edit form' , ( ) => {
@@ -333,33 +317,29 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
333
317
334
318
/* Validating Reset button */
335
319
// Checking if the Reset button is disabled initially
336
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
337
- 'be.disabled'
338
- ) ;
320
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
339
321
// Editing name and description fields
340
- cy . get ( inputFieldSelector ( nameInputFieldId ) )
322
+ cy . getFormInputFieldById ( nameInputFieldId )
341
323
. clear ( )
342
324
. type ( editedNamespaceName ) ;
343
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) )
325
+ cy . getFormInputFieldById ( descriptionInputFieldId )
344
326
. clear ( )
345
327
. type ( editedDescription ) ;
346
328
// Resetting
347
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton )
348
- . should ( 'be.enabled' )
349
- . click ( ) ;
329
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
350
330
cy . expect_flash ( flashTypeWarning , flashMessageResetNamespace ) ;
351
331
// Confirming the edited fields contain the old values after resetting
352
- cy . get ( inputFieldSelector ( nameInputFieldId ) ) . should (
332
+ cy . getFormInputFieldById ( nameInputFieldId ) . should (
353
333
'have.value' ,
354
334
namespaceName
355
335
) ;
356
- cy . get ( inputFieldSelector ( descriptionInputFieldId ) ) . should (
336
+ cy . getFormInputFieldById ( descriptionInputFieldId ) . should (
357
337
'have.value' ,
358
338
description
359
339
) ;
360
340
361
341
/* Validating Cancel button */
362
- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton ) . click ( ) ;
342
+ cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
363
343
cy . expect_flash ( flashTypeWarning , flashMessageCancelled ) ;
364
344
} ) ;
365
345
0 commit comments