@@ -16,52 +16,58 @@ Cypress.Commands.add("cancelForm", (formId) => {
1616} ) ;
1717
1818Cypress . Commands . add ( "resetForm" , ( formId , managementApi , address ) => {
19- const resetButton = "#" + formId + ' a.clickable[data-operation="reset"' ;
20- cy . get ( resetButton ) . click ( ) ;
21- cy . get ( "body" ) . then ( ( $body ) => {
22- if ( $body . find ( ".modal-footer .btn-hal.btn-primary" ) . length ) {
23- cy . get ( ".modal-footer .btn-hal.btn-primary" ) . click ( { force : true } ) ;
24- cy . verifySuccess ( ) ;
25- } else {
26- cy . get ( ".toast-notifications-list-pf .alert-warning" )
27- . contains ( "None of the attributes could be reset." )
28- . should ( "be.visible" ) ;
29- }
30- } ) ;
31- cy . task ( "execute:cli" , {
32- managementApi : `${ managementApi } /management` ,
33- operation : "read-resource-description" ,
34- address : address ,
35- } ) . then ( ( result ) => {
36- expect ( ( result as { outcome : string } ) . outcome ) . to . equal ( "success" ) ;
37- const attributes = (
38- result as {
39- result : { attributes : { [ key : string ] : { default ?: string } } } ;
40- }
41- ) . result . attributes ;
42- const attributesWithDefaultValues = Object . keys ( attributes )
43- . filter ( ( key : string ) => Object . prototype . hasOwnProperty . call ( attributes [ key ] , "default" ) )
44- . map ( ( key ) => {
45- const obj : {
46- [ index : string ] : undefined | string | number | boolean ;
47- } = { } ;
48- obj [ "name" ] = key ;
49- obj [ "defaultValue" ] = attributes [ key ] . default ;
50- return obj ;
19+ const resetButton = `#${ formId } a.clickable[data-operation="reset"]` ;
20+ cy . isEAP ( managementApi ) . then ( ( isEAP ) => {
21+ if ( isEAP ) {
22+ cy . get ( resetButton ) . click ( ) ;
23+ cy . get ( "body" ) . then ( ( $body ) => {
24+ if ( $body . find ( ".modal-footer .btn-hal.btn-primary" ) . length ) {
25+ cy . get ( ".modal-footer .btn-hal.btn-primary" ) . click ( { force : true } ) ;
26+ cy . verifySuccess ( ) ;
27+ } else {
28+ cy . get ( ".toast-notifications-list-pf .alert-warning" )
29+ . contains ( "None of the attributes could be reset." )
30+ . should ( "be.visible" ) ;
31+ }
5132 } ) ;
52- attributesWithDefaultValues . forEach ( ( attributeWithDefaultValue ) => {
5333 cy . task ( "execute:cli" , {
5434 managementApi : `${ managementApi } /management` ,
55- operation : "read-attribute " ,
35+ operation : "read-resource-description " ,
5636 address : address ,
57- name : attributeWithDefaultValue . name ,
5837 } ) . then ( ( result ) => {
5938 expect ( ( result as { outcome : string } ) . outcome ) . to . equal ( "success" ) ;
60- expect ( ( result as { result : string | number | boolean } ) . result ) . to . equal (
61- attributeWithDefaultValue . defaultValue
62- ) ;
39+ const attributes = (
40+ result as {
41+ result : { attributes : { [ key : string ] : { default ?: string } } } ;
42+ }
43+ ) . result . attributes ;
44+ const attributesWithDefaultValues = Object . keys ( attributes )
45+ . filter ( ( key : string ) => Object . prototype . hasOwnProperty . call ( attributes [ key ] , "default" ) )
46+ . map ( ( key ) => {
47+ const obj : {
48+ [ index : string ] : undefined | string | number | boolean ;
49+ } = { } ;
50+ obj [ "name" ] = key ;
51+ obj [ "defaultValue" ] = attributes [ key ] . default ;
52+ return obj ;
53+ } ) ;
54+ attributesWithDefaultValues . forEach ( ( attributeWithDefaultValue ) => {
55+ cy . task ( "execute:cli" , {
56+ managementApi : `${ managementApi } /management` ,
57+ operation : "read-attribute" ,
58+ address : address ,
59+ name : attributeWithDefaultValue . name ,
60+ } ) . then ( ( result ) => {
61+ expect ( ( result as { outcome : string } ) . outcome ) . to . equal ( "success" ) ;
62+ expect ( ( result as { result : string | number | boolean } ) . result ) . to . equal (
63+ attributeWithDefaultValue . defaultValue
64+ ) ;
65+ } ) ;
66+ } ) ;
6367 } ) ;
64- } ) ;
68+ } else {
69+ cy . contains ( resetButton ) . should ( "not.exist" ) ;
70+ }
6571 } ) ;
6672} ) ;
6773
0 commit comments