|
| 1 | +/// <reference types="Cypress" /> |
| 2 | +import { UserGroupBuilder } from 'umbraco-cypress-testhelpers'; |
| 3 | + |
| 4 | +context('User Groups', () => { |
| 5 | + |
| 6 | + function navigateToUserGroups() { |
| 7 | + cy.umbracoSection('users'); |
| 8 | + cy.get('[data-element="sub-view-userGroups"]').click(); |
| 9 | + } |
| 10 | + |
| 11 | + beforeEach(() => { |
| 12 | + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); |
| 13 | + }); |
| 14 | + |
| 15 | + it('Create user group', () => { |
| 16 | + const name = "Test Group"; |
| 17 | + |
| 18 | + cy.umbracoEnsureUserGroupNameNotExists(name); |
| 19 | + |
| 20 | + navigateToUserGroups(); |
| 21 | + cy.umbracoButtonByLabelKey("actions_createGroup").click(); |
| 22 | + |
| 23 | + //Type name |
| 24 | + cy.umbracoEditorHeaderName(name); |
| 25 | + |
| 26 | + // Assign sections |
| 27 | + cy.get('.umb-box:nth-child(1) .umb-property:nth-child(1) localize').click(); |
| 28 | + cy.get('.umb-tree-item__inner').click({multiple:true, timeout: 10000}); |
| 29 | + cy.get('.btn-success').last().click(); |
| 30 | + |
| 31 | + // Save |
| 32 | + cy.get('.btn-success').click(); |
| 33 | + |
| 34 | + //Assert |
| 35 | + cy.umbracoSuccessNotification().should('be.visible'); |
| 36 | + |
| 37 | + //Clean up |
| 38 | + cy.umbracoEnsureUserGroupNameNotExists(name); |
| 39 | + }); |
| 40 | + |
| 41 | + it('Can delete user group', () => { |
| 42 | + // Create user group |
| 43 | + const groupName = "Delete user group test" |
| 44 | + cy.umbracoEnsureUserGroupNameNotExists(groupName); |
| 45 | + |
| 46 | + const userGroup = new UserGroupBuilder() |
| 47 | + .withName(groupName) |
| 48 | + .build(); |
| 49 | + |
| 50 | + cy.saveUserGroup(userGroup); |
| 51 | + navigateToUserGroups(); |
| 52 | + |
| 53 | + // Delete the user group |
| 54 | + cy.get('.umb-table-body > :nth-child(2)').click(); |
| 55 | + cy.umbracoButtonByLabelKey("general_delete").click(); |
| 56 | + cy.get('umb-button[alias="overlaySubmit"]').click(); |
| 57 | + |
| 58 | + cy.umbracoSuccessNotification().should('be.visible'); |
| 59 | + cy.get('.umb-table-body').contains(groupName).should('not.exist'); |
| 60 | + |
| 61 | + cy.umbracoEnsureUserGroupNameNotExists(groupName); |
| 62 | + }); |
| 63 | + |
| 64 | + it('Cannot delete required groups', () => { |
| 65 | + navigateToUserGroups(); |
| 66 | + |
| 67 | + // There's not really a good way to be 100% sure we'll get the admin group, it should be first, but who knows |
| 68 | + // so double check that we actually got the correct one |
| 69 | + const administrators = cy.get('.umb-table-body > :nth-child(1)'); |
| 70 | + administrators.should('contain', 'Administrators'); |
| 71 | + administrators.click({force: true}); |
| 72 | + |
| 73 | + const sensitive = cy.get('.umb-table-body > :nth-child(3)'); |
| 74 | + sensitive.should('contain', 'Sensitive data'); |
| 75 | + sensitive.click({force: true}); |
| 76 | + |
| 77 | + const translators = cy.get('.umb-table-body > :nth-child(4)'); |
| 78 | + translators.should('contain', 'Translators'); |
| 79 | + translators.click({force: true}); |
| 80 | + |
| 81 | + // Now that we've clicked all that we shouldn't be able to delete, ensure that the delete button does not show up |
| 82 | + cy.get('.umb-editor-sub-header').should('not.contain', 'Delete'); |
| 83 | + }); |
| 84 | +}); |
| 85 | + |
0 commit comments