aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfebe <fenn25.fn@gmail.com>2025-05-15 16:45:41 +0100
committernfebe <fenn25.fn@gmail.com>2025-05-22 13:36:32 +0100
commit3e0368e1427245ff7e7d50188ccf393333befca9 (patch)
treee73ed793b9270162f9df832f67a815f18750a83f
parent1301cf5a94d9697da045f5b9177dabb6268cae26 (diff)
downloadnextcloud-server-3e0368e1427245ff7e7d50188ccf393333befca9.tar.gz
nextcloud-server-3e0368e1427245ff7e7d50188ccf393333befca9.zip
test(settings): Test user manager can be set and unset
Signed-off-by: nfebe <fenn25.fn@gmail.com>
-rw-r--r--cypress/e2e/settings/users_manager.cy.ts121
-rw-r--r--cypress/e2e/settings/users_modify.cy.ts41
2 files changed, 121 insertions, 41 deletions
diff --git a/cypress/e2e/settings/users_manager.cy.ts b/cypress/e2e/settings/users_manager.cy.ts
new file mode 100644
index 00000000000..b7596ddf0ce
--- /dev/null
+++ b/cypress/e2e/settings/users_manager.cy.ts
@@ -0,0 +1,121 @@
+/**
+ * SPDX-FileCopyrightText: 2025 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: User Manager Management', function() {
+ let user: User
+ let manager: User
+
+ beforeEach(function() {
+ clearState()
+ cy.createRandomUser().then(($user) => {
+ manager = $user
+ return cy.createRandomUser()
+ }).then(($user) => {
+ user = $user
+ cy.login(admin)
+ cy.intercept('PUT', `/ocs/v2.php/cloud/users/${user.userId}*`).as('updateUser')
+ })
+ })
+
+ it('Can assign and remove a manager through the UI', function() {
+ cy.visit('/settings/users')
+
+ toggleEditButton(user, true)
+
+ // Scroll to manager cell and wait for it to be visible
+ getUserListRow(user.userId)
+ .find('[data-cy-user-list-cell-manager]')
+ .scrollIntoView()
+ .should('be.visible')
+
+ // Assign a manager
+ getUserListRow(user.userId).find('[data-cy-user-list-cell-manager]').within(() => {
+ // Verify no manager is set initially
+ cy.get('.vs__selected').should('not.exist')
+
+ // Open the dropdown menu
+ cy.get('[role="combobox"]').click({ force: true })
+
+ // Wait for the dropdown to be visible and initialized
+ waitLoading('[data-cy-user-list-input-manager]')
+
+ // Type the manager's username to search
+ cy.get('input[type="search"]').type(manager.userId, { force: true })
+
+ // Wait for the search results to load
+ waitLoading('[data-cy-user-list-input-manager]')
+ })
+
+ // Now select the manager from the filtered results
+ // Since the dropdown is floating, we need to search globally
+ cy.get('.vs__dropdown-menu').find('li').contains('span', manager.userId).should('be.visible').click({ force: true })
+
+ // Handle password confirmation if needed
+ handlePasswordConfirmation(admin.password)
+
+ // Verify the manager is selected in the UI
+ cy.get('.vs__selected').should('exist').and('contain.text', manager.userId)
+
+ // Verify the PUT request was made to set the manager
+ cy.wait('@updateUser').then((interception) => {
+ // Verify the request URL and body
+ expect(interception.request.url).to.match(/\/cloud\/users\/.+/)
+ expect(interception.request.body).to.deep.equal({
+ key: 'manager',
+ value: manager.userId
+ })
+ expect(interception.response?.statusCode).to.equal(200)
+ })
+
+ // Wait for the save to complete
+ waitLoading('[data-cy-user-list-input-manager]')
+
+ // Verify the manager is set in the backend
+ cy.getUserData(user).then(($result) => {
+ expect($result.body).to.contain(`<manager>${manager.userId}</manager>`)
+ })
+
+ // Now remove the manager
+ getUserListRow(user.userId).find('[data-cy-user-list-cell-manager]').within(() => {
+ // Clear the manager selection
+ cy.get('.vs__clear').click({ force: true })
+
+ // Verify the manager is cleared in the UI
+ cy.get('.vs__selected').should('not.exist')
+
+ // Handle password confirmation if needed
+ handlePasswordConfirmation(admin.password)
+ })
+
+ // Verify the PUT request was made to clear the manager
+ cy.wait('@updateUser').then((interception) => {
+ // Verify the request URL and body
+ expect(interception.request.url).to.match(/\/cloud\/users\/.+/)
+ expect(interception.request.body).to.deep.equal({
+ key: 'manager',
+ value: '',
+ })
+ expect(interception.response?.statusCode).to.equal(200)
+ })
+
+ // Wait for the save to complete
+ waitLoading('[data-cy-user-list-input-manager]')
+
+ // Verify the manager is cleared in the backend
+ cy.getUserData(user).then(($result) => {
+ expect($result.body).to.not.contain(`<manager>${manager.userId}</manager>`)
+ expect($result.body).to.contain('<manager></manager>')
+ })
+
+ // Finish editing the user
+ toggleEditButton(user, false)
+ })
+})
diff --git a/cypress/e2e/settings/users_modify.cy.ts b/cypress/e2e/settings/users_modify.cy.ts
index d4948cb3d53..749bded2e94 100644
--- a/cypress/e2e/settings/users_modify.cy.ts
+++ b/cypress/e2e/settings/users_modify.cy.ts
@@ -181,47 +181,6 @@ describe('Settings: Change user properties', function() {
})
})
- 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'