chore: remove legacy tests (#9183)

This commit is contained in:
liuyi
2024-12-17 17:06:28 +08:00
committed by GitHub
parent 27d4aa7ca7
commit b0e64fe516
79 changed files with 45 additions and 12448 deletions

View File

@@ -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);
}