Add user group tests

This commit is contained in:
Nikolaj Geisle
2022-02-18 09:26:47 +01:00
parent 27a3431e76
commit 566648de3f
4 changed files with 89 additions and 39 deletions

View File

@@ -1,35 +0,0 @@
context('User Groups', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create user group', () => {
const name = "Test Group";
cy.umbracoEnsureUserGroupNameNotExists(name);
cy.umbracoSection('users');
cy.get('[data-element="sub-view-userGroups"]').click();
cy.umbracoButtonByLabelKey("actions_createGroup").click();
//Type name
cy.umbracoEditorHeaderName(name);
// Assign sections
cy.get('.umb-box:nth-child(1) .umb-property:nth-child(1) localize').click();
cy.get('.umb-tree-item__inner').click({multiple:true, timeout: 10000});
cy.get('.btn-success').last().click();
// Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureUserGroupNameNotExists(name);
});
});

View File

@@ -0,0 +1,85 @@
/// <reference types="Cypress" />
import { UserGroupBuilder } from 'umbraco-cypress-testhelpers';
context('User Groups', () => {
function navigateToUserGroups() {
cy.umbracoSection('users');
cy.get('[data-element="sub-view-userGroups"]').click();
}
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
it('Create user group', () => {
const name = "Test Group";
cy.umbracoEnsureUserGroupNameNotExists(name);
navigateToUserGroups();
cy.umbracoButtonByLabelKey("actions_createGroup").click();
//Type name
cy.umbracoEditorHeaderName(name);
// Assign sections
cy.get('.umb-box:nth-child(1) .umb-property:nth-child(1) localize').click();
cy.get('.umb-tree-item__inner').click({multiple:true, timeout: 10000});
cy.get('.btn-success').last().click();
// Save
cy.get('.btn-success').click();
//Assert
cy.umbracoSuccessNotification().should('be.visible');
//Clean up
cy.umbracoEnsureUserGroupNameNotExists(name);
});
it('Can delete user group', () => {
// Create user group
const groupName = "Delete user group test"
cy.umbracoEnsureUserGroupNameNotExists(groupName);
const userGroup = new UserGroupBuilder()
.withName(groupName)
.build();
cy.saveUserGroup(userGroup);
navigateToUserGroups();
// Delete the user group
cy.get('.umb-table-body > :nth-child(2)').click();
cy.umbracoButtonByLabelKey("general_delete").click();
cy.get('umb-button[alias="overlaySubmit"]').click();
cy.umbracoSuccessNotification().should('be.visible');
cy.get('.umb-table-body').contains(groupName).should('not.exist');
cy.umbracoEnsureUserGroupNameNotExists(groupName);
});
it('Cannot delete required groups', () => {
navigateToUserGroups();
// There's not really a good way to be 100% sure we'll get the admin group, it should be first, but who knows
// so double check that we actually got the correct one
const administrators = cy.get('.umb-table-body > :nth-child(1)');
administrators.should('contain', 'Administrators');
administrators.click({force: true});
const sensitive = cy.get('.umb-table-body > :nth-child(3)');
sensitive.should('contain', 'Sensitive data');
sensitive.click({force: true});
const translators = cy.get('.umb-table-body > :nth-child(4)');
translators.should('contain', 'Translators');
translators.click({force: true});
// Now that we've clicked all that we shouldn't be able to delete, ensure that the delete button does not show up
cy.get('.umb-editor-sub-header').should('not.contain', 'Delete');
});
});

View File

@@ -1628,9 +1628,9 @@
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q=="
},
"umbraco-cypress-testhelpers": {
"version": "1.0.0-beta-63",
"resolved": "https://registry.npmjs.org/umbraco-cypress-testhelpers/-/umbraco-cypress-testhelpers-1.0.0-beta-63.tgz",
"integrity": "sha512-X+DHWktfB+WBb7YrxvpneVfS1PATx2zPYMdkeZTmtoQEeyGxXA9fW6P712/AUbyGAhRhH+46t4cAINdWJxItug==",
"version": "1.0.0-beta-66",
"resolved": "https://registry.npmjs.org/umbraco-cypress-testhelpers/-/umbraco-cypress-testhelpers-1.0.0-beta-66.tgz",
"integrity": "sha512-/Iq0P7rN9LfODO9snoLNqvbd8b432JIYtCVjYOdYZFceMAUIv0v2/6t7+N55Z7h8OpAQzcTLU3VCxfPzZp8wQw==",
"dev": true,
"requires": {
"camelize": "^1.0.0",

View File

@@ -14,7 +14,7 @@
"del": "^6.0.0",
"ncp": "^2.0.0",
"prompt": "^1.2.0",
"umbraco-cypress-testhelpers": "^1.0.0-beta-63"
"umbraco-cypress-testhelpers": "^1.0.0-beta-65"
},
"dependencies": {
"typescript": "^3.9.2"