mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
fix: test case (#3686)
This commit is contained in:
@@ -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,39 +115,43 @@ 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 clickSideBarAllPageButton(page);
|
await newPage(page);
|
||||||
await createFirstFilter(page, 'Created');
|
await clickSideBarAllPageButton(page);
|
||||||
await checkFilterName(page, 'after');
|
await waitForAllPagesLoad(page);
|
||||||
// init date
|
const pages = await page.locator('[data-testid="title"]').all();
|
||||||
const yesterday = new Date();
|
const pageCount = pages.length;
|
||||||
yesterday.setDate(yesterday.getDate() - 1);
|
expect(pageCount).not.toBe(0);
|
||||||
await checkDatePicker(page, yesterday);
|
await createFirstFilter(page, 'Created');
|
||||||
await checkPagesCount(page, 1);
|
await checkFilterName(page, 'after');
|
||||||
// change date
|
// init date
|
||||||
const today = new Date();
|
const yesterday = new Date();
|
||||||
await selectDateFromDatePicker(page, today);
|
yesterday.setDate(yesterday.getDate() - 1);
|
||||||
await checkPagesCount(page, 0);
|
await checkDatePicker(page, yesterday);
|
||||||
// change filter
|
await checkPagesCount(page, 1);
|
||||||
await page.locator('[data-testid="filter-name"]').click();
|
// change date
|
||||||
await page
|
const today = new Date();
|
||||||
.locator('[data-testid="filter-name-select"]')
|
await selectDateFromDatePicker(page, today);
|
||||||
.locator('button', { hasText: 'before' })
|
await checkPagesCount(page, 0);
|
||||||
.click();
|
// change filter
|
||||||
const tomorrow = new Date();
|
await page.locator('[data-testid="filter-name"]').click();
|
||||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
await page
|
||||||
await selectDateFromDatePicker(page, tomorrow);
|
.locator('[data-testid="filter-name-select"]')
|
||||||
await checkDatePicker(page, tomorrow);
|
.locator('button', { hasText: 'before' })
|
||||||
await checkPagesCount(page, 1);
|
.click();
|
||||||
}
|
const tomorrow = new Date();
|
||||||
);
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
|
await selectDateFromDatePicker(page, tomorrow);
|
||||||
|
await checkDatePicker(page, tomorrow);
|
||||||
|
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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user