2023-01-03 16:57:33 +03:00
|
|
|
import type { Page } from '@playwright/test';
|
2023-05-18 08:18:40 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-01-03 16:57:33 +03:00
|
|
|
|
2023-06-07 12:31:54 +03:00
|
|
|
export async function waitEditorLoad(page: Page) {
|
|
|
|
await page.waitForSelector('v-line', {
|
|
|
|
timeout: 10000,
|
|
|
|
});
|
2023-03-28 08:25:16 +03:00
|
|
|
}
|
|
|
|
|
2023-01-03 16:57:33 +03:00
|
|
|
export async function newPage(page: Page) {
|
2023-03-01 10:40:01 +03:00
|
|
|
// fixme(himself65): if too fast, the page will crash
|
2023-03-27 21:41:04 +03:00
|
|
|
await page.getByTestId('new-page-button').click({
|
2023-03-01 10:40:01 +03:00
|
|
|
delay: 100,
|
|
|
|
});
|
2023-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-03-02 20:38:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getBlockSuiteEditorTitle(page: Page) {
|
2023-07-27 08:37:38 +03:00
|
|
|
return page.locator('.affine-default-page-block-title').nth(0);
|
2022-12-30 21:32:59 +03:00
|
|
|
}
|
|
|
|
|
2023-05-18 08:18:40 +03:00
|
|
|
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 });
|
|
|
|
};
|
|
|
|
|
2023-01-03 16:57:33 +03:00
|
|
|
export async function clickPageMoreActions(page: Page) {
|
2022-12-30 21:32:59 +03:00
|
|
|
return page
|
|
|
|
.getByTestId('editor-header-items')
|
2023-03-01 10:40:01 +03:00
|
|
|
.getByTestId('editor-option-menu')
|
2022-12-30 21:32:59 +03:00
|
|
|
.click();
|
|
|
|
}
|