mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 13:38:49 +08:00
test: update test case for quick search
This commit is contained in:
@@ -15,7 +15,7 @@ async function assertTitleTexts(
|
|||||||
texts: string[],
|
texts: string[],
|
||||||
option?: { delay: number }
|
option?: { delay: number }
|
||||||
) {
|
) {
|
||||||
await page.mouse.move(100, 100); // move mouse for focus
|
await page.mouse.move(100, 100);
|
||||||
const actual = await page
|
const actual = await page
|
||||||
.locator('[class=affine-default-page-block-title]')
|
.locator('[class=affine-default-page-block-title]')
|
||||||
.allInnerTexts();
|
.allInnerTexts();
|
||||||
@@ -23,6 +23,17 @@ async function assertTitleTexts(
|
|||||||
expect(actual).toEqual(texts);
|
expect(actual).toEqual(texts);
|
||||||
}, option?.delay);
|
}, option?.delay);
|
||||||
}
|
}
|
||||||
|
async function assertResultList(
|
||||||
|
page: Page,
|
||||||
|
texts: string[],
|
||||||
|
option?: { delay: number }
|
||||||
|
) {
|
||||||
|
await page.mouse.move(100, 100);
|
||||||
|
const actual = await page.locator('[cmdk-item]').allInnerTexts();
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(actual).toEqual(texts);
|
||||||
|
}, option?.delay);
|
||||||
|
}
|
||||||
|
|
||||||
test.describe('Open quick search', () => {
|
test.describe('Open quick search', () => {
|
||||||
test('Click slider bar button', async ({ page }) => {
|
test('Click slider bar button', async ({ page }) => {
|
||||||
@@ -31,7 +42,7 @@ test.describe('Open quick search', () => {
|
|||||||
);
|
);
|
||||||
await quickSearchButton.click();
|
await quickSearchButton.click();
|
||||||
const quickSearch = page.locator('[data-testid=quickSearch]');
|
const quickSearch = page.locator('[data-testid=quickSearch]');
|
||||||
expect(quickSearch.isVisible()).toEqual(true);
|
await expect(quickSearch).toBeVisible();
|
||||||
});
|
});
|
||||||
test('Click arrowDown icon after title', async ({ page }) => {
|
test('Click arrowDown icon after title', async ({ page }) => {
|
||||||
//header-quickSearchButton
|
//header-quickSearchButton
|
||||||
@@ -40,12 +51,12 @@ test.describe('Open quick search', () => {
|
|||||||
);
|
);
|
||||||
await quickSearchButton.click();
|
await quickSearchButton.click();
|
||||||
const quickSearch = page.locator('[data-testid=quickSearch]');
|
const quickSearch = page.locator('[data-testid=quickSearch]');
|
||||||
expect(quickSearch.isVisible()).toEqual(true);
|
await expect(quickSearch).toBeVisible();
|
||||||
});
|
});
|
||||||
test('Press the shortcut key cmd+k', async ({ page }) => {
|
test('Press the shortcut key cmd+k', async ({ page }) => {
|
||||||
await openQuickSearchByShortcut(page);
|
await openQuickSearchByShortcut(page);
|
||||||
const quickSearch = page.locator('[data-testid=quickSearch]');
|
const quickSearch = page.locator('[data-testid=quickSearch]');
|
||||||
expect(quickSearch.isVisible()).toEqual(true);
|
await expect(quickSearch).toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,3 +75,28 @@ test.describe('Add new page in quick search', () => {
|
|||||||
await assertTitleTexts(page, ['test'], { delay: 50 });
|
await assertTitleTexts(page, ['test'], { delay: 50 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.describe('Search and select', () => {
|
||||||
|
test('Search and get results', async ({ page }) => {
|
||||||
|
await openQuickSearchByShortcut(page);
|
||||||
|
await page.keyboard.insertText('Welcome');
|
||||||
|
await assertResultList(page, ['Welcome to the AFFiNE Alpha'], {
|
||||||
|
delay: 50,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('Create a new page and search this page', async ({ page }) => {
|
||||||
|
await openQuickSearchByShortcut(page);
|
||||||
|
await page.keyboard.insertText('Welcome');
|
||||||
|
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
|
||||||
|
await addNewPage.click();
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
await openQuickSearchByShortcut(page);
|
||||||
|
await page.keyboard.insertText('Welcome');
|
||||||
|
await assertResultList(page, ['Welcome to the AFFiNE Alpha', 'Welcome']);
|
||||||
|
await page.keyboard.press('ArrowDown', { delay: 50 });
|
||||||
|
await page.keyboard.press('Enter', { delay: 50 });
|
||||||
|
await assertTitleTexts(page, ['Welcome'], {
|
||||||
|
delay: 50,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user