From f555f0adfe68d06c78ec64b0763359291d0f72e6 Mon Sep 17 00:00:00 2001 From: Jesper Mayntzhusen <79840720+jemayn@users.noreply.github.com> Date: Sun, 10 Oct 2021 18:50:02 +0200 Subject: [PATCH] add cypress test for deleting a user (#11282) (cherry picked from commit a2f05850c0d9771189861214a6ec35828e359528) # Conflicts: # src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/users.ts --- .../cypress/integration/Users/users.ts | 107 +++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/users.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/users.ts index e122b2156432..12a9bee7a20b 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/users.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/users.ts @@ -32,4 +32,109 @@ context('Users', () => { }); -}); + it('Update user', () => { + // Set userdata + const name = "Alice Bobson"; + const email = "alice-bobson@acceptancetest.umbraco"; + 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 edit their name + cy.umbracoSection('users'); + cy.get('.umb-user-card__name').contains(name).click(); + cy.get('#headerName').type('{movetoend}son'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + + // assert save succeeds + cy.umbracoSuccessNotification().should('be.visible'); + cy.umbracoEnsureUserEmailNotExists(email); + }) + + it('Delete user', () => { + // Set userdata + const name = "Alice Bobson"; + const email = "alice-bobson@acceptancetest.umbraco"; + 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); + }) +}); \ No newline at end of file