Skip to content

Commit cad9a23

Browse files
NikolausDemmelnextcloud-command
authored andcommitted
test(settings): Add regression test for group display names
Add Cypress E2E test to verify that group display names are shown correctly in the user editor, even when the group ID differs from the display name (e.g., when long group names get hashed). The test creates a group with a very long name to trigger Nextcloud's ID hashing behavior, assigns a user to that group, then verifies that after a page reload the display name is shown instead of the hash ID. Related to #55785 Signed-off-by: Claude <noreply@anthropic.com> Co-Authored-By: Nikolaus Demmel <nikolaus@nikolaus-demmel.de> Signed-off-by: Nikolaus Demmel <nikolaus@nikolaus-demmel.de>
1 parent fafc93c commit cad9a23

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*
5+
* Regression test for: https://github.com/nextcloud/server/issues/55785
6+
*
7+
* Tests that group display names are shown correctly in the user editor,
8+
* even when the group ID differs from the display name (e.g., when long
9+
* group names get hashed to create the group ID).
10+
*/
11+
12+
import { User } from '@nextcloud/cypress'
13+
import { getUserListRow, handlePasswordConfirmation, toggleEditButton } from './usersUtils'
14+
15+
// eslint-disable-next-line n/no-extraneous-import
16+
import randomString from 'crypto-random-string'
17+
18+
const admin = new User('admin', 'admin')
19+
20+
describe('Settings: Group names persist after reload (issue #55785)', () => {
21+
let testUser: User
22+
// Use a very long name to ensure Nextcloud hashes it to create the group ID.
23+
// This creates a test case where group ID !== group display name.
24+
const randomPart = randomString(80)
25+
const groupName = `Test Group with Very Long Name ${randomPart}`
26+
27+
before(() => {
28+
cy.createRandomUser().then((user) => {
29+
testUser = user
30+
})
31+
cy.runOccCommand(`group:add '${groupName}'`).then(() => {
32+
// Verify that the group ID is different from the display name
33+
// (this confirms our test case is valid)
34+
cy.runOccCommand('group:list --output=json').then((result) => {
35+
const groups = JSON.parse(result.stdout)
36+
const groupEntry = Object.entries(groups).find(([, displayName]) =>
37+
(displayName as string).includes(randomPart)
38+
)
39+
if (groupEntry) {
40+
const [groupId, displayName] = groupEntry
41+
cy.log(`Group ID: ${groupId}`)
42+
cy.log(`Display name: ${displayName}`)
43+
// Assert that ID and name are different (this is what triggers the bug)
44+
expect(groupId).to.not.equal(displayName)
45+
}
46+
})
47+
})
48+
cy.login(admin)
49+
cy.intercept('GET', '**/ocs/v2.php/cloud/groups/details?search=&offset=*&limit=*').as('loadGroups')
50+
cy.visit('/settings/users')
51+
cy.wait('@loadGroups')
52+
})
53+
54+
it('Assign user to group', () => {
55+
toggleEditButton(testUser)
56+
57+
getUserListRow(testUser.userId)
58+
.find('[data-cy-user-list-input-groups] input')
59+
.click({ force: true })
60+
61+
getUserListRow(testUser.userId)
62+
.find('[data-cy-user-list-input-groups] input')
63+
.type(randomPart.slice(0, 10))
64+
65+
cy.contains('li.vs__dropdown-option', groupName)
66+
.should('exist')
67+
.click({ force: true })
68+
69+
handlePasswordConfirmation(admin.password)
70+
71+
toggleEditButton(testUser, false)
72+
})
73+
74+
it('After page reload, selected group still shows correct name', () => {
75+
// Visit the users page again to simulate a fresh page load
76+
cy.visit('/settings/users')
77+
78+
toggleEditButton(testUser)
79+
80+
// Verify the selected group displays the name, not the hashed ID
81+
getUserListRow(testUser.userId)
82+
.find('[data-cy-user-list-input-groups]')
83+
.should('exist')
84+
.within(() => {
85+
cy.get('.vs__selected').invoke('text').then((displayedText) => {
86+
expect(displayedText.trim()).to.include('Test Group with Very Long Name')
87+
})
88+
})
89+
90+
toggleEditButton(testUser, false)
91+
})
92+
})

0 commit comments

Comments
 (0)