AFFiNE/tests/libs/page-logic.ts

48 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-01-03 16:57:33 +03:00
import type { Page } from '@playwright/test';
2023-03-28 08:25:16 +03:00
export async function waitMarkdownImported(page: Page) {
return page.evaluate(
() =>
new Promise(resolve => {
document.addEventListener('markdown:imported', resolve);
})
);
}
2023-01-03 16:57:33 +03:00
export async function newPage(page: Page) {
// fixme(himself65): if too fast, the page will crash
2023-03-27 21:41:04 +03:00
await page.getByTestId('new-page-button').click({
delay: 100,
});
2023-03-07 05:11:49 +03:00
await page.waitForSelector('v-line');
}
export function getBlockSuiteEditorTitle(page: Page) {
2023-03-07 05:11:49 +03:00
return page.locator('v-line').nth(0);
}
2023-01-03 16:57:33 +03:00
export async function clickPageMoreActions(page: Page) {
return page
.getByTestId('editor-header-items')
.getByTestId('editor-option-menu')
.click();
}
export async function createPinboardPage(
page: Page,
parentId: string,
title: string
) {
await newPage(page);
await page.focus('.affine-default-page-block-title');
await page.type('.affine-default-page-block-title', title, {
delay: 100,
});
await clickPageMoreActions(page);
await page.getByTestId('move-to-menu-item').click();
await page
.getByTestId('pinboard-menu')
.getByTestId(`pinboard-${parentId}`)
.click();
}