2023-05-12 04:51:13 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-05-18 23:07:05 +03:00
|
|
|
import type { Page } from '@playwright/test';
|
|
|
|
import { expect } from '@playwright/test';
|
2023-05-09 06:54:07 +03:00
|
|
|
|
|
|
|
import { openHomePage } from '../libs/load-page';
|
2023-05-18 23:07:05 +03:00
|
|
|
import {
|
|
|
|
getBlockSuiteEditorTitle,
|
|
|
|
waitMarkdownImported,
|
|
|
|
} from '../libs/page-logic';
|
2023-05-09 06:54:07 +03:00
|
|
|
import { clickSideBarAllPageButton } from '../libs/sidebar';
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
return { clickNewPageButton, clickNewEdgelessDropdown };
|
|
|
|
}
|
|
|
|
|
2023-05-09 06:54:07 +03:00
|
|
|
test('all page', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
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);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
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);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
await clickSideBarAllPageButton(page);
|
|
|
|
await clickNewEdgelessDropdown();
|
|
|
|
await expect(page.locator('affine-edgeless-page')).toBeVisible();
|
|
|
|
});
|