aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e/settings/users_modify.cy.ts
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2023-10-18 15:19:11 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2023-10-25 11:36:24 +0200
commit5b0c27b6dafb6ab6007339214c1d22d79e4b6f5d (patch)
treee292568c4e2311fa0b29f0b95c7432c4418e1a84 /cypress/e2e/settings/users_modify.cy.ts
parent888473f5e2aa47b92c11fd169a3ffdd23b2c5504 (diff)
downloadnextcloud-server-5b0c27b6dafb6ab6007339214c1d22d79e4b6f5d.tar.gz
nextcloud-server-5b0c27b6dafb6ab6007339214c1d22d79e4b6f5d.zip
fix(settings): Stablize user list cypress tests
* Use common `data-testid` to identify elements rather than to depend on internal classes or properties * Force clean the state for the user tests * Move leftover acceptance tests for users from drone to cypress Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'cypress/e2e/settings/users_modify.cy.ts')
-rw-r--r--cypress/e2e/settings/users_modify.cy.ts284
1 files changed, 226 insertions, 58 deletions
diff --git a/cypress/e2e/settings/users_modify.cy.ts b/cypress/e2e/settings/users_modify.cy.ts
index c08e9de2610..ee3d1f37c02 100644
--- a/cypress/e2e/settings/users_modify.cy.ts
+++ b/cypress/e2e/settings/users_modify.cy.ts
@@ -21,92 +21,260 @@
*/
import { User } from '@nextcloud/cypress'
-import { getUserListRow, handlePasswordConfirmation } from './usersUtils'
+import { clearState, getUserListRow, handlePasswordConfirmation, toggleEditButton, waitLoading } from './usersUtils'
const admin = new User('admin', 'admin')
-const jdoe = new User('jdoe', 'jdoe')
describe('Settings: Change user properties', function() {
- before(function() {
- cy.createUser(jdoe)
- cy.login(admin)
- // open the User settings
- cy.visit('/settings/users')
- })
+ let user: User
beforeEach(function() {
- // reset to read-only mode: try to find the edit button and click it if set to editing
- getUserListRow(jdoe.userId)
- .find('[data-test-id="cell-actions"]')
- // replace with following (more error resilent) with nextcloud-vue 8
- // find('[data-test-id="button-toggleEdit"][data-test="true"]')
- .find('button[aria-label="Done"]')
- .if()
- .click({ force: true })
- })
-
- after(() => {
- cy.deleteUser(jdoe)
+ clearState()
+ cy.createRandomUser().then(($user) => { user = $user })
+ cy.login(admin)
})
it('Can change the display name', function() {
- // see that the list of users contains the user jdoe
- getUserListRow(jdoe.userId).should('exist')
- // toggle the edit mode for the user jdoe
- .find('[data-test-id="cell-actions"]')
- .find('button[aria-label="Edit"]')
- // replace with following (more error resilent) with nextcloud-vue 8
- // find('[data-test-id="button-toggleEdit"]')
- .click({ force: true })
-
- getUserListRow(jdoe.userId).within(() => {
+ // 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('input[data-test-id="input-displayName"]').should('exist').and('have.value', 'jdoe')
- cy.get('input[data-test-id="input-displayName"]').clear()
- cy.get('input[data-test-id="input-displayName"]').type('John Doe')
- cy.get('input[data-test-id="input-displayName"]').should('have.value', 'John Doe')
- cy.get('input[data-test-id="input-displayName"] ~ button').click()
+ 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
- cy.get('[data-test-id="input-displayName"]').should('have.attr', 'data-test-loading', 'true')
- cy.waitUntil(() => cy.get('[data-test-id="input-displayName"]').should('have.attr', 'data-test-loading', 'false'), { timeout: 10000 })
+ 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() {
- // see that the list of users contains the user jdoe
- getUserListRow(jdoe.userId).should('exist')
- // toggle the edit mode for the user jdoe
- .find('[data-test-id="cell-actions"]')
- .find('button[aria-label="Edit"]')
- // replace with following (more error resilent) with nextcloud-vue 8
- // find('[data-test-id="button-toggleEdit"]')
- .click({ force: true })
-
- getUserListRow(jdoe.userId).within(() => {
- // see that the password of user0 is ""
- cy.get('input[type="password"]').should('exist').and('have.value', '')
- // set the password for user0 to 123456
- cy.get('input[type="password"]').type('123456')
- // When I set the password for user0 to 123456
- cy.get('input[type="password"]').should('have.value', '123456')
- cy.get('input[type="password"] ~ button').click()
+ // 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 user0 is done loading
- cy.get('[data-test-id="input-password"]').should('have.attr', 'data-test-loading', 'true')
- cy.waitUntil(() => cy.get('[data-test-id="input-password"]').should('have.attr', 'data-test-loading', 'false'), { timeout: 10000 })
+ // 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-test-id="input-password"]').should('have.value', '')
+ 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 set manager of a user', function() {
+ // create the manager
+ let manager: User
+ cy.createRandomUser().then(($user) => { manager = $user })
+
+ // open the User settings as admin
+ cy.login(admin)
+ cy.visit('/settings/users')
+
+ // toggle edit button into edit mode
+ toggleEditButton(user, true)
+
+ getUserListRow(user.userId)
+ .find('[data-cy-user-list-cell-manager]')
+ .scrollIntoView()
+
+ getUserListRow(user.userId).find('[data-cy-user-list-cell-manager]').within(() => {
+ // see that the user has no manager
+ cy.get('.vs__selected').should('not.exist')
+ // Open the dropdown menu
+ cy.get('[role="combobox"]').click({ force: true })
+ // select the manager
+ cy.contains('li', manager.userId).click({ force: true })
+
+ // Handle password confirmation on time out
+ handlePasswordConfirmation(admin.password)
+
+ // see that the user has a manager set
+ cy.get('.vs__selected').should('exist').and('contain.text', manager.userId)
+ })
+
+ // see that the changes are loading
+ waitLoading('[data-cy-user-list-input-manager]')
+
+ // finish editing the user
+ toggleEditButton(user, false)
+
+ // validate the manager is set
+ cy.getUserData(user).then(($result) => expect($result.body).to.contain(`<manager>${manager.userId}</manager>`))
+ })
+
+ 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 })
+ // 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)
+ })
+ })
})