mirror of
https://github.com/nextcloud/server.git
synced 2026-10-20 07:19:44 +02: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>
77 lines
2.7 KiB
TypeScript
77 lines
2.7 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import { runOcc } from '@nextcloud/e2e-test-server/docker'
|
|
import { createRandomUser } from '@nextcloud/e2e-test-server/playwright'
|
|
import { expect } from '@playwright/test'
|
|
import { test } from '../../support/fixtures/admin-session.ts'
|
|
import { SettingsUsersPage } from '../../support/sections/SettingsUsersPage.ts'
|
|
|
|
test.describe('Settings: Create and delete accounts', () => {
|
|
test('can create a user with username and password', async ({ page }) => {
|
|
const newUserId = crypto.randomUUID()
|
|
try {
|
|
const settingsPage = new SettingsUsersPage(page)
|
|
await settingsPage.open()
|
|
|
|
await settingsPage.openNewUserDialog()
|
|
|
|
const dialog = settingsPage.newUserDialog()
|
|
await dialog.getByLabel(/Account name/).fill(newUserId)
|
|
await dialog.getByLabel(/Password/).and(page.locator('input')).fill('password123')
|
|
|
|
await dialog.getByRole('button', { name: 'Add new account' }).click()
|
|
await expect(dialog).toBeHidden({ timeout: 30_000 })
|
|
|
|
await expect(settingsPage.userRow(newUserId)).toContainText(newUserId)
|
|
} finally {
|
|
await runOcc(['user:delete', newUserId], { failOnError: false })
|
|
}
|
|
})
|
|
|
|
test('can create a user with display name and email', async ({ page }) => {
|
|
const newUserId = crypto.randomUUID()
|
|
try {
|
|
const settingsPage = new SettingsUsersPage(page)
|
|
await settingsPage.open()
|
|
|
|
await settingsPage.openNewUserDialog()
|
|
|
|
const dialog = settingsPage.newUserDialog()
|
|
await dialog.getByLabel(/Account name/).fill(newUserId)
|
|
await dialog.getByLabel('Display name').fill('John Smith')
|
|
await dialog.getByLabel(/Email/).fill('john@example.org')
|
|
await dialog.getByLabel(/Password/).and(page.locator('input')).fill('password123')
|
|
|
|
await dialog.getByRole('button', { name: 'Add new account' }).click()
|
|
await expect(dialog).toBeHidden({ timeout: 30_000 })
|
|
|
|
await expect(settingsPage.userRow(newUserId)).toContainText(newUserId)
|
|
} finally {
|
|
await runOcc(['user:delete', newUserId])
|
|
}
|
|
})
|
|
|
|
test('can delete a user', async ({ page }) => {
|
|
const testUser = await createRandomUser()
|
|
const settingsPage = new SettingsUsersPage(page)
|
|
|
|
try {
|
|
await settingsPage.open()
|
|
await expect(settingsPage.userRow(testUser.userId)).toBeVisible()
|
|
|
|
await settingsPage.openActionsMenu(testUser.userId)
|
|
await page.getByRole('menuitem', { name: 'Delete account' }).click()
|
|
|
|
// Confirm the deletion in the confirmation dialog
|
|
await page.getByRole('dialog').getByRole('button', { name: `Delete ${testUser.userId}` }).click()
|
|
|
|
await expect(settingsPage.userRow(testUser.userId)).toHaveCount(0)
|
|
} finally {
|
|
await runOcc(['user:delete', testUser.userId]).catch(() => {})
|
|
}
|
|
})
|
|
})
|