mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 10:42:00 +03:00
401fb48b86
Co-authored-by: JimmFly <yangjinfei001@gmail.com> Co-authored-by: Alex Yang <himself65@outlook.com>
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import type { Page } from '@playwright/test';
|
|
import { expect } from '@playwright/test';
|
|
|
|
export async function waitEditorLoad(page: Page) {
|
|
await page.waitForSelector('v-line', {
|
|
timeout: 10000,
|
|
});
|
|
}
|
|
|
|
export async function waitForAllPagesLoad(page: Page) {
|
|
// if filters tag is rendered, we believe all_pages is ready
|
|
await page.waitForSelector('[data-testid="create-first-filter"]', {
|
|
timeout: 1000,
|
|
});
|
|
}
|
|
|
|
export async function newPage(page: Page) {
|
|
// fixme(himself65): if too fast, the page will crash
|
|
await page.getByTestId('new-page-button').click({
|
|
delay: 100,
|
|
});
|
|
await waitEditorLoad(page);
|
|
}
|
|
|
|
export function getBlockSuiteEditorTitle(page: Page) {
|
|
return page.locator('.affine-doc-page-block-title').nth(0);
|
|
}
|
|
|
|
export async function type(page: Page, content: string, delay = 50) {
|
|
await page.keyboard.type(content, { delay });
|
|
}
|
|
|
|
export async function pressEnter(page: Page) {
|
|
// avoid flaky test by simulate real user input
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
}
|
|
|
|
export const createLinkedPage = async (page: Page, pageName?: string) => {
|
|
await page.keyboard.type('@', { delay: 50 });
|
|
const linkedPagePopover = page.locator('.linked-page-popover');
|
|
await expect(linkedPagePopover).toBeVisible();
|
|
if (pageName) {
|
|
await type(page, pageName);
|
|
} else {
|
|
pageName = 'Untitled';
|
|
}
|
|
|
|
await page.keyboard.press('ArrowUp');
|
|
await page.keyboard.press('ArrowUp');
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
};
|
|
|
|
export async function clickPageMoreActions(page: Page) {
|
|
return page
|
|
.getByTestId('header')
|
|
.getByTestId('header-dropDownButton')
|
|
.click();
|
|
}
|