mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 16:16:46 +08:00
@@ -126,3 +126,16 @@ export async function getMetas(page: Page): Promise<PageMeta[]> {
|
||||
() => globalThis.currentWorkspace.blockSuiteWorkspace.meta.pageMetas ?? []
|
||||
);
|
||||
}
|
||||
|
||||
export async function waitForLogMessage(
|
||||
page: Page,
|
||||
log: string
|
||||
): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
page.on('console', msg => {
|
||||
if (msg.type() === 'log' && msg.text() === log) {
|
||||
resolve(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
newPage,
|
||||
waitMarkdownImported,
|
||||
} from '../libs/page-logic';
|
||||
import { waitForLogMessage } from '../libs/utils';
|
||||
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
||||
|
||||
test('New a page and open it ,then favorite it', async ({ page }) => {
|
||||
@@ -29,7 +30,7 @@ test('New a page and open it ,then favorite it', async ({ page }) => {
|
||||
await assertCurrentWorkspaceFlavour('local', page);
|
||||
});
|
||||
|
||||
test('Export to html and markdown', async ({ page }) => {
|
||||
test('Export to html, markdown and png', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitMarkdownImported(page);
|
||||
{
|
||||
@@ -47,6 +48,31 @@ test('Export to html and markdown', async ({ page }) => {
|
||||
await page.getByTestId('export-to-html').click();
|
||||
await downloadPromise;
|
||||
}
|
||||
await page.waitForTimeout(50);
|
||||
{
|
||||
await clickPageMoreActions(page);
|
||||
await page.getByTestId('export-menu').click();
|
||||
const downloadPromise = page.waitForEvent('download');
|
||||
await page.getByTestId('export-to-png').click();
|
||||
await downloadPromise;
|
||||
}
|
||||
});
|
||||
|
||||
test('Export to pdf', async ({ page }) => {
|
||||
const CheckedMessage = '[test] beforeprint event emitted';
|
||||
page.addInitScript(() => {
|
||||
window.addEventListener('beforeprint', () => {
|
||||
console.log(CheckedMessage);
|
||||
});
|
||||
});
|
||||
await openHomePage(page);
|
||||
await waitMarkdownImported(page);
|
||||
{
|
||||
await clickPageMoreActions(page);
|
||||
await page.getByTestId('export-menu').click();
|
||||
await page.getByTestId('export-to-pdf').click();
|
||||
expect(waitForLogMessage(page, CheckedMessage)).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
test('Cancel favorite', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user