@@ -9,7 +9,6 @@ const textConstants = {
9
9
// Toolbar options
10
10
toolbarConfiguration : 'Configuration' ,
11
11
toolbarAddNewDomain : 'Add a New Domain' ,
12
- toolbarRemoveDomain : 'Remove this Domain' ,
13
12
toolbarAddNewNamespace : 'Add a New Namespace' ,
14
13
toolbarEditNamespace : 'Edit this Namespace' ,
15
14
toolbarRemoveNamespace : 'Remove this Namespace' ,
@@ -41,9 +40,6 @@ const textConstants = {
41
40
editNamespaceFormHeader : 'Editing Automate Namespace' ,
42
41
namespaceFormSubHeader : 'Info' ,
43
42
44
- // List items
45
- dataStoreAccordionItem : 'Datastore' ,
46
-
47
43
// Buttons
48
44
addButton : 'Add' ,
49
45
cancelButton : 'Cancel' ,
@@ -85,7 +81,6 @@ const {
85
81
toolbarAddNewNamespace,
86
82
toolbarEditNamespace,
87
83
toolbarRemoveNamespace,
88
- toolbarRemoveDomain,
89
84
addNamespaceFormHeader,
90
85
editNamespaceFormHeader,
91
86
namespaceFormSubHeader,
@@ -104,7 +99,6 @@ const {
104
99
flashMessageNameAlreadyExists,
105
100
flashMessageResetNamespace,
106
101
browserConfirmRemoveMessage,
107
- dataStoreAccordionItem,
108
102
nameInputFieldId,
109
103
descriptionInputFieldId,
110
104
namespacePathInputFieldId,
@@ -126,7 +120,6 @@ function selectAccordionTree(textValue) {
126
120
const aliasObject = {
127
121
[ domainName ] : 'getCreatedDomainInfo' ,
128
122
[ namespaceName ] : 'getCreatedNamespaceInfo' ,
129
- [ dataStoreAccordionItem ] : 'getDataStoreAccordionItemInfo' ,
130
123
} ;
131
124
cy . intercept (
132
125
'POST' ,
@@ -193,6 +186,33 @@ function createNamespaceAndOpenEditForm() {
193
186
cy . toolbar ( toolbarConfiguration , toolbarEditNamespace ) ;
194
187
}
195
188
189
+ function extractDomainIdAndTokenFromResponse ( interception ) {
190
+ const rawTreeObject = interception ?. response ?. body ?. reloadTrees ?. ae_tree ;
191
+ if ( rawTreeObject ) {
192
+ const rawTreeParsed = JSON . parse ( rawTreeObject ) ;
193
+ rawTreeParsed . every ( ( treeObject ) => {
194
+ // Exit iteration once id is extracted from nodes array
195
+ return treeObject ?. nodes ?. every ( ( nodeObject ) => {
196
+ if ( nodeObject ?. text === domainName ) {
197
+ const domainId = nodeObject ?. key ?. split ( '-' ) ?. [ 1 ] ;
198
+ const csrfToken = interception ?. request ?. headers ?. [ 'x-csrf-token' ] ;
199
+ const idAndToken = {
200
+ domainId,
201
+ csrfToken,
202
+ } ;
203
+ // Creating an aliased state to store id and token
204
+ cy . wrap ( idAndToken ) . as ( 'idAndToken' ) ;
205
+
206
+ // Stop iterating once the domain id is found
207
+ return false ;
208
+ }
209
+ // Continue iterating
210
+ return true ;
211
+ } ) ;
212
+ } ) ;
213
+ }
214
+ }
215
+
196
216
describe ( 'Automate operations on Namespaces: Automation -> Embedded Automate -> Explorer -> {Any-created-domain} -> Namespace form' , ( ) => {
197
217
beforeEach ( ( ) => {
198
218
cy . login ( ) ;
@@ -209,7 +229,9 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
209
229
'addNamespaceApi'
210
230
) ;
211
231
cy . contains ( buttonSelector ( submitButtonType ) , addButton ) . click ( ) ;
212
- cy . wait ( '@addNamespaceApi' ) ;
232
+ cy . wait ( '@addNamespaceApi' ) . then ( ( interception ) => {
233
+ extractDomainIdAndTokenFromResponse ( interception ) ;
234
+ } ) ;
213
235
cy . expect_flash ( flashTypeSuccess , flashMessageAddSuccess ) ;
214
236
// Selecting the created domain from the accordion list items
215
237
selectAccordionTree ( domainName ) ;
@@ -335,15 +357,18 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate ->
335
357
} ) ;
336
358
337
359
afterEach ( ( ) => {
338
- // Selecting the created domain(Test_Domain) from the accordion list items
339
- selectAccordionTree ( dataStoreAccordionItem ) ;
340
- cy . accordionItem ( domainName ) ;
341
- cy . wait ( '@getCreatedDomainInfo' ) ;
342
- // Removing the domain
343
- cy . expect_browser_confirm_with_text ( {
344
- confirmTriggerFn : ( ) =>
345
- cy . toolbar ( toolbarConfiguration , toolbarRemoveDomain ) ,
346
- containsText : browserConfirmRemoveMessage ,
360
+ // retrieve the id and token from the aliased state
361
+ // to invoke api for deleting the created domain
362
+ cy . get ( '@idAndToken' ) . then ( ( data ) => {
363
+ cy . request ( {
364
+ method : 'POST' ,
365
+ url : `/miq_ae_class/x_button/${ data . domainId } ?pressed=miq_ae_domain_delete` ,
366
+ headers : {
367
+ 'X-CSRF-Token' : data ?. csrfToken ,
368
+ } ,
369
+ } ) . then ( ( response ) => {
370
+ expect ( response . status ) . to . eq ( 200 ) ;
371
+ } ) ;
347
372
} ) ;
348
373
} ) ;
349
374
} ) ;
0 commit comments