@@ -84,5 +84,57 @@ context('Users', () => {
84
84
cy . umbracoSuccessNotification ( ) . should ( 'be.visible' ) ;
85
85
cy . umbracoEnsureUserEmailNotExists ( email ) ;
86
86
} )
87
+
88
+ it ( 'Delete user' , ( ) => {
89
+ // Set userdata
90
+ const name = "Alice Bobson" ;
91
+ const email = "[email protected] " ;
92
+ const startContentIds = [ ] ;
93
+ const startMediaIds = [ ] ;
94
+ const userGroups = [ "admin" ] ;
95
+
96
+ var userData =
97
+ {
98
+ "id" : - 1 ,
99
+ "parentId" : - 1 ,
100
+ "name" : name ,
101
+ "username" : email ,
102
+ "culture" : "en-US" ,
103
+ "email" : email ,
104
+ "startContentIds" : startContentIds ,
105
+ "startMediaIds" : startMediaIds ,
106
+ "userGroups" : userGroups ,
107
+ "message" : ""
108
+ } ;
109
+
110
+ // Ensure user doesn't exist
111
+ cy . umbracoEnsureUserEmailNotExists ( email ) ;
87
112
113
+ // Create user through API
114
+ cy . getCookie ( 'UMB-XSRF-TOKEN' , { log : false } ) . then ( ( token ) => {
115
+ cy . request ( {
116
+ method : 'POST' ,
117
+ url : '/umbraco/backoffice/umbracoapi/users/PostCreateUser' ,
118
+ followRedirect : true ,
119
+ headers : {
120
+ Accept : 'application/json' ,
121
+ 'X-UMB-XSRF-TOKEN' : token . value ,
122
+ } ,
123
+ body : userData ,
124
+ log : false ,
125
+ } ) . then ( ( response ) => {
126
+ return ;
127
+ } ) ;
128
+ } ) ;
129
+
130
+ // Go to the user and delete them
131
+ cy . umbracoSection ( 'users' ) ;
132
+ cy . get ( '.umb-user-card__name' ) . contains ( name ) . click ( ) ;
133
+ cy . umbracoButtonByLabelKey ( "user_deleteUser" ) . click ( ) ;
134
+ cy . get ( 'umb-button[label="Yes, delete"]' ) . click ( ) ;
135
+
136
+ // assert deletion succeeds
137
+ cy . umbracoSuccessNotification ( ) . should ( 'be.visible' ) ;
138
+ cy . umbracoEnsureUserEmailNotExists ( email ) ;
139
+ } )
88
140
} ) ;
0 commit comments