@@ -32,4 +32,109 @@ context('Users', () => {
3232
3333 } ) ;
3434
35- } ) ;
35+ it ( 'Update user' , ( ) => {
36+ // Set userdata
37+ const name = "Alice Bobson" ;
38+ const email = "alice-bobson@acceptancetest.umbraco" ;
39+ const startContentIds = [ ] ;
40+ const startMediaIds = [ ] ;
41+ const userGroups = [ "admin" ] ;
42+
43+ var userData =
44+ {
45+ "id" : - 1 ,
46+ "parentId" : - 1 ,
47+ "name" : name ,
48+ "username" : email ,
49+ "culture" : "en-US" ,
50+ "email" : email ,
51+ "startContentIds" : startContentIds ,
52+ "startMediaIds" : startMediaIds ,
53+ "userGroups" : userGroups ,
54+ "message" : ""
55+ } ;
56+
57+ // Ensure user doesn't exist
58+ cy . umbracoEnsureUserEmailNotExists ( email ) ;
59+
60+ // Create user through API
61+ cy . getCookie ( 'UMB-XSRF-TOKEN' , { log : false } ) . then ( ( token ) => {
62+ cy . request ( {
63+ method : 'POST' ,
64+ url : '/umbraco/backoffice/umbracoapi/users/PostCreateUser' ,
65+ followRedirect : true ,
66+ headers : {
67+ Accept : 'application/json' ,
68+ 'X-UMB-XSRF-TOKEN' : token . value ,
69+ } ,
70+ body : userData ,
71+ log : false ,
72+ } ) . then ( ( response ) => {
73+ return ;
74+ } ) ;
75+ } ) ;
76+
77+ // Go to the user and edit their name
78+ cy . umbracoSection ( 'users' ) ;
79+ cy . get ( '.umb-user-card__name' ) . contains ( name ) . click ( ) ;
80+ cy . get ( '#headerName' ) . type ( '{movetoend}son' ) ;
81+ cy . umbracoButtonByLabelKey ( 'buttons_save' ) . click ( ) ;
82+
83+ // assert save succeeds
84+ cy . umbracoSuccessNotification ( ) . should ( 'be.visible' ) ;
85+ cy . umbracoEnsureUserEmailNotExists ( email ) ;
86+ } )
87+
88+ it ( 'Delete user' , ( ) => {
89+ // Set userdata
90+ const name = "Alice Bobson" ;
91+ const email = "alice-bobson@acceptancetest.umbraco" ;
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 ) ;
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+ } )
140+ } ) ;
0 commit comments