test: fix quick search test case

This commit is contained in:
JimmFly 2023-02-06 18:06:30 +08:00
parent dd127bc68d
commit 6bdaee66cf

View File

@ -9,6 +9,7 @@ const openQuickSearchByShortcut = async (page: Page) =>
await withCtrlOrMeta(page, () => page.keyboard.press('k', { delay: 50 }));
async function assertTitleTexts(page: Page, texts: string) {
await page.title();
const actual = await page.evaluate(() => {
const titleElement = <HTMLTextAreaElement>(
document.querySelector('.affine-default-page-block-title')
@ -58,7 +59,7 @@ test.describe('Add new page in quick search', () => {
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
await addNewPage.click();
await page.waitForTimeout(200);
await page.waitForTimeout(300);
await assertTitleTexts(page, '');
});
@ -68,7 +69,7 @@ test.describe('Add new page in quick search', () => {
await page.keyboard.insertText('test123456');
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
await addNewPage.click();
await page.waitForTimeout(200);
await page.waitForTimeout(300);
await assertTitleTexts(page, 'test123456');
});
});
@ -80,10 +81,11 @@ test.describe('Search and select', () => {
await page.keyboard.insertText('test123456');
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
await addNewPage.click();
await page.waitForTimeout(200);
await page.waitForTimeout(300);
await assertTitleTexts(page, 'test123456');
await page.waitForTimeout(100);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
await page.keyboard.type('test123456');
await assertResultList(page, ['test123456']);
await page.keyboard.press('Enter', { delay: 50 });
await assertTitleTexts(page, 'test123456');