mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
chore: remove legacy tests (#9183)
This commit is contained in:
@@ -1,28 +1,23 @@
|
||||
import { join } from 'node:path';
|
||||
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
import { focusInlineEditor } from './page-logic';
|
||||
export async function importImage(page: Page, pathInFixtures: string) {
|
||||
await page.evaluate(() => {
|
||||
// Force fallback to input[type=file] in tests
|
||||
// See https://github.com/microsoft/playwright/issues/8850
|
||||
// @ts-expect-error allow
|
||||
window.showOpenFilePicker = undefined;
|
||||
});
|
||||
|
||||
export async function importImage(page: Page, url: string) {
|
||||
await focusInlineEditor(page);
|
||||
await page.evaluate(
|
||||
([url]) => {
|
||||
const clipData = {
|
||||
'text/html': `<img alt={'Sample image'} src=${url} />`,
|
||||
};
|
||||
const e = new ClipboardEvent('paste', {
|
||||
clipboardData: new DataTransfer(),
|
||||
});
|
||||
Object.defineProperty(e, 'target', {
|
||||
writable: false,
|
||||
value: document,
|
||||
});
|
||||
Object.entries(clipData).forEach(([key, value]) => {
|
||||
e.clipboardData?.setData(key, value);
|
||||
});
|
||||
document.dispatchEvent(e);
|
||||
},
|
||||
[url]
|
||||
);
|
||||
const fileChooser = page.waitForEvent('filechooser');
|
||||
|
||||
// open slash menu
|
||||
await page.keyboard.type('/image', { delay: 50 });
|
||||
await page.keyboard.press('Enter');
|
||||
await (
|
||||
await fileChooser
|
||||
).setFiles(join(__dirname, '../../fixtures', pathInFixtures));
|
||||
// TODO(@catsjuice): wait for image to be loaded more reliably
|
||||
await page.waitForTimeout(1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user