AFFiNE/tests/kit/utils/page-logic.ts

54 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-01-03 16:57:33 +03:00
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
2023-01-03 16:57:33 +03:00
export async function waitForEditorLoad(page: Page) {
await page.waitForSelector('v-line', {
timeout: 10000,
});
2023-03-28 08:25:16 +03:00
}
2023-08-11 09:59:06 +03:00
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,
});
}
2023-09-02 08:57:04 +03:00
export async function clickNewPageButton(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,
});
await waitForEditorLoad(page);
}
export function getBlockSuiteEditorTitle(page: Page) {
2023-08-05 02:55:28 +03:00
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 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) {
return page
.getByTestId('header')
2023-08-08 20:14:24 +03:00
.getByTestId('header-dropDownButton')
.click();
}