Skip to content

Commit 08cc94b

Browse files
committed
test(settings): adjust tests for new profile user settings
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 094030a commit 08cc94b

7 files changed

Lines changed: 799 additions & 280 deletions

File tree

tests/playwright/e2e/settings/access-levels.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ userTest.describe('Settings: Access levels – regular user', () => {
1818

1919
const appNavigation = page.locator('#app-navigation-vue')
2020
await expect(appNavigation.getByRole('list', { name: 'Personal' })).toBeVisible()
21-
await expect(appNavigation.getByRole('link', { name: /Personal info/i })).toBeVisible()
21+
await expect(appNavigation.getByRole('link', { name: 'Profile & contact' })).toBeVisible()
2222
// Regular users must not see the Administration section
2323
await expect(appNavigation.getByRole('list', { name: 'Administration' })).toHaveCount(0)
2424
})
@@ -34,7 +34,7 @@ adminTest.describe('Settings: Access levels – admin user', () => {
3434

3535
const appNavigation = page.locator('#app-navigation-vue')
3636
await expect(appNavigation.getByRole('list', { name: 'Personal' })).toBeVisible()
37-
await expect(appNavigation.getByRole('link', { name: /Personal info/i })).toBeVisible()
37+
await expect(appNavigation.getByRole('link', { name: 'Profile & contact' })).toBeVisible()
3838
// Admins must see the Administration section
3939
await expect(appNavigation.getByRole('list', { name: 'Administration' })).toBeVisible()
4040
await expect(appNavigation.getByRole('link', { name: /Overview/i })).toBeVisible()

tests/playwright/e2e/settings/personal-info.spec.ts

Lines changed: 219 additions & 278 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { runOcc } from '@nextcloud/e2e-test-server/docker'
7+
import { LanguageLocaleSettingsPage } from '../sections/LanguageLocaleSettingsPage.ts'
8+
import { ProfileContactSettingsPage } from '../sections/ProfileContactSettingsPage.ts'
9+
import { test as userSessionTest } from './random-user-session.ts'
10+
11+
/**
12+
* Extends the random user session with the personal settings page objects.
13+
* The user language and locale are pinned to English so that assertions on
14+
* rendered strings are stable.
15+
*/
16+
export const test = userSessionTest.extend<{
17+
profileContactPage: ProfileContactSettingsPage
18+
languageLocalePage: LanguageLocaleSettingsPage
19+
}>({
20+
user: async ({ user: baseUser }, use) => {
21+
await runOcc(['user:setting', baseUser.userId, 'core', 'lang', 'en'])
22+
await runOcc(['user:setting', baseUser.userId, 'core', 'locale', 'en_US'])
23+
await use(baseUser)
24+
},
25+
26+
profileContactPage: async ({ page, user }, use) => {
27+
await use(new ProfileContactSettingsPage(page, user))
28+
},
29+
30+
languageLocalePage: async ({ page, user }, use) => {
31+
await use(new LanguageLocaleSettingsPage(page, user))
32+
},
33+
})
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import type { User } from '@nextcloud/e2e-test-server'
7+
import type { Locator, Page } from '@playwright/test'
8+
9+
import { expect } from '@playwright/test'
10+
import { saveAccountProperty } from '../utils/account-properties.ts'
11+
import { expectSelectedOption, pickSelectOption } from '../utils/select.ts'
12+
13+
/**
14+
* Page object for the personal "Language & locale" settings section.
15+
*
16+
* Saving the language or the locale reloads the page, so the result of such a
17+
* change is asserted on the reloaded page.
18+
*/
19+
export class LanguageLocaleSettingsPage {
20+
constructor(
21+
private readonly page: Page,
22+
private readonly user: User,
23+
) {}
24+
25+
async open(): Promise<void> {
26+
await this.page.goto('settings/user/language-locale')
27+
await expect(this.page.getByRole('heading', { name: 'Language & locale', level: 2 })).toBeVisible()
28+
}
29+
30+
languageSelect(): Locator {
31+
return this.page.getByRole('combobox', { name: 'Language' })
32+
}
33+
34+
localeSelect(): Locator {
35+
return this.page.getByRole('combobox', { name: 'Locale' })
36+
}
37+
38+
firstDayOfWeekSelect(): Locator {
39+
return this.page.getByRole('combobox', { name: 'First day of week' })
40+
}
41+
42+
/** Date and time as rendered in the currently selected locale */
43+
localeExample(): Locator {
44+
return this.page.getByText('Example:')
45+
}
46+
47+
/**
48+
* Select a language, which reloads the page in that language.
49+
*
50+
* @param language - Name of the language, as listed in the select
51+
* @param search - Search term to filter the languages with
52+
*/
53+
async selectLanguage(language: string, search: string): Promise<void> {
54+
await this.selectOption(this.languageSelect(), language, search)
55+
}
56+
57+
/**
58+
* Select a locale, which reloads the page using that locale.
59+
*
60+
* @param locale - Name of the locale, as listed in the select
61+
* @param search - Search term to filter the locales with
62+
*/
63+
async selectLocale(locale: string, search: string): Promise<void> {
64+
await this.selectOption(this.localeSelect(), locale, search)
65+
}
66+
67+
/**
68+
* Select the day to use as the first day of week and wait for it to be persisted.
69+
*
70+
* @param day - Name of the day, as listed in the select
71+
*/
72+
async selectFirstDayOfWeek(day: string): Promise<void> {
73+
await saveAccountProperty(this.page, this.user.password, () => pickSelectOption(this.page, this.firstDayOfWeekSelect(), day))
74+
}
75+
76+
/**
77+
* Assert the option a select currently has selected.
78+
*
79+
* @param select - The select to read, see `languageSelect` and friends
80+
* @param value - Text of the expected option
81+
*/
82+
async expectSelected(select: Locator, value: string | RegExp): Promise<void> {
83+
await expectSelectedOption(this.page, select, value)
84+
}
85+
86+
private async selectOption(select: Locator, option: string, search?: string): Promise<void> {
87+
await pickSelectOption(this.page, select, option, search)
88+
}
89+
}

0 commit comments

Comments
 (0)