diff options
Diffstat (limited to 'cypress/e2e/settings/users_modify.cy.ts')
-rw-r--r-- | cypress/e2e/settings/users_modify.cy.ts | 225 |
1 files changed, 225 insertions, 0 deletions
diff --git a/cypress/e2e/settings/users_modify.cy.ts b/cypress/e2e/settings/users_modify.cy.ts new file mode 100644 index 00000000000..749bded2e94 --- /dev/null +++ b/cypress/e2e/settings/users_modify.cy.ts @@ -0,0 +1,225 @@ +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { User } from '@nextcloud/cypress' +import { getUserListRow, handlePasswordConfirmation, toggleEditButton, waitLoading } from './usersUtils' +import { clearState } from '../../support/commonUtils' + +const admin = new User('admin', 'admin') + +describe('Settings: Change user properties', function() { + let user: User + + beforeEach(function() { + clearState() + cy.createRandomUser().then(($user) => { user = $user }) + cy.login(admin) + }) + + it('Can change the display name', function() { + // open the User settings as admin + cy.visit('/settings/users') + + // toggle edit button into edit mode + toggleEditButton(user, true) + + getUserListRow(user.userId).within(() => { + // set the display name + cy.get('[data-cy-user-list-input-displayname]').should('exist').and('have.value', user.userId) + cy.get('[data-cy-user-list-input-displayname]').clear() + cy.get('[data-cy-user-list-input-displayname]').type('John Doe') + cy.get('[data-cy-user-list-input-displayname]').should('have.value', 'John Doe') + cy.get('[data-cy-user-list-input-displayname] ~ button').click() + + // Make sure no confirmation modal is shown + handlePasswordConfirmation(admin.password) + + // see that the display name cell is done loading + waitLoading('[data-cy-user-list-input-displayname]') + }) + + // Success message is shown + cy.get('.toastify.toast-success').contains(/Display.+name.+was.+successfully.+changed/i).should('exist') + }) + + it('Can change the password', function() { + // open the User settings as admin + cy.visit('/settings/users') + + // toggle edit button into edit mode + toggleEditButton(user, true) + + getUserListRow(user.userId).within(() => { + // see that the password of user is "" + cy.get('[data-cy-user-list-input-password]').should('exist').and('have.value', '') + // set the password for user to 123456 + cy.get('[data-cy-user-list-input-password]').type('123456') + // When I set the password for user to 123456 + cy.get('[data-cy-user-list-input-password]').should('have.value', '123456') + cy.get('[data-cy-user-list-input-password] ~ button').click() + + // Make sure no confirmation modal is shown + handlePasswordConfirmation(admin.password) + + // see that the password cell for user is done loading + waitLoading('[data-cy-user-list-input-password]') + // password input is emptied on change + cy.get('[data-cy-user-list-input-password]').should('have.value', '') + }) + + // Success message is shown + cy.get('.toastify.toast-success').contains(/Password.+successfully.+changed/i).should('exist') + }) + + it('Can change the email address', function() { + // open the User settings as admin + cy.visit('/settings/users') + + // toggle edit button into edit mode + toggleEditButton(user, true) + + getUserListRow(user.userId).find('[data-cy-user-list-cell-email]').within(() => { + // see that the email of user is "" + cy.get('input').should('exist').and('have.value', '') + // set the email for user to mymail@example.com + cy.get('input').type('mymail@example.com') + // When I set the password for user to mymail@example.com + cy.get('input').should('have.value', 'mymail@example.com') + cy.get('input ~ button').click() + + // Make sure no confirmation modal is shown + handlePasswordConfirmation(admin.password) + + // see that the password cell for user is done loading + waitLoading('[data-cy-user-list-input-email]') + }) + + // Success message is shown + cy.get('.toastify.toast-success').contains(/Email.+successfully.+changed/i).should('exist') + }) + + it('Can change the user quota to a predefined one', function() { + // open the User settings as admin + cy.visit('/settings/users') + + // toggle edit button into edit mode + toggleEditButton(user, true) + + getUserListRow(user.userId).find('[data-cy-user-list-cell-quota]').scrollIntoView() + getUserListRow(user.userId).find('[data-cy-user-list-cell-quota] [data-cy-user-list-input-quota]').within(() => { + // see that the quota of user is unlimited + cy.get('.vs__selected').should('exist').and('contain.text', 'Unlimited') + // Open the quota selector + cy.get('[role="combobox"]').click({ force: true }) + // see that there are default options for the quota + cy.get('li').then(($options) => { + expect($options).to.have.length(5) + cy.wrap($options).contains('Default quota') + cy.wrap($options).contains('Unlimited') + cy.wrap($options).contains('1 GB') + cy.wrap($options).contains('10 GB') + // select 5 GB + cy.wrap($options).contains('5 GB').click({ force: true }) + + // Make sure no confirmation modal is shown + handlePasswordConfirmation(admin.password) + }) + // see that the quota of user is 5 GB + cy.get('.vs__selected').should('exist').and('contain.text', '5 GB') + }) + + // see that the changes are loading + waitLoading('[data-cy-user-list-input-quota]') + + // finish editing the user + toggleEditButton(user, false) + + // I see that the quota was set on the backend + cy.runOccCommand(`user:info --output=json '${user.userId}'`).then(($result) => { + expect($result.code).to.equal(0) + const info = JSON.parse($result.stdout) + expect(info?.quota).to.equal('5 GB') + }) + }) + + it('Can change the user quota to a custom value', function() { + // open the User settings as admin + cy.visit('/settings/users') + + // toggle edit button into edit mode + toggleEditButton(user, true) + + getUserListRow(user.userId).find('[data-cy-user-list-cell-quota]').scrollIntoView() + getUserListRow(user.userId).find('[data-cy-user-list-cell-quota]').within(() => { + // see that the quota of user is unlimited + cy.get('.vs__selected').should('exist').and('contain.text', 'Unlimited') + // set the quota to 4 MB + cy.get('[data-cy-user-list-input-quota] input').type('4 MB{enter}') + + // Make sure no confirmation modal is shown + handlePasswordConfirmation(admin.password) + + // see that the quota of user is 4 MB + // TODO: Enable this after the file size handling is fixed + // cy.get('.vs__selected').should('exist').and('contain.text', '4 MB') + + // see that the changes are loading + waitLoading('[data-cy-user-list-input-quota]') + }) + + // finish editing the user + toggleEditButton(user, false) + + // I see that the quota was set on the backend + cy.runOccCommand(`user:info --output=json '${user.userId}'`).then(($result) => { + expect($result.code).to.equal(0) + // TODO: Enable this after the file size handling is fixed!!!!!! + // const info = JSON.parse($result.stdout) + // expect(info?.quota).to.equal('4 MB') + }) + }) + + it('Can make user a subadmin of a group', function() { + // create a group + const groupName = 'userstestgroup' + cy.runOccCommand(`group:add '${groupName}'`) + + // open the User settings as admin + cy.visit('/settings/users') + + // toggle edit button into edit mode + toggleEditButton(user, true) + + getUserListRow(user.userId).find('[data-cy-user-list-cell-subadmins]').scrollIntoView() + getUserListRow(user.userId).find('[data-cy-user-list-cell-subadmins]').within(() => { + // see that the user is no subadmin + cy.get('.vs__selected').should('not.exist') + // Open the dropdown menu + cy.get('[role="combobox"]').click({ force: true }) + // Search for the group + cy.get('[role="combobox"]').type('userstestgroup') + // select the group + cy.contains('li', groupName).click({ force: true }) + + // handle password confirmation on time out + handlePasswordConfirmation(admin.password) + + // see that the user is subadmin of the group + cy.get('.vs__selected').should('exist').and('contain.text', groupName) + }) + + waitLoading('[data-cy-user-list-input-subadmins]') + + // finish editing the user + toggleEditButton(user, false) + + // I see that the quota was set on the backend + cy.getUserData(user).then(($response) => { + expect($response.status).to.equal(200) + const dom = (new DOMParser()).parseFromString($response.body, 'text/xml') + expect(dom.querySelector('subadmin element')?.textContent).to.contain(groupName) + }) + }) +}) |