Skip to content

Commit dafd7f2

Browse files
authored
Merge pull request #12024 from umbraco/v9/feature/add_user_group_tests
Add user group tests
2 parents e67da0b + 566648d commit dafd7f2

File tree

4 files changed

+89
-39
lines changed

4 files changed

+89
-39
lines changed

tests/Umbraco.Tests.AcceptanceTest/cypress/integration/Users/userGroups.js

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+

tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Umbraco.Tests.AcceptanceTest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"del": "^6.0.0",
1515
"ncp": "^2.0.0",
1616
"prompt": "^1.2.0",
17-
"umbraco-cypress-testhelpers": "^1.0.0-beta-63"
17+
"umbraco-cypress-testhelpers": "^1.0.0-beta-65"
1818
},
1919
"dependencies": {
2020
"typescript": "^3.9.2"

0 commit comments

Comments
 (0)