2023-04-25 06:12:48 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-02-05 13:41:18 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-02-17 10:33:32 +03:00
|
|
|
|
2023-03-24 01:15:40 +03:00
|
|
|
import { openHomePage } from '../libs/load-page';
|
2023-03-02 20:38:17 +03:00
|
|
|
import {
|
|
|
|
clickPageMoreActions,
|
2023-05-18 08:18:40 +03:00
|
|
|
createLinkedPage,
|
2023-03-02 20:38:17 +03:00
|
|
|
getBlockSuiteEditorTitle,
|
|
|
|
newPage,
|
2023-06-07 12:31:54 +03:00
|
|
|
waitEditorLoad,
|
2023-03-24 01:15:40 +03:00
|
|
|
} from '../libs/page-logic';
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
test('Show favorite items in sidebar', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-04-17 00:02:41 +03:00
|
|
|
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];
|
2023-05-12 06:13:51 +03:00
|
|
|
await page.getByTestId('all-pages').click();
|
2023-04-17 00:02:41 +03:00
|
|
|
const cell = page.getByRole('cell', {
|
|
|
|
name: 'this is a new page to favorite',
|
2022-12-30 16:40:15 +03:00
|
|
|
});
|
2023-04-17 00:02:41 +03:00
|
|
|
await expect(cell).toBeVisible();
|
|
|
|
await cell.click();
|
|
|
|
await clickPageMoreActions(page);
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
});
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-05-18 08:18:40 +03:00
|
|
|
test('Show favorite reference in sidebar', async ({ page }) => {
|
2023-04-17 00:02:41 +03:00
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-04-17 00:02:41 +03:00
|
|
|
await newPage(page);
|
|
|
|
await getBlockSuiteEditorTitle(page).click();
|
|
|
|
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
|
2023-05-18 08:18:40 +03:00
|
|
|
|
|
|
|
// goes to main content
|
|
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
|
|
|
|
|
|
await createLinkedPage(page, 'Another page');
|
|
|
|
|
|
|
|
const newPageId = page.url().split('/').reverse()[0];
|
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
await clickPageMoreActions(page);
|
2022-12-30 16:40:15 +03:00
|
|
|
|
2023-04-17 00:02:41 +03:00
|
|
|
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
|
|
|
await favoriteBtn.click();
|
2023-03-01 19:50:23 +03:00
|
|
|
|
2023-05-18 08:18:40 +03:00
|
|
|
const favItemTestId = 'favorite-list-item-' + newPageId;
|
|
|
|
|
|
|
|
const favoriteListItemInSidebar = page.getByTestId(favItemTestId);
|
|
|
|
expect(await favoriteListItemInSidebar.textContent()).toBe(
|
|
|
|
'this is a new page to favorite'
|
|
|
|
);
|
2023-05-12 06:13:51 +03:00
|
|
|
|
2023-05-18 08:18:40 +03:00
|
|
|
const collapseButton = favoriteListItemInSidebar.locator(
|
|
|
|
'[data-testid="fav-collapsed-button"]'
|
|
|
|
);
|
2023-04-17 00:02:41 +03:00
|
|
|
|
2023-05-18 08:18:40 +03:00
|
|
|
await expect(collapseButton).toBeVisible();
|
|
|
|
await collapseButton.click();
|
|
|
|
await expect(
|
|
|
|
page.locator('[data-type="favorite-list-item"] >> text=Another page')
|
|
|
|
).toBeVisible();
|
2022-12-30 16:40:15 +03:00
|
|
|
});
|
2023-06-06 05:36:58 +03:00
|
|
|
|
|
|
|
test("Deleted page's reference will not be shown in sidebar", async ({
|
|
|
|
page,
|
|
|
|
}) => {
|
|
|
|
await openHomePage(page);
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-06-06 05:36:58 +03:00
|
|
|
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];
|
|
|
|
|
|
|
|
// goes to main content
|
|
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
|
|
|
|
|
|
await createLinkedPage(page, 'Another page');
|
|
|
|
|
|
|
|
await clickPageMoreActions(page);
|
|
|
|
|
|
|
|
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
|
|
|
|
await favoriteBtn.click();
|
|
|
|
|
|
|
|
// goto "Another page"
|
|
|
|
await page.locator('.affine-reference-title').click();
|
|
|
|
|
|
|
|
// delete the page
|
|
|
|
await clickPageMoreActions(page);
|
|
|
|
|
|
|
|
const deleteBtn = page.getByTestId('editor-option-menu-delete');
|
|
|
|
await deleteBtn.click();
|
|
|
|
|
|
|
|
// confirm delete
|
|
|
|
await page.locator('button >> text=Delete').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).not.toBeVisible();
|
|
|
|
});
|