mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-03-12 00:12:37 +01:00
The main change here is to use `datalist` for pronouns This supports (see also docs[1]): * Displaying the value already set by the user (if any), otherwise * Presenting a list of common options to the user, and * Allowing them to freely enter any value This setup requires no additional JS and resolves[2]. This is different from the previous flow which used, if JS was available: * A menu for a default 'recognised' set of pronouns, and if the user wanted another value: * An extra text div if the user wanted to enter custom pronouns Without JS enabled both the menu and the custom text div would always be displayed. This change means there's no longer a distinction between 'custom' and 'recognised' pronouns (this difference looks to have only been made in code, and not in any data models). Link: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist [1] Link: https://codeberg.org/forgejo/forgejo/issues/6774 [2] Co-authored-by: Matthew Hughes <matthewhughes934@gmail.com> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6835 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: mhughes9 <mhughes9@noreply.codeberg.org> Co-committed-by: mhughes9 <mhughes9@noreply.codeberg.org>
80 lines
3.7 KiB
TypeScript
80 lines
3.7 KiB
TypeScript
// @watch start
|
||
// templates/user/settings/**.tmpl
|
||
// web_src/css/{form,user}.css
|
||
// @watch end
|
||
|
||
import {expect} from '@playwright/test';
|
||
import {test, save_visual, login_user, login} from './utils_e2e.ts';
|
||
import {validate_form} from './shared/forms.ts';
|
||
|
||
test.beforeAll(async ({browser}, workerInfo) => {
|
||
await login_user(browser, workerInfo, 'user2');
|
||
});
|
||
|
||
test('User: Profile settings', async ({browser}, workerInfo) => {
|
||
const page = await login({browser}, workerInfo);
|
||
await page.goto('/user/settings');
|
||
|
||
await page.getByLabel('Full name').fill('SecondUser');
|
||
|
||
const pronounsInput = page.locator('input[list="pronouns"]');
|
||
await expect(pronounsInput).toHaveAttribute('placeholder', 'Unspecified');
|
||
await pronounsInput.click();
|
||
const pronounsList = page.locator('datalist#pronouns');
|
||
const pronounsOptions = pronounsList.locator('option');
|
||
const pronounsValues = await pronounsOptions.evaluateAll((opts) => opts.map((opt) => opt.value));
|
||
expect(pronounsValues).toEqual(['he/him', 'she/her', 'they/them', 'it/its', 'any pronouns']);
|
||
await pronounsInput.fill('she/her');
|
||
|
||
await page.getByPlaceholder('Tell others a little bit').fill('I am a playwright test running for several seconds.');
|
||
await page.getByPlaceholder('Tell others a little bit').press('Tab');
|
||
await page.getByLabel('Website').fill('https://forgejo.org');
|
||
await page.getByPlaceholder('Share your approximate').fill('on a computer chip');
|
||
await page.getByLabel('User visibility').click();
|
||
await page.getByLabel('Visible only to signed-in').click();
|
||
await page.getByLabel('Hide email address Your email').uncheck();
|
||
await page.getByLabel('Hide activity from profile').check();
|
||
|
||
await validate_form({page}, 'fieldset');
|
||
await save_visual(page);
|
||
await page.getByRole('button', {name: 'Update profile'}).click();
|
||
await expect(page.getByText('Your profile has been updated.')).toBeVisible();
|
||
await page.getByRole('link', {name: 'public activity'}).click();
|
||
await expect(page.getByText('Your activity is only visible')).toBeVisible();
|
||
await save_visual(page);
|
||
|
||
await page.goto('/user2');
|
||
await expect(page.getByText('SecondUser')).toBeVisible();
|
||
await expect(page.getByText('on a computer chip')).toBeVisible();
|
||
await expect(page.locator('li').filter({hasText: 'user2@example.com'})).toBeVisible();
|
||
await expect(page.locator('li').filter({hasText: 'https://forgejo.org'})).toBeVisible();
|
||
await expect(page.getByText('I am a playwright test')).toBeVisible();
|
||
await save_visual(page);
|
||
|
||
await page.goto('/user/settings');
|
||
await page.locator('input[list="pronouns"]').fill('rob/ot');
|
||
await page.getByLabel('User visibility').click();
|
||
await page.getByLabel('Visible to everyone').click();
|
||
await page.getByLabel('Hide email address Your email').check();
|
||
await page.getByLabel('Hide activity from profile').uncheck();
|
||
await expect(page.getByText('Your profile has been updated.')).toBeHidden();
|
||
await validate_form({page}, 'fieldset');
|
||
await save_visual(page);
|
||
await page.getByRole('button', {name: 'Update profile'}).click();
|
||
await expect(page.getByText('Your profile has been updated.')).toBeVisible();
|
||
|
||
await page.goto('/user2');
|
||
await expect(page.getByText('SecondUser')).toBeVisible();
|
||
await expect(page.locator('li').filter({hasText: 'user2@example.com'})).toBeHidden();
|
||
await page.goto('/user2?tab=activity');
|
||
await expect(page.getByText('Your activity is visible to everyone')).toBeVisible();
|
||
});
|
||
|
||
test('User: Storage overview', async ({browser}, workerInfo) => {
|
||
const page = await login({browser}, workerInfo);
|
||
await page.goto('/user/settings/storage_overview');
|
||
await page.waitForLoadState();
|
||
await page.getByLabel('Git LFS – 8 KiB').nth(1).hover({position: {x: 250, y: 2}});
|
||
await expect(page.getByText('Git LFS')).toBeVisible();
|
||
await save_visual(page);
|
||
});
|