mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
Closes: [BS-2239](https://linear.app/affine-design/issue/BS-2239/不应该通过window注入affine的api)
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
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();
|
|
});
|