2023-05-12 04:51:13 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-07-06 09:17:19 +03:00
|
|
|
import {
|
|
|
|
changeFilter,
|
|
|
|
checkDatePicker,
|
|
|
|
checkDatePickerMonth,
|
|
|
|
checkFilterName,
|
|
|
|
checkPagesCount,
|
|
|
|
clickDatePicker,
|
|
|
|
createFirstFilter,
|
|
|
|
createPageWithTag,
|
|
|
|
fillDatePicker,
|
|
|
|
selectDateFromDatePicker,
|
|
|
|
selectMonthFromMonthPicker,
|
|
|
|
selectTag,
|
2023-07-13 12:05:01 +03:00
|
|
|
} from '@affine-test/kit/utils/filter';
|
|
|
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
2023-06-30 08:40:00 +03:00
|
|
|
import {
|
|
|
|
getBlockSuiteEditorTitle,
|
2023-08-11 09:59:06 +03:00
|
|
|
newPage,
|
2023-06-30 08:40:00 +03:00
|
|
|
waitEditorLoad,
|
2023-08-11 09:59:06 +03:00
|
|
|
waitForAllPagesLoad,
|
2023-07-13 12:05:01 +03:00
|
|
|
} from '@affine-test/kit/utils/page-logic';
|
|
|
|
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
|
|
|
|
import type { Page } from '@playwright/test';
|
|
|
|
import { expect } from '@playwright/test';
|
2023-05-09 06:54:07 +03:00
|
|
|
|
2023-05-18 23:07:05 +03:00
|
|
|
function getAllPage(page: Page) {
|
|
|
|
const newPageButton = page
|
|
|
|
.locator('table')
|
|
|
|
.getByRole('button', { name: 'New Page' });
|
|
|
|
const newPageDropdown = newPageButton.locator('svg');
|
|
|
|
const edgelessBlockCard = page.locator('table').getByText('New Edgeless');
|
|
|
|
|
|
|
|
async function clickNewPageButton() {
|
|
|
|
return newPageButton.click();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function clickNewEdgelessDropdown() {
|
|
|
|
await newPageDropdown.click();
|
|
|
|
await edgelessBlockCard.click();
|
|
|
|
}
|
2023-07-04 10:32:11 +03:00
|
|
|
|
2023-05-18 23:07:05 +03:00
|
|
|
return { clickNewPageButton, clickNewEdgelessDropdown };
|
|
|
|
}
|
|
|
|
|
2023-05-09 06:54:07 +03:00
|
|
|
test('all page', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-05-09 06:54:07 +03:00
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
});
|
2023-05-18 23:07:05 +03:00
|
|
|
|
|
|
|
test('all page can create new page', async ({ page }) => {
|
|
|
|
const { clickNewPageButton } = getAllPage(page);
|
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-05-18 23:07:05 +03:00
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
await clickNewPageButton();
|
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
|
|
await title.fill('this is a new page');
|
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
const cell = page.getByRole('cell', { name: 'this is a new page' });
|
|
|
|
expect(cell).not.toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('all page can create new edgeless page', async ({ page }) => {
|
|
|
|
const { clickNewEdgelessDropdown } = getAllPage(page);
|
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-05-18 23:07:05 +03:00
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
await clickNewEdgelessDropdown();
|
|
|
|
await expect(page.locator('affine-edgeless-page')).toBeVisible();
|
|
|
|
});
|
2023-06-04 18:34:16 +03:00
|
|
|
|
|
|
|
test('allow creation of filters by favorite', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-06-04 18:34:16 +03:00
|
|
|
await clickSideBarAllPageButton(page);
|
2023-07-04 20:40:58 +03:00
|
|
|
await createFirstFilter(page, 'Favourited');
|
2023-06-04 18:34:16 +03:00
|
|
|
await page
|
|
|
|
.locator('[data-testid="filter-arg"]', { hasText: 'true' })
|
|
|
|
.locator('div')
|
|
|
|
.click();
|
|
|
|
await expect(
|
|
|
|
await page.locator('[data-testid="filter-arg"]').textContent()
|
|
|
|
).toBe('false');
|
|
|
|
});
|
|
|
|
|
2023-08-11 09:59:06 +03:00
|
|
|
test('allow creation of filters by created time', async ({ page }) => {
|
2023-06-04 18:34:16 +03:00
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-08-11 09:59:06 +03:00
|
|
|
await newPage(page);
|
2023-06-04 18:34:16 +03:00
|
|
|
await clickSideBarAllPageButton(page);
|
2023-08-11 09:59:06 +03:00
|
|
|
await waitForAllPagesLoad(page);
|
|
|
|
const pages = await page.locator('[data-testid="title"]').all();
|
|
|
|
const pageCount = pages.length;
|
|
|
|
expect(pageCount).not.toBe(0);
|
2023-06-04 18:34:16 +03:00
|
|
|
await createFirstFilter(page, 'Created');
|
|
|
|
await checkFilterName(page, 'after');
|
|
|
|
// init date
|
|
|
|
const yesterday = new Date();
|
|
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
|
|
await checkDatePicker(page, yesterday);
|
|
|
|
await checkPagesCount(page, 1);
|
|
|
|
// change date
|
|
|
|
const today = new Date();
|
|
|
|
await fillDatePicker(page, today);
|
|
|
|
await checkPagesCount(page, 0);
|
|
|
|
// change filter
|
|
|
|
await page.locator('[data-testid="filter-name"]').click();
|
|
|
|
await page
|
|
|
|
.locator('[data-testid="filter-name-select"]')
|
|
|
|
.locator('button', { hasText: 'before' })
|
|
|
|
.click();
|
|
|
|
const tomorrow = new Date();
|
|
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
|
await fillDatePicker(page, tomorrow);
|
|
|
|
await checkDatePicker(page, tomorrow);
|
2023-08-11 09:59:06 +03:00
|
|
|
await checkPagesCount(page, pageCount);
|
2023-06-04 18:34:16 +03:00
|
|
|
});
|
2023-06-08 12:55:16 +03:00
|
|
|
|
2023-08-11 09:59:06 +03:00
|
|
|
test('creation of filters by created time, then click date picker to modify the date', async ({
|
|
|
|
page,
|
|
|
|
}) => {
|
|
|
|
await openHomePage(page);
|
|
|
|
await waitEditorLoad(page);
|
|
|
|
await newPage(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 checkFilterName(page, 'after');
|
|
|
|
// init date
|
|
|
|
const yesterday = new Date();
|
|
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
|
|
await checkDatePicker(page, yesterday);
|
|
|
|
await checkPagesCount(page, 1);
|
|
|
|
// change date
|
|
|
|
const today = new Date();
|
|
|
|
await selectDateFromDatePicker(page, today);
|
|
|
|
await checkPagesCount(page, 0);
|
|
|
|
// change filter
|
|
|
|
await page.locator('[data-testid="filter-name"]').click();
|
|
|
|
await page
|
|
|
|
.locator('[data-testid="filter-name-select"]')
|
|
|
|
.locator('button', { hasText: 'before' })
|
|
|
|
.click();
|
|
|
|
const tomorrow = new Date();
|
|
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
|
|
await selectDateFromDatePicker(page, tomorrow);
|
|
|
|
await checkDatePicker(page, tomorrow);
|
|
|
|
await checkPagesCount(page, pageCount);
|
|
|
|
});
|
2023-07-06 09:17:19 +03:00
|
|
|
|
2023-06-08 12:55:16 +03:00
|
|
|
test('use monthpicker to modify the month of datepicker', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
|
|
|
await waitEditorLoad(page);
|
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
await createFirstFilter(page, 'Created');
|
|
|
|
await checkFilterName(page, 'after');
|
|
|
|
// init date
|
|
|
|
const yesterday = new Date();
|
|
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
|
|
await checkDatePicker(page, yesterday);
|
|
|
|
// change month
|
|
|
|
await clickDatePicker(page);
|
|
|
|
const lastMonth = new Date();
|
|
|
|
lastMonth.setMonth(lastMonth.getMonth() - 1);
|
|
|
|
await selectMonthFromMonthPicker(page, lastMonth);
|
|
|
|
await checkDatePickerMonth(page, lastMonth);
|
|
|
|
// change month
|
|
|
|
await clickDatePicker(page);
|
|
|
|
const nextMonth = new Date();
|
|
|
|
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
|
|
|
await selectMonthFromMonthPicker(page, nextMonth);
|
|
|
|
await checkDatePickerMonth(page, nextMonth);
|
|
|
|
});
|
2023-07-04 10:32:11 +03:00
|
|
|
|
2023-08-11 09:59:06 +03:00
|
|
|
test('allow creation of filters by tags', async ({ page }) => {
|
2023-07-04 10:32:11 +03:00
|
|
|
await openHomePage(page);
|
|
|
|
await waitEditorLoad(page);
|
2023-08-11 09:59:06 +03:00
|
|
|
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);
|
2023-07-04 10:32:11 +03:00
|
|
|
await createPageWithTag(page, { title: 'Page A', tags: ['A'] });
|
|
|
|
await createPageWithTag(page, { title: 'Page B', tags: ['B'] });
|
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
await createFirstFilter(page, 'Tags');
|
|
|
|
await checkFilterName(page, 'is not empty');
|
2023-08-11 09:59:06 +03:00
|
|
|
await checkPagesCount(page, pagesWithTagsCount + 2);
|
2023-07-04 10:32:11 +03:00
|
|
|
await changeFilter(page, /^contains all/);
|
2023-08-11 09:59:06 +03:00
|
|
|
await checkPagesCount(page, pageCount + 2);
|
2023-07-04 10:32:11 +03:00
|
|
|
await selectTag(page, 'A');
|
|
|
|
await checkPagesCount(page, 1);
|
|
|
|
await changeFilter(page, /^does not contains all/);
|
|
|
|
await selectTag(page, 'B');
|
2023-08-11 09:59:06 +03:00
|
|
|
await checkPagesCount(page, pageCount + 1);
|
2023-07-04 10:32:11 +03:00
|
|
|
});
|