Skip to content

Commit 2bb23b2

Browse files
authored
Merge pull request #62283 from nextcloud/test/user-hardcoded
test(users): prevent flaky tests with hardcoded values
2 parents 0bf8efd + abcb09d commit 2bb23b2

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

tests/playwright/e2e/users/users.spec.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ import { handlePasswordConfirmation } from '../../support/utils/password-confirm
1212

1313
test.describe('Settings: Create and delete accounts', () => {
1414
test('can create a user with username and password', async ({ page }) => {
15-
const settingsPage = new SettingsUsersPage(page)
16-
await settingsPage.open()
17-
18-
await settingsPage.openNewUserDialog()
15+
const newUserId = crypto.randomUUID()
16+
try {
17+
const settingsPage = new SettingsUsersPage(page)
18+
await settingsPage.open()
1919

20-
const dialog = settingsPage.newUserDialog()
21-
await dialog.getByLabel(/Account name/).fill('newuser-basic')
22-
await dialog.getByLabel(/Password/).and(page.locator('input')).fill('password123')
20+
await settingsPage.openNewUserDialog()
2321

24-
await dialog.getByRole('button', { name: 'Add new account' }).click()
25-
await handlePasswordConfirmation(page)
26-
await dialog.waitFor({ state: 'hidden' })
22+
const dialog = settingsPage.newUserDialog()
23+
await dialog.getByLabel(/Account name/).fill(newUserId)
24+
await dialog.getByLabel(/Password/).and(page.locator('input')).fill('password123')
2725

28-
await expect(settingsPage.userRow('newuser-basic')).toContainText('newuser-basic')
26+
await dialog.getByRole('button', { name: 'Add new account' }).click()
27+
await handlePasswordConfirmation(page)
28+
await dialog.waitFor({ state: 'hidden' })
2929

30-
await runOcc(['user:delete', 'newuser-basic'])
30+
await expect(settingsPage.userRow(newUserId)).toContainText(newUserId)
31+
} finally {
32+
await runOcc(['user:delete', newUserId], { failOnError: false })
33+
}
3134
})
3235

3336
test('can create a user with display name and email', async ({ page }) => {

0 commit comments

Comments
 (0)