Files
cinny/e2e/settings-search.spec.ts
T

52 lines
2.2 KiB
TypeScript
Raw Normal View History

import { test, expect } from '@playwright/test';
import { ensureUser, hsReachable, loginUI, uniq } from './localHs';
// [Gitea #463] Search across all settings.
test.describe('settings search (#463)', () => {
test.beforeAll(async () => {
test.skip(!(await hsReachable()), 'local homeserver not running');
});
test('finds a setting, opens its page and shows it', async ({ page }) => {
test.setTimeout(120_000);
const user = await ensureUser(uniq('ss'));
await loginUI(page, user);
await page.getByRole('button', { name: 'User Settings' }).click();
const dialog = page.getByRole('dialog').first();
const box = dialog.getByRole('textbox', { name: 'Search settings' });
// Ctrl+F focuses the box while settings are open (after the dialog has
// placed its own initial focus).
await expect(box).toBeVisible();
await page.waitForTimeout(800);
await page.keyboard.press('ControlOrMeta+f');
await expect(box).toBeFocused();
await box.fill('deafen');
const results = dialog.getByRole('list', { name: 'Matching settings' });
const first = results.getByRole('listitem').first();
await expect(first).toContainText('Push to deafen');
await expect(first).toContainText('Calls & audio');
await expect(dialog.getByRole('navigation', { name: 'Settings sections' })).toBeHidden();
await first.click();
await expect(dialog.getByText('Calls & audio', { exact: true }).last()).toBeVisible();
await expect(dialog.getByText('Push to deafen', { exact: true })).toBeInViewport();
await expect(dialog.getByRole('navigation', { name: 'Settings sections' })).toBeVisible();
// A description word finds it too; Enter picks the top result.
await box.fill('utm');
await expect(results.getByRole('listitem').first()).toContainText(
'Strip tracking parameters from links',
);
await box.press('Enter');
await expect(dialog.getByText('Strip tracking parameters from links')).toBeInViewport();
// No match, then Esc clears.
await box.fill('zzzz-nothing');
await expect(dialog.getByText(/No settings match/)).toBeVisible();
await box.press('Escape');
await expect(box).toHaveValue('');
await expect(dialog).toBeVisible();
});
});