mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-24 04:06:09 +03:00
2f7b51d7ff
Co-authored-by: Himself65 <himself65@outlook.com>
74 lines
2.2 KiB
TypeScript
74 lines
2.2 KiB
TypeScript
import { test } from '@affine-test/kit/playwright';
|
|
import { expect } from '@playwright/test';
|
|
|
|
import { openHomePage } from '../libs/load-page';
|
|
import {
|
|
clickPageMoreActions,
|
|
createLinkedPage,
|
|
getBlockSuiteEditorTitle,
|
|
newPage,
|
|
waitMarkdownImported,
|
|
} from '../libs/page-logic';
|
|
|
|
test('Show favorite items in sidebar', async ({ page }) => {
|
|
await openHomePage(page);
|
|
await waitMarkdownImported(page);
|
|
await newPage(page);
|
|
await getBlockSuiteEditorTitle(page).click();
|
|
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
|
const newPageId = page.url().split('/').reverse()[0];
|
|
await page.getByTestId('all-pages').click();
|
|
const cell = page.getByRole('cell', {
|
|
name: 'this is a new page to favorite',
|
|
});
|
|
await expect(cell).toBeVisible();
|
|
await cell.click();
|
|
await clickPageMoreActions(page);
|
|
|
|
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 reference in sidebar', async ({ page }) => {
|
|
await openHomePage(page);
|
|
await waitMarkdownImported(page);
|
|
await newPage(page);
|
|
await getBlockSuiteEditorTitle(page).click();
|
|
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
|
|
|
// goes to main content
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
|
|
await createLinkedPage(page, 'Another page');
|
|
|
|
const newPageId = page.url().split('/').reverse()[0];
|
|
|
|
await clickPageMoreActions(page);
|
|
|
|
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
|
await favoriteBtn.click();
|
|
|
|
const favItemTestId = 'favorite-list-item-' + newPageId;
|
|
|
|
const favoriteListItemInSidebar = page.getByTestId(favItemTestId);
|
|
expect(await favoriteListItemInSidebar.textContent()).toBe(
|
|
'this is a new page to favorite'
|
|
);
|
|
|
|
const collapseButton = favoriteListItemInSidebar.locator(
|
|
'[data-testid="fav-collapsed-button"]'
|
|
);
|
|
|
|
await expect(collapseButton).toBeVisible();
|
|
await collapseButton.click();
|
|
await expect(
|
|
page.locator('[data-type="favorite-list-item"] >> text=Another page')
|
|
).toBeVisible();
|
|
});
|