From 4386803ae8c385f1c8506a95d953b0168d59731f Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Wed, 11 Oct 2023 10:39:54 -0700 Subject: test(settings): Create and delete groups Signed-off-by: Christopher Ng --- cypress/e2e/settings/users_groups.cy.ts | 104 ++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 cypress/e2e/settings/users_groups.cy.ts (limited to 'cypress') diff --git a/cypress/e2e/settings/users_groups.cy.ts b/cypress/e2e/settings/users_groups.cy.ts new file mode 100644 index 00000000000..1a5e8560590 --- /dev/null +++ b/cypress/e2e/settings/users_groups.cy.ts @@ -0,0 +1,104 @@ +/** + * @copyright 2023 Christopher Ng + * + * @author Christopher Ng + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import { User } from '@nextcloud/cypress' + +const admin = new User('admin', 'admin') + +describe('Settings: Create and delete groups', () => { + before(() => { + cy.login(admin) + // open the User settings + cy.visit('/settings/users') + }) + + it('Can create a group', () => { + // open the Create group menu + cy.get('button[aria-label="Create group"]').click() + + cy.get('.action-item__popper ul[role="menu"]').within(() => { + // see that the group name is "" + cy.get('input[placeholder="Group name"]').should('exist').and('have.value', '') + // set the group name to foo + cy.get('input[placeholder="Group name"]').type('foo') + // see that the group name is foo + cy.get('input[placeholder="Group name"]').should('have.value', 'foo') + // submit the group name + cy.get('input[placeholder="Group name"] ~ button').click() + }) + + // Ignore failure if modal is not shown + cy.once('fail', (error) => { + expect(error.name).to.equal('AssertionError') + expect(error).to.have.property('node', '.modal-container') + }) + // Make sure no confirmation modal is shown + cy.get('body').find('.modal-container').then(($modals) => { + if ($modals.length > 0) { + cy.wrap($modals.first()).find('input[type="password"]').type(admin.password) + cy.wrap($modals.first()).find('button').contains('Confirm').click() + } + }) + + // see that the created group is in the list + cy.get('ul.app-navigation__list').within(() => { + // see that the list of groups contains the group foo + cy.contains('foo').should('exist') + }) + }) + + it('Can delete a group', () => { + // see that the group is in the list + cy.get('ul.app-navigation__list').within(() => { + // see that the list of groups contains the group foo + cy.contains('foo').should('exist') + // open the actions menu for the group + cy.contains('li', 'foo').within(() => { + cy.get('button.action-item__menutoggle').click() + }) + }) + + // The "Remove group" action in the actions menu is shown and clicked + cy.get('.action-item__popper button').contains('Remove group').should('exist').click() + // And confirmation dialog accepted + cy.get('.modal-container button').contains('Confirm').click() + + // Ignore failure if modal is not shown + cy.once('fail', (error) => { + expect(error.name).to.equal('AssertionError') + expect(error).to.have.property('node', '.modal-container') + }) + // Make sure no confirmation modal is shown + cy.get('body').find('.modal-container').then(($modals) => { + if ($modals.length > 0) { + cy.wrap($modals.first()).find('input[type="password"]').type(admin.password) + cy.wrap($modals.first()).find('button').contains('Confirm').click() + } + }) + + // deleted group is not shown anymore + cy.get('ul.app-navigation__list').within(() => { + // see that the list of groups does not contain the group foo + cy.contains('foo').should('not.exist') + }) + }) +}) -- cgit v1.2.3