Skip to content

Commit

Permalink
add cypress test for deleting a user (umbraco#11282)
Browse files Browse the repository at this point in the history
  • Loading branch information
jemayn authored Oct 10, 2021
1 parent 9a5960b commit a2f0585
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,57 @@ context('Users', () => {
cy.umbracoSuccessNotification().should('be.visible');
cy.umbracoEnsureUserEmailNotExists(email);
})

it('Delete user', () => {
// Set userdata
const name = "Alice Bobson";
const email = "[email protected]";
const startContentIds = [];
const startMediaIds = [];
const userGroups = ["admin"];

var userData =
{
"id": -1,
"parentId": -1,
"name": name,
"username": email,
"culture": "en-US",
"email": email,
"startContentIds": startContentIds,
"startMediaIds": startMediaIds,
"userGroups": userGroups,
"message": ""
};

// Ensure user doesn't exist
cy.umbracoEnsureUserEmailNotExists(email);

// Create user through API
cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => {
cy.request({
method: 'POST',
url: '/umbraco/backoffice/umbracoapi/users/PostCreateUser',
followRedirect: true,
headers: {
Accept: 'application/json',
'X-UMB-XSRF-TOKEN': token.value,
},
body: userData,
log: false,
}).then((response) => {
return;
});
});

// Go to the user and delete them
cy.umbracoSection('users');
cy.get('.umb-user-card__name').contains(name).click();
cy.umbracoButtonByLabelKey("user_deleteUser").click();
cy.get('umb-button[label="Yes, delete"]').click();

// assert deletion succeeds
cy.umbracoSuccessNotification().should('be.visible');
cy.umbracoEnsureUserEmailNotExists(email);
})
});

0 comments on commit a2f0585

Please sign in to comment.