mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 02:26:21 +08:00
test: speed up favorites test
This commit is contained in:
@@ -3,8 +3,8 @@ import { loadPage } from './libs/load-page';
|
||||
|
||||
loadPage();
|
||||
|
||||
test.describe('Local first favorite page', () => {
|
||||
test('New a page and open it ,then favorite ot', async ({ page }) => {
|
||||
test.describe('Local first favorite and cancel favorite page', () => {
|
||||
test('New a page and open it ,then favorite it', async ({ page }) => {
|
||||
await page.getByText('New Page').click();
|
||||
await page.getByPlaceholder('Title').click();
|
||||
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
|
||||
@@ -23,59 +23,6 @@ test.describe('Local first favorite page', () => {
|
||||
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
||||
await favoriteBtn.click();
|
||||
});
|
||||
|
||||
test('Show favorite items in sidebar', async ({ page }) => {
|
||||
await page.getByText('New Page').click();
|
||||
await page.getByPlaceholder('Title').click();
|
||||
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
|
||||
const newPageId = page.url().split('/').reverse()[0];
|
||||
await page.getByRole('link', { name: 'All pages' }).click();
|
||||
const cell = page.getByRole('cell', {
|
||||
name: 'this is a new page to favorite',
|
||||
});
|
||||
expect(cell).not.toBeUndefined();
|
||||
await cell.click();
|
||||
await page
|
||||
.getByTestId('editor-header-items')
|
||||
.getByRole('button')
|
||||
.nth(2)
|
||||
.click();
|
||||
|
||||
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
||||
await favoriteBtn.click();
|
||||
const favoriteListItemInSidebar = page.getByTestId(
|
||||
'favorite-list-item-' + newPageId
|
||||
);
|
||||
expect(await favoriteListItemInSidebar.textContent()).toBe(
|
||||
'this is a new page to favorite'
|
||||
);
|
||||
});
|
||||
|
||||
test('Show favorite items in favorite list', async ({ page }) => {
|
||||
await page.getByText('New Page').click();
|
||||
await page.getByPlaceholder('Title').click();
|
||||
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
|
||||
await page.getByRole('link', { name: 'All pages' }).click();
|
||||
const cell = page.getByRole('cell', {
|
||||
name: 'this is a new page to favorite',
|
||||
});
|
||||
expect(cell).not.toBeUndefined();
|
||||
await cell.click();
|
||||
await page
|
||||
.getByTestId('editor-header-items')
|
||||
.getByRole('button')
|
||||
.nth(2)
|
||||
.click();
|
||||
|
||||
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
||||
await favoriteBtn.click();
|
||||
|
||||
await page.getByRole('link', { name: 'Favourites' }).click();
|
||||
expect(
|
||||
page.getByRole('cell', { name: 'this is a new page to favorite' })
|
||||
).not.toBeUndefined();
|
||||
});
|
||||
|
||||
test('Cancel favorite', async ({ page }) => {
|
||||
await page.getByText('New Page').click();
|
||||
await page.getByPlaceholder('Title').click();
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { loadPage } from './libs/load-page';
|
||||
|
||||
loadPage();
|
||||
|
||||
test.describe('Local first favorite items ui', () => {
|
||||
test('Show favorite items in sidebar', async ({ page }) => {
|
||||
await page.getByText('New Page').click();
|
||||
await page.getByPlaceholder('Title').click();
|
||||
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
|
||||
const newPageId = page.url().split('/').reverse()[0];
|
||||
await page.getByRole('link', { name: 'All pages' }).click();
|
||||
const cell = page.getByRole('cell', {
|
||||
name: 'this is a new page to favorite',
|
||||
});
|
||||
expect(cell).not.toBeUndefined();
|
||||
await cell.click();
|
||||
await page
|
||||
.getByTestId('editor-header-items')
|
||||
.getByRole('button')
|
||||
.nth(2)
|
||||
.click();
|
||||
|
||||
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
||||
await favoriteBtn.click();
|
||||
const favoriteListItemInSidebar = page.getByTestId(
|
||||
'favorite-list-item-' + newPageId
|
||||
);
|
||||
expect(await favoriteListItemInSidebar.textContent()).toBe(
|
||||
'this is a new page to favorite'
|
||||
);
|
||||
});
|
||||
|
||||
test('Show favorite items in favorite list', async ({ page }) => {
|
||||
await page.getByText('New Page').click();
|
||||
await page.getByPlaceholder('Title').click();
|
||||
await page.getByPlaceholder('Title').fill('this is a new page to favorite');
|
||||
await page.getByRole('link', { name: 'All pages' }).click();
|
||||
const cell = page.getByRole('cell', {
|
||||
name: 'this is a new page to favorite',
|
||||
});
|
||||
expect(cell).not.toBeUndefined();
|
||||
await cell.click();
|
||||
await page
|
||||
.getByTestId('editor-header-items')
|
||||
.getByRole('button')
|
||||
.nth(2)
|
||||
.click();
|
||||
|
||||
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
||||
await favoriteBtn.click();
|
||||
|
||||
await page.getByRole('link', { name: 'Favourites' }).click();
|
||||
expect(
|
||||
page.getByRole('cell', { name: 'this is a new page to favorite' })
|
||||
).not.toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user