feat: new collections (#4530)

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
3720
2023-10-27 17:06:59 +08:00
committed by GitHub
parent 9fc0152cb1
commit ef8024c657
133 changed files with 8382 additions and 3743 deletions

View File

@@ -1,8 +1,4 @@
import { test } from '@affine-test/kit/playwright';
import {
checkDatePicker,
selectDateFromDatePicker,
} from '@affine-test/kit/utils/filter';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
@@ -29,16 +25,17 @@ const createAndPinCollection = async (
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page');
await page.getByTestId('all-pages').click();
const cell = page.getByRole('cell', {
name: 'test page',
});
const cell = page.getByTestId('page-list-item-title').getByText('test page');
await expect(cell).toBeVisible();
await page.getByTestId('create-first-filter').click({
delay: 200,
});
await page.getByTestId(`filler-tag-Created`).click({
delay: 200,
});
await page
.getByTestId('variable-select')
.getByTestId(`filler-tag-Created`)
.click({
delay: 200,
});
await page.getByTestId('save-as-collection').click({
delay: 200,
});
@@ -47,8 +44,6 @@ const createAndPinCollection = async (
await title.fill(options?.collectionName ?? 'test collection');
await page.getByTestId('save-collection').click();
await page.waitForTimeout(100);
await page.getByTestId('collection-bar-option-pin').click();
await page.waitForTimeout(100);
};
test('Show collections items in sidebar', async ({ page }) => {
@@ -93,32 +88,6 @@ test('Show collections items in sidebar', async ({ page }) => {
await page.getByTestId('workspace-card').nth(0).click();
});
test('pin and unpin collection', async ({ page }) => {
const name = 'asd';
await createAndPinCollection(page, { collectionName: name });
const collections = page.getByTestId('collections');
const items = collections.getByTestId('collection-item');
await page.waitForTimeout(50);
expect(await items.count()).toBe(1);
const first = items.first();
await first.hover();
await first.getByTestId('collection-options').click();
const deleteCollection = page
.getByTestId('collection-option')
.getByText('Unpin');
await deleteCollection.click();
await page.waitForTimeout(50);
expect(await items.count()).toBe(0);
await page.getByTestId('collection-select').click();
const option = page.locator('[data-testid=collection-select-option]', {
hasText: name,
});
await option.hover();
await option.getByTestId('collection-select-option-pin').click();
await page.waitForTimeout(100);
expect(await items.count()).toBe(1);
});
test('edit collection', async ({ page }) => {
await createAndPinCollection(page);
const collections = page.getByTestId('collections');
@@ -129,7 +98,7 @@ test('edit collection', async ({ page }) => {
await first.getByTestId('collection-options').click();
const editCollection = page
.getByTestId('collection-option')
.getByText('Edit Filter');
.getByText('Rename');
await editCollection.click();
const title = page.getByTestId('input-collection-title');
await title.fill('123');
@@ -148,14 +117,10 @@ test('edit collection and change filter date', async ({ page }) => {
await first.getByTestId('collection-options').click();
const editCollection = page
.getByTestId('collection-option')
.getByText('Edit Filter');
.getByText('Rename');
await editCollection.click();
const title = page.getByTestId('input-collection-title');
await title.fill('123');
const today = new Date();
await page.locator('[data-testid="filter-arg"]').locator('input').click();
await selectDateFromDatePicker(page, today);
await checkDatePicker(page, today);
await page.getByTestId('save-collection').click();
await page.waitForTimeout(100);
expect(await first.textContent()).toBe('123');
@@ -173,15 +138,15 @@ test('create temporary filter by click tag', async ({ page }) => {
await page.keyboard.press('Enter');
await page.keyboard.press('Escape');
await page.locator('.tag', { hasText: 'TODO Tag' }).click();
const cell = page.getByRole('cell', {
name: 'test page',
});
const cell = page.getByTestId('page-list-item-title').getByText('test page');
await expect(cell).toBeVisible();
expect(await page.getByTestId('title').count()).toBe(1);
expect(await page.getByTestId('page-list-item').count()).toBe(1);
await page.getByTestId('filter-arg').click();
await page.getByTestId('multi-select-TODO Tag').click();
expect(await page.getByTestId('title').count()).toBeGreaterThanOrEqual(2);
expect(
await page.getByTestId('page-list-item').count()
).toBeGreaterThanOrEqual(2);
});
test('add collection from sidebar', async ({ page }) => {
@@ -191,9 +156,7 @@ test('add collection from sidebar', async ({ page }) => {
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page');
await page.getByTestId('all-pages').click();
const cell = page.getByRole('cell', {
name: 'test page',
});
const cell = page.getByTestId('page-list-item-title').getByText('test page');
await expect(cell).toBeVisible();
const nullCollection = page.getByTestId(
'slider-bar-collection-null-description'