mirror of
https://github.com/nextcloud/server.git
synced 2026-10-31 18:15:57 +01:00
The dialog only appears once a session's confirmation window has expired, so the old helper probed for it for 500 ms and silently skipped it on a slow shard, leaving the guarded request unsent; its wait for the dialog to close was unbounded. Install a locator handler per logged-in page instead, and use awaitPasswordGuardedRequest() where a response promise is awaited, since handlers never run during a bare waitForResponse. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
80 lines
2.6 KiB
TypeScript
80 lines
2.6 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import type { User } from '@nextcloud/e2e-test-server'
|
|
|
|
import { runOcc } from '@nextcloud/e2e-test-server/docker'
|
|
import { createRandomUser } from '@nextcloud/e2e-test-server/playwright'
|
|
import { expect } from '@playwright/test'
|
|
import { test as adminUserTest } from '../../support/fixtures/admin-with-user.ts'
|
|
import { SettingsUsersPage } from '../../support/sections/SettingsUsersPage.ts'
|
|
import { getToast } from '../../support/utils/toast.ts'
|
|
|
|
const test = adminUserTest.extend<{ manager: User }>({
|
|
manager: async ({}, use) => {
|
|
const manager = await createRandomUser()
|
|
await use(manager)
|
|
await runOcc(['user:delete', manager.userId]).catch(() => {})
|
|
},
|
|
})
|
|
|
|
test.describe('Settings: User Manager Management', () => {
|
|
test('can assign a manager through the edit dialog', async ({ page, user, manager }) => {
|
|
const settingsPage = new SettingsUsersPage(page)
|
|
await settingsPage.open()
|
|
|
|
await settingsPage.openEditDialog(user.userId)
|
|
const dialog = settingsPage.editUserDialog()
|
|
|
|
const managerCombobox = dialog.getByRole('combobox', { name: /Manager/i })
|
|
await managerCombobox.fill(manager.userId)
|
|
await page.getByRole('option', { name: manager.userId }).click()
|
|
|
|
await settingsPage.saveEditDialog()
|
|
|
|
await expect(getToast(page, /Account updated/i)).toBeVisible()
|
|
|
|
// Verify via OCS API (page shares admin auth cookies)
|
|
const response = await page.request.get(
|
|
`/ocs/v2.php/cloud/users/${user.userId}`,
|
|
{ headers: { 'OCS-APIRequest': 'true', Accept: 'application/json' } },
|
|
)
|
|
const data = await response.json()
|
|
expect(data?.ocs?.data?.manager).toBe(manager.userId)
|
|
})
|
|
|
|
test('can remove a manager through the edit dialog', async ({ page, user, manager }) => {
|
|
// Set manager via OCC first
|
|
await runOcc([
|
|
'user:setting',
|
|
user.userId,
|
|
'settings',
|
|
'manager',
|
|
`["${manager.userId}"]`,
|
|
])
|
|
|
|
const settingsPage = new SettingsUsersPage(page)
|
|
await settingsPage.open()
|
|
|
|
await settingsPage.openEditDialog(user.userId)
|
|
const dialog = settingsPage.editUserDialog()
|
|
|
|
// Clear the currently-set manager using the NcSelect's clear button
|
|
await dialog.getByRole('button', { name: /Clear Selected/i }).click()
|
|
|
|
await settingsPage.saveEditDialog()
|
|
|
|
await expect(getToast(page, /Account updated/i)).toBeVisible()
|
|
|
|
// Verify backend: manager must be empty
|
|
const response = await page.request.get(
|
|
`/ocs/v2.php/cloud/users/${user.userId}`,
|
|
{ headers: { 'OCS-APIRequest': 'true', Accept: 'application/json' } },
|
|
)
|
|
const data = await response.json()
|
|
expect(data?.ocs?.data?.manager).toBeFalsy()
|
|
})
|
|
})
|