-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(settings): Send update request when clearing user manager #52833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0323242
fix(settings): Send update request when clearing user manager
nfebe fad3537
fix: correctly unset account manager
susnux 1301cf5
fix(settings): Prevent double request on manager change
nfebe 3e0368e
test(settings): Test user manager can be set and unset
nfebe 3495fb7
chore(assets): Recompile assets
nextcloud-command File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.