Skip to content

Commit a2f0585

Browse files
authored
add cypress test for deleting a user (#11282)
1 parent 9a5960b commit a2f0585

File tree

1 file changed

+52
-0
lines changed
  • src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users

1 file changed

+52
-0
lines changed

src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/users.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,57 @@ context('Users', () => {
8484
cy.umbracoSuccessNotification().should('be.visible');
8585
cy.umbracoEnsureUserEmailNotExists(email);
8686
})
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);
87112

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+
})
88140
});

0 commit comments

Comments
 (0)