refactor(editor): add native clipboard extension (#9502)
Closes: [BS-2239](https://linear.app/affine-design/issue/BS-2239/不应该通过window注入affine的api)
This commit is contained in:
52
tests/affine-desktop/e2e/image.spec.ts
Normal file
52
tests/affine-desktop/e2e/image.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import { importImage } from '@affine-test/kit/utils/image';
|
||||
import { pasteByKeyboard } from '@affine-test/kit/utils/keyboard';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
getBlockSuiteEditorTitle,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
test('should be able to insert SVG images', async ({ page }) => {
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await importImage(page, 'affine.svg');
|
||||
|
||||
const svg = page.locator('affine-image').first();
|
||||
await expect(svg).toBeVisible();
|
||||
});
|
||||
|
||||
test('should paste it as PNG after copying SVG', async ({ page }) => {
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await importImage(page, 'affine.svg');
|
||||
|
||||
const svg = page.locator('affine-image').first();
|
||||
await expect(svg).toBeVisible();
|
||||
|
||||
await svg.hover();
|
||||
|
||||
await page.waitForTimeout(500);
|
||||
const imageToolbar = page.locator('affine-image-toolbar');
|
||||
await expect(imageToolbar).toBeVisible();
|
||||
await imageToolbar.getByRole('button', { name: 'More' }).click();
|
||||
|
||||
const moveMenu = page.locator('.image-more-popup-menu');
|
||||
await moveMenu.getByRole('button', { name: /^Copy$/ }).click();
|
||||
|
||||
await svg.click();
|
||||
|
||||
await page.keyboard.press('Enter');
|
||||
await pasteByKeyboard(page);
|
||||
|
||||
const png = page.locator('affine-image').nth(1);
|
||||
await expect(png).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user