fix: test case (#3686)

This commit is contained in:
JimmFly
2023-08-11 14:59:06 +08:00
committed by GitHub
parent 4834f99da9
commit f0cbbc3a84
4 changed files with 66 additions and 38 deletions

View File

@@ -16,7 +16,9 @@ import {
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitEditorLoad, waitEditorLoad,
waitForAllPagesLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar'; import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
@@ -83,10 +85,15 @@ test('allow creation of filters by favorite', async ({ page }) => {
).toBe('false'); ).toBe('false');
}); });
test.fixme('allow creation of filters by created time', async ({ page }) => { test('allow creation of filters by created time', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitEditorLoad(page);
await newPage(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page);
const pages = await page.locator('[data-testid="title"]').all();
const pageCount = pages.length;
expect(pageCount).not.toBe(0);
await createFirstFilter(page, 'Created'); await createFirstFilter(page, 'Created');
await checkFilterName(page, 'after'); await checkFilterName(page, 'after');
// init date // init date
@@ -108,15 +115,20 @@ test.fixme('allow creation of filters by created time', async ({ page }) => {
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
await fillDatePicker(page, tomorrow); await fillDatePicker(page, tomorrow);
await checkDatePicker(page, tomorrow); await checkDatePicker(page, tomorrow);
await checkPagesCount(page, 1); await checkPagesCount(page, pageCount);
}); });
test.fixme( test('creation of filters by created time, then click date picker to modify the date', async ({
'creation of filters by created time, then click date picker to modify the date', page,
async ({ page }) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitEditorLoad(page);
await newPage(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page);
const pages = await page.locator('[data-testid="title"]').all();
const pageCount = pages.length;
expect(pageCount).not.toBe(0);
await createFirstFilter(page, 'Created'); await createFirstFilter(page, 'Created');
await checkFilterName(page, 'after'); await checkFilterName(page, 'after');
// init date // init date
@@ -138,9 +150,8 @@ test.fixme(
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
await selectDateFromDatePicker(page, tomorrow); await selectDateFromDatePicker(page, tomorrow);
await checkDatePicker(page, tomorrow); await checkDatePicker(page, tomorrow);
await checkPagesCount(page, 1); await checkPagesCount(page, pageCount);
} });
);
test('use monthpicker to modify the month of datepicker', async ({ page }) => { test('use monthpicker to modify the month of datepicker', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
@@ -166,20 +177,30 @@ test('use monthpicker to modify the month of datepicker', async ({ page }) => {
await checkDatePickerMonth(page, nextMonth); await checkDatePickerMonth(page, nextMonth);
}); });
test.fixme('allow creation of filters by tags', async ({ page }) => { test('allow creation of filters by tags', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitEditorLoad(page);
await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page);
const pages = await page.locator('[data-testid="title"]').all();
const pageCount = pages.length;
expect(pageCount).not.toBe(0);
await createFirstFilter(page, 'Tags');
await checkFilterName(page, 'is not empty');
const pagesWithTags = await page.locator('[data-testid="title"]').all();
const pagesWithTagsCount = pagesWithTags.length;
expect(pagesWithTagsCount).not.toBe(0);
await createPageWithTag(page, { title: 'Page A', tags: ['A'] }); await createPageWithTag(page, { title: 'Page A', tags: ['A'] });
await createPageWithTag(page, { title: 'Page B', tags: ['B'] }); await createPageWithTag(page, { title: 'Page B', tags: ['B'] });
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await createFirstFilter(page, 'Tags'); await createFirstFilter(page, 'Tags');
await checkFilterName(page, 'is not empty'); await checkFilterName(page, 'is not empty');
await checkPagesCount(page, 2); await checkPagesCount(page, pagesWithTagsCount + 2);
await changeFilter(page, /^contains all/); await changeFilter(page, /^contains all/);
await checkPagesCount(page, 3); await checkPagesCount(page, pageCount + 2);
await selectTag(page, 'A'); await selectTag(page, 'A');
await checkPagesCount(page, 1); await checkPagesCount(page, 1);
await changeFilter(page, /^does not contains all/); await changeFilter(page, /^does not contains all/);
await selectTag(page, 'B'); await selectTag(page, 'B');
await checkPagesCount(page, 2); await checkPagesCount(page, pageCount + 1);
}); });

View File

@@ -43,7 +43,7 @@ const createAndPinCollection = async (
await page.waitForTimeout(100); await page.waitForTimeout(100);
}; };
test.fixme('Show collections items in sidebar', async ({ page }) => { test('Show collections items in sidebar', async ({ page }) => {
await createAndPinCollection(page); await createAndPinCollection(page);
const collections = page.getByTestId('collections'); const collections = page.getByTestId('collections');
const items = collections.getByTestId('collection-item'); const items = collections.getByTestId('collection-item');

View File

@@ -213,7 +213,7 @@ export async function selectTag(page: Page, name: string | RegExp) {
await page await page
.getByTestId('multi-select') .getByTestId('multi-select')
.getByTestId('select-option') .getByTestId('select-option')
.getByText(name) .getByText(name, { exact: true })
.click(); .click();
await page.getByTestId('filter-arg').click(); await page.getByTestId('filter-arg').click();
} }

View File

@@ -7,6 +7,13 @@ export async function waitEditorLoad(page: Page) {
}); });
} }
export async function waitForAllPagesLoad(page: Page) {
// if filters tag is rendered, we believe all_pages is ready
await page.waitForSelector('[data-testid="create-first-filter"]', {
timeout: 1000,
});
}
export async function newPage(page: Page) { export async function newPage(page: Page) {
// fixme(himself65): if too fast, the page will crash // fixme(himself65): if too fast, the page will crash
await page.getByTestId('new-page-button').click({ await page.getByTestId('new-page-button').click({