import { expect, test } from '@playwright/test';
import { createDoc, verifyDocName } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test.describe('Document search', () => {
test('it searches documents', async ({ page, browserName }) => {
const [doc1Title] = await createDoc(
page,
'My doc search super',
browserName,
1,
);
await verifyDocName(page, doc1Title);
const [doc2Title] = await createDoc(
'My doc search doc',
await verifyDocName(page, doc2Title);
await page.getByRole('button', { name: 'search' }).click();
await expect(
page.getByRole('img', { name: 'No active search' }),
).toBeVisible();
page.getByLabel('Search modal').getByText('search'),
const inputSearch = page.getByPlaceholder('Type the name of a document');
await inputSearch.click();
await inputSearch.fill('My doc search');
await inputSearch.press('ArrowDown');
const listSearch = page.getByRole('listbox').getByRole('group');
const rowdoc = listSearch.getByRole('option').first();
await expect(rowdoc.getByText('keyboard_return')).toBeVisible();
await expect(rowdoc.getByText(/seconds? ago/)).toBeVisible();
listSearch.getByRole('option').getByText(doc1Title),
listSearch.getByRole('option').getByText(doc2Title),
await inputSearch.fill('My doc search super');
).toBeHidden();