test: cover share page e2e (#4126)

This commit is contained in:
Alex Yang
2023-09-02 00:57:04 -05:00
committed by GitHub
parent 8825678ca9
commit 4f97ea8a5d
27 changed files with 186 additions and 99 deletions

View File

@@ -48,7 +48,11 @@ export class PermissionService {
return true; return true;
} else { } else {
// check if this is a public subpage // check if this is a public subpage
return subpages.map(page => `space:${page}`).includes(id);
// why use `endsWith`?
// because there might have `${wsId}:space:${subpageId}`,
// but subpages only have `${subpageId}`
return subpages.some(subpage => id.endsWith(subpage));
} }
} }
} }

View File

@@ -9,6 +9,7 @@ import type { Page } from '@blocksuite/store';
import { Button } from '@toeverything/components/button'; import { Button } from '@toeverything/components/button';
import { Divider } from '@toeverything/components/divider'; import { Divider } from '@toeverything/components/divider';
import { useAtom } from 'jotai'; import { useAtom } from 'jotai';
import { useCallback } from 'react';
import { Menu } from '../../ui/menu/menu'; import { Menu } from '../../ui/menu/menu';
import * as styles from './index.css'; import * as styles from './index.css';
@@ -62,15 +63,15 @@ export const ShareMenu = (props: ShareMenuProps) => {
trigger={['click']} trigger={['click']}
width={410} width={410}
disablePortal={true} disablePortal={true}
onClickAway={() => { onClickAway={useCallback(() => {
setOpen(false); setOpen(false);
}} }, [setOpen])}
> >
<Button <Button
data-testid="share-menu-button" data-testid="share-menu-button"
onClick={() => { onClick={useCallback(() => {
setOpen(!open); setOpen(value => !value);
}} }, [setOpen])}
type={'plain'} type={'plain'}
> >
<div <div

View File

@@ -132,13 +132,18 @@ export const AffineSharePage = (props: ShareMenuProps) => {
readOnly readOnly
/> />
{isPublic ? ( {isPublic ? (
<Button onClick={onClickCopyLink} style={{ padding: '4px 12px' }}> <Button
onClick={onClickCopyLink}
data-testid="share-menu-copy-link-button"
style={{ padding: '4px 12px' }}
>
{t.Copy()} {t.Copy()}
</Button> </Button>
) : ( ) : (
<Button <Button
onClick={onClickCreateLink} onClick={onClickCreateLink}
type="primary" type="primary"
data-testid="share-menu-create-link-button"
style={{ padding: '4px 12px' }} style={{ padding: '4px 12px' }}
> >
{t.Create()} {t.Create()}

View File

@@ -0,0 +1,70 @@
import { test } from '@affine-test/kit/playwright';
import { createRandomUser, loginUser } from '@affine-test/kit/utils/cloud';
import {
clickNewPageButton,
getBlockSuiteEditorTitle,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
let user: {
name: string;
email: string;
password: string;
};
test.beforeEach(async () => {
user = await createRandomUser();
});
test.beforeEach(async ({ page }) => {
await loginUser(page, user);
});
test.describe('collaboration', () => {
test('can enable share page', async ({ page, browser }) => {
await page.reload();
await waitForEditorLoad(page);
await createLocalWorkspace(
{
name: 'test',
},
page
);
await clickSideBarSettingButton(page);
await page.getByTestId('current-workspace-label').click();
await page.getByTestId('publish-enable-affine-cloud-button').click();
await page.getByTestId('confirm-enable-affine-cloud-button').click();
// wait for upload and delete local workspace
await page.waitForTimeout(2000);
await waitForEditorLoad(page);
await clickNewPageButton(page);
const title = getBlockSuiteEditorTitle(page);
await title.type('TEST TITLE', {
delay: 50,
});
await page.keyboard.press('Enter', { delay: 50 });
await page.keyboard.type('TEST CONTENT', { delay: 50 });
await page.getByTestId('share-menu-button').click();
await page.getByTestId('share-menu-create-link-button').click();
await page.getByTestId('share-menu-copy-link-button').click();
// check share page is accessible
{
const context = await browser.newContext();
const url: string = await page.evaluate(() =>
navigator.clipboard.readText()
);
const page2 = await context.newPage();
await page2.goto(url);
await waitForEditorLoad(page2);
const title = getBlockSuiteEditorTitle(page2);
expect(await title.innerText()).toBe('TEST TITLE');
expect(await page2.textContent('affine-paragraph')).toContain(
'TEST CONTENT'
);
}
});
});

View File

@@ -1,7 +1,10 @@
import { resolve } from 'node:path'; import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic'; import {
clickNewPageButton,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { import {
check8080Available, check8080Available,
setupProxyServer, setupProxyServer,
@@ -17,7 +20,7 @@ test('init page', async ({ page, context }) => {
await check8080Available(context); await check8080Available(context);
await page.goto('http://localhost:8081/'); await page.goto('http://localhost:8081/');
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const locator = page.locator('v-line').nth(0); const locator = page.locator('v-line').nth(0);
await locator.fill('hello'); await locator.fill('hello');

View File

@@ -15,8 +15,8 @@ import {
} from '@affine-test/kit/utils/filter'; } from '@affine-test/kit/utils/filter';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForAllPagesLoad, waitForAllPagesLoad,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
@@ -88,7 +88,7 @@ test('allow creation of filters by favorite', async ({ page }) => {
test('allow creation of filters by created time', async ({ page }) => { test('allow creation of filters by created time', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page); await waitForAllPagesLoad(page);
const pages = await page.locator('[data-testid="title"]').all(); const pages = await page.locator('[data-testid="title"]').all();
@@ -123,7 +123,7 @@ test('creation of filters by created time, then click date picker to modify the
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page); await waitForAllPagesLoad(page);
const pages = await page.locator('[data-testid="title"]').all(); const pages = await page.locator('[data-testid="title"]').all();

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
@@ -20,7 +20,7 @@ const addDatabase = async (page: Page) => {
test('database is useable', async ({ page }) => { test('database is useable', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test title'); await title.type('test title');
@@ -31,7 +31,7 @@ test('database is useable', async ({ page }) => {
await expect(database).toBeVisible(); await expect(database).toBeVisible();
await page.reload(); await page.reload();
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title2 = getBlockSuiteEditorTitle(page); const title2 = getBlockSuiteEditorTitle(page);
await title2.type('test title2'); await title2.type('test title2');
@@ -46,13 +46,13 @@ test('database is useable', async ({ page }) => {
test('link page is useable', async ({ page }) => { test('link page is useable', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.type('page1'); await title.type('page1');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
expect(await title.innerText()).toBe('page1'); expect(await title.innerText()).toBe('page1');
await newPage(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title2 = await getBlockSuiteEditorTitle(page); const title2 = await getBlockSuiteEditorTitle(page);
await title2.type('page2'); await title2.type('page2');

View File

@@ -1,9 +1,9 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -11,7 +11,7 @@ import { expect } from '@playwright/test';
test('Duplicate page should work', async ({ page }) => { test('Duplicate page should work', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test'); await title.type('test');
await clickPageMoreActions(page); await clickPageMoreActions(page);

View File

@@ -1,7 +1,7 @@
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
@@ -43,7 +43,7 @@ async function closeImagePreviewModal(page: Page) {
test('image preview should be shown', async ({ page }) => { test('image preview should be shown', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
@@ -58,7 +58,7 @@ test('image preview should be shown', async ({ page }) => {
test('image go left and right', async ({ page }) => { test('image go left and right', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -105,7 +105,7 @@ test('image go left and right', async ({ page }) => {
test('image able to zoom in and out with mouse scroll', async ({ page }) => { test('image able to zoom in and out with mouse scroll', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -158,7 +158,7 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
test('image able to zoom in and out with button click', async ({ page }) => { test('image able to zoom in and out with button click', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -204,7 +204,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {
test('image should able to go left and right by buttons', async ({ page }) => { test('image should able to go left and right by buttons', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -258,7 +258,7 @@ test('image should able to go left and right by buttons', async ({ page }) => {
test('image able to fit to screen by button', async ({ page }) => { test('image able to fit to screen by button', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -315,7 +315,7 @@ test('image able to fit to screen by button', async ({ page }) => {
test('image able to reset zoom to 100%', async ({ page }) => { test('image able to reset zoom to 100%', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -368,7 +368,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {
test('image able to copy to clipboard', async ({ page }) => { test('image able to copy to clipboard', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -395,7 +395,7 @@ test('image able to copy to clipboard', async ({ page }) => {
test('image able to download', async ({ page }) => { test('image able to download', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -427,7 +427,7 @@ test('image should only able to move when image is larger than viewport', async
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -484,7 +484,7 @@ test('image should able to delete and when delete, it will move to previous/next
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -559,7 +559,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
let blobId: string; let blobId: string;
{ {
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
@@ -654,7 +654,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
test('keypress esc should close the modal', async ({ page }) => { test('keypress esc should close the modal', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
@@ -672,7 +672,7 @@ test('when mouse moves outside, the modal should be closed', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
@@ -693,7 +693,7 @@ test('caption should be visible and different styles were applied if image zoome
const sampleCaption = 'affine owns me and all'; const sampleCaption = 'affine owns me and all';
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');

View File

@@ -2,7 +2,10 @@ import { resolve } from 'node:path';
import { rootDir, test } from '@affine-test/kit/playwright'; import { rootDir, test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic'; import {
clickNewPageButton,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('should create a page with a local first avatar', async ({ test('should create a page with a local first avatar', async ({
@@ -11,7 +14,7 @@ test('should create a page with a local first avatar', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click();
await page.getByTestId('new-workspace').click({ delay: 50 }); await page.getByTestId('new-workspace').click({ delay: 50 });
await page await page

View File

@@ -5,8 +5,8 @@ import {
} from '@affine-test/kit/utils/filter'; } from '@affine-test/kit/utils/filter';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
@@ -20,7 +20,7 @@ const createAndPinCollection = async (
) => { ) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
@@ -141,7 +141,7 @@ test('edit collection and change filter date', async ({ page }) => {
test('create temporary filter by click tag', async ({ page }) => { test('create temporary filter by click tag', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');
await page.locator('affine-page-meta-data').click(); await page.locator('affine-page-meta-data').click();
@@ -163,7 +163,7 @@ test('create temporary filter by click tag', async ({ page }) => {
test('add collection from sidebar', async ({ page }) => { test('add collection from sidebar', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -13,7 +13,7 @@ test('page delete -> refresh page -> it should be disappear', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page delete');
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];
@@ -56,7 +56,7 @@ test('page delete -> create new page -> refresh page -> new page should be appea
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page delete');
const newPageDeleteId = page.url().split('/').reverse()[0]; const newPageDeleteId = page.url().split('/').reverse()[0];
@@ -87,12 +87,12 @@ test('page delete -> create new page -> refresh page -> new page should be appea
expect(page.getByText("There's no page here yet")).not.toBeUndefined(); expect(page.getByText("There's no page here yet")).not.toBeUndefined();
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page1'); await getBlockSuiteEditorTitle(page).fill('this is a new page1');
const newPageId1 = page.url().split('/').reverse()[0]; const newPageId1 = page.url().split('/').reverse()[0];
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page2'); await getBlockSuiteEditorTitle(page).fill('this is a new page2');
const newPageId2 = page.url().split('/').reverse()[0]; const newPageId2 = page.url().split('/').reverse()[0];
@@ -115,13 +115,13 @@ test('delete multiple pages -> create multiple pages -> refresh', async ({
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
// create 1st page // create 1st page
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page1'); await getBlockSuiteEditorTitle(page).fill('this is a new page1');
const newPageId1 = page.url().split('/').reverse()[0]; const newPageId1 = page.url().split('/').reverse()[0];
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
// create 2nd page // create 2nd page
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page2'); await getBlockSuiteEditorTitle(page).fill('this is a new page2');
const newPageId2 = page.url().split('/').reverse()[0]; const newPageId2 = page.url().split('/').reverse()[0];

View File

@@ -1,9 +1,9 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -14,7 +14,7 @@ test.skip('New a page ,then open it and export html', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await page await page
.getByPlaceholder('Title') .getByPlaceholder('Title')
@@ -48,7 +48,7 @@ test.skip('New a page ,then open it and export markdown', async ({
page, page,
workspace, workspace,
}) => { }) => {
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await page await page
.getByPlaceholder('Title') .getByPlaceholder('Title')

View File

@@ -1,9 +1,9 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { waitForLogMessage } from '@affine-test/kit/utils/utils'; import { waitForLogMessage } from '@affine-test/kit/utils/utils';
@@ -15,7 +15,7 @@ test('New a page and open it ,then favorite it', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
@@ -81,7 +81,7 @@ test.skip('Export to pdf', async ({ page }) => {
test('Cancel favorite', async ({ page, workspace }) => { test('Cancel favorite', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();

View File

@@ -1,10 +1,10 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
clickPageMoreActions, clickPageMoreActions,
createLinkedPage, createLinkedPage,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -12,7 +12,7 @@ import { expect } from '@playwright/test';
test('Show favorite items in sidebar', async ({ page, workspace }) => { test('Show favorite items in sidebar', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];
@@ -40,7 +40,7 @@ test('Show favorite items in sidebar', async ({ page, workspace }) => {
test('Show favorite reference in sidebar', async ({ page, workspace }) => { test('Show favorite reference in sidebar', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
@@ -83,7 +83,7 @@ test("Deleted page's reference will not be shown in sidebar", async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -11,7 +11,7 @@ test('click btn new page', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const originPageId = page.url().split('/').reverse()[0]; const originPageId = page.url().split('/').reverse()[0];
await newPage(page); await clickNewPageButton(page);
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];
expect(newPageId).not.toBe(originPageId); expect(newPageId).not.toBe(originPageId);
const currentWorkspace = await workspace.current(); const currentWorkspace = await workspace.current();
@@ -25,7 +25,7 @@ test('click btn bew page and find it in all pages', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page'); await getBlockSuiteEditorTitle(page).fill('this is a new page');
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -10,7 +10,7 @@ import { expect } from '@playwright/test';
test('click btn bew page and open in tab', async ({ page, workspace }) => { test('click btn bew page and open in tab', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page'); await getBlockSuiteEditorTitle(page).fill('this is a new page');
const newPageUrl = page.url(); const newPageUrl = page.url();

View File

@@ -1,8 +1,8 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -13,7 +13,7 @@ test('New a page , then delete it in all pages, restore it', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore'); await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];

View File

@@ -1,9 +1,9 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -14,7 +14,7 @@ test('New a page ,then open it and show delete modal', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
@@ -40,7 +40,7 @@ test('New a page ,then go to all pages and show delete modal', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];

View File

@@ -1,9 +1,9 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -14,7 +14,7 @@ test('New a page , then delete it in all pages, finally find it in trash', async
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];
@@ -50,7 +50,7 @@ test('New a page , then delete it in page, blockHub and option menu will not app
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test'); await title.type('test');
await clickPageMoreActions(page); await clickPageMoreActions(page);

View File

@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar'; import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
import { import {
createWorkspace, createLocalWorkspace,
openWorkspaceListModal, openWorkspaceListModal,
} from '@affine-test/kit/utils/workspace'; } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -34,7 +34,7 @@ test('create one workspace in the workspace list', async ({
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const newWorkspaceNameStr = 'New Workspace'; const newWorkspaceNameStr = 'New Workspace';
await createWorkspace({ name: newWorkspaceNameStr }, page); await createLocalWorkspace({ name: newWorkspaceNameStr }, page);
// check new workspace name // check new workspace name
const newWorkspaceName = page.getByTestId('workspace-name'); const newWorkspaceName = page.getByTestId('workspace-name');
@@ -67,8 +67,8 @@ test('create multi workspace in the workspace list', async ({
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await createWorkspace({ name: 'New Workspace 2' }, page); await createLocalWorkspace({ name: 'New Workspace 2' }, page);
await createWorkspace({ name: 'New Workspace 3' }, page); await createLocalWorkspace({ name: 'New Workspace 3' }, page);
// show workspace list // show workspace list
const workspaceName = page.getByTestId('workspace-name'); const workspaceName = page.getByTestId('workspace-name');

View File

@@ -1,13 +1,13 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { createWorkspace } from '@affine-test/kit/utils/workspace'; import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Open last workspace when back to affine', async ({ page }) => { test('Open last workspace when back to affine', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await createWorkspace({ name: 'New Workspace 2' }, page); await createLocalWorkspace({ name: 'New Workspace 2' }, page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
// show workspace list // show workspace list
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click();

View File

@@ -2,8 +2,8 @@ import { test } from '@affine-test/kit/playwright';
import { withCtrlOrMeta } from '@affine-test/kit/utils/keyboard'; import { withCtrlOrMeta } from '@affine-test/kit/utils/keyboard';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickNewPageButton,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage,
waitForEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect, type Page } from '@playwright/test'; import { expect, type Page } from '@playwright/test';
@@ -39,7 +39,7 @@ async function titleIsFocused(page: Page) {
test('Click slider bar button', async ({ page }) => { test('Click slider bar button', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const quickSearchButton = page.locator( const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]' '[data-testid=slider-bar-quick-search-button]'
); );
@@ -51,7 +51,7 @@ test('Click slider bar button', async ({ page }) => {
test('Click arrowDown icon after title', async ({ page }) => { test('Click arrowDown icon after title', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
const quickSearchButton = page.locator( const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]' '[data-testid=slider-bar-quick-search-button]'
); );
@@ -63,7 +63,7 @@ test('Click arrowDown icon after title', async ({ page }) => {
test('Press the shortcut key cmd+k', async ({ page }) => { test('Press the shortcut key cmd+k', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const quickSearch = page.locator('[data-testid=quickSearch]'); const quickSearch = page.locator('[data-testid=quickSearch]');
await expect(quickSearch).toBeVisible(); await expect(quickSearch).toBeVisible();
@@ -72,7 +72,7 @@ test('Press the shortcut key cmd+k', async ({ page }) => {
test('Create a new page without keyword', async ({ page }) => { test('Create a new page without keyword', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]'); const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click(); await addNewPage.click();
@@ -83,7 +83,7 @@ test('Create a new page without keyword', async ({ page }) => {
test('Create a new page with keyword', async ({ page }) => { test('Create a new page with keyword', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456'); await page.keyboard.insertText('test123456');
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]'); const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
@@ -95,7 +95,7 @@ test('Create a new page with keyword', async ({ page }) => {
test('Enter a keyword to search for', async ({ page }) => { test('Enter a keyword to search for', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456'); await page.keyboard.insertText('test123456');
const actual = await page.locator('[cmdk-input]').inputValue(); const actual = await page.locator('[cmdk-input]').inputValue();
@@ -105,7 +105,7 @@ test('Enter a keyword to search for', async ({ page }) => {
test('Create a new page and search this page', async ({ page }) => { test('Create a new page and search this page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
// input title and create new page // input title and create new page
await page.keyboard.insertText('test123456'); await page.keyboard.insertText('test123456');
@@ -147,7 +147,7 @@ test('Navigate to the 404 page and try to open quick search', async ({
test('Open quick search on local page', async ({ page }) => { test('Open quick search on local page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const publishedSearchResults = page.locator('[publishedSearchResults]'); const publishedSearchResults = page.locator('[publishedSearchResults]');
await expect(publishedSearchResults).toBeVisible({ visible: false }); await expect(publishedSearchResults).toBeVisible({ visible: false });
@@ -156,7 +156,7 @@ test('Open quick search on local page', async ({ page }) => {
test('Autofocus input after opening quick search', async ({ page }) => { test('Autofocus input after opening quick search', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const locator = page.locator('[cmdk-input]'); const locator = page.locator('[cmdk-input]');
await expect(locator).toBeVisible(); await expect(locator).toBeVisible();
@@ -165,7 +165,7 @@ test('Autofocus input after opening quick search', async ({ page }) => {
test('Autofocus input after select', async ({ page }) => { test('Autofocus input after select', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.press('ArrowUp'); await page.keyboard.press('ArrowUp');
const locator = page.locator('[cmdk-input]'); const locator = page.locator('[cmdk-input]');
@@ -175,7 +175,7 @@ test('Autofocus input after select', async ({ page }) => {
test('Focus title after creating a new page', async ({ page }) => { test('Focus title after creating a new page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await clickNewPageButton(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]'); const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click(); await addNewPage.click();
@@ -198,7 +198,7 @@ test('assert the recent browse pages are on the recent list', async ({
await waitForEditorLoad(page); await waitForEditorLoad(page);
// create first page // create first page
await newPage(page); await clickNewPageButton(page);
{ {
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('sgtokidoki', { await title.type('sgtokidoki', {

View File

@@ -8,7 +8,7 @@ import {
openSettingModal, openSettingModal,
openShortcutsPanel, openShortcutsPanel,
} from '@affine-test/kit/utils/setting'; } from '@affine-test/kit/utils/setting';
import { createWorkspace } from '@affine-test/kit/utils/workspace'; import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Open settings modal', async ({ page }) => { test('Open settings modal', async ({ page }) => {
@@ -118,8 +118,8 @@ test('Different workspace should have different name in the setting panel', asyn
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
await createWorkspace({ name: 'New Workspace 2' }, page); await createLocalWorkspace({ name: 'New Workspace 2' }, page);
await createWorkspace({ name: 'New Workspace 3' }, page); await createLocalWorkspace({ name: 'New Workspace 3' }, page);
await openSettingModal(page); await openSettingModal(page);
await page.getByTestId('current-workspace-label').click(); await page.getByTestId('current-workspace-label').click();
expect(await page.getByTestId('workspace-name-input').inputValue()).toBe( expect(await page.getByTestId('workspace-name-input').inputValue()).toBe(

View File

@@ -1,7 +1,7 @@
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
import { getBlockSuiteEditorTitle, newPage } from './page-logic'; import { clickNewPageButton, getBlockSuiteEditorTitle } from './page-logic';
const monthNames = [ const monthNames = [
'Jan', 'Jan',
@@ -189,7 +189,7 @@ export const createPageWithTag = async (
} }
) => { ) => {
await page.getByTestId('all-pages').click(); await page.getByTestId('all-pages').click();
await newPage(page); await clickNewPageButton(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');
await page.locator('affine-page-meta-data').click(); await page.locator('affine-page-meta-data').click();

View File

@@ -14,7 +14,7 @@ export async function waitForAllPagesLoad(page: Page) {
}); });
} }
export async function newPage(page: Page) { export async function clickNewPageButton(page: Page) {
// fixme(himself65): if too fast, the page will crash // fixme(himself65): if too fast, the page will crash
await page.getByTestId('new-page-button').click({ await page.getByTestId('new-page-button').click({
delay: 100, delay: 100,

View File

@@ -5,11 +5,12 @@ interface CreateWorkspaceParams {
} }
export async function openWorkspaceListModal(page: Page) { export async function openWorkspaceListModal(page: Page) {
const workspaceName = page.getByTestId('workspace-name'); await page.getByTestId('workspace-name').click({
await workspaceName.click(); delay: 50,
});
} }
export async function createWorkspace( export async function createLocalWorkspace(
params: CreateWorkspaceParams, params: CreateWorkspaceParams,
page: Page page: Page
) { ) {