Files
upstream-affine/tests/blocksuite/e2e/edgeless/frame/clipboard.spec.ts
upstream-mirror 702cc698a7
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
2026-09-16 04:01:20 +05:00

163 lines
5.3 KiB
TypeScript

import type { Page } from '@playwright/test';
import { clickView, moveView } from '../../utils/actions/click.js';
import {
autoFit,
createFrame as _createFrame,
createShapeElement,
deleteAll,
dragBetweenViewCoords,
edgelessCommonSetup,
getAllSortedIds,
getFirstContainerId,
getIds,
Shape,
shiftClickView,
triggerComponentToolbarAction,
zoomResetByKeyboard,
} from '../../utils/actions/edgeless.js';
import {
copyByKeyboard,
pasteByKeyboard,
pressBackspace,
pressEscape,
} from '../../utils/actions/keyboard.js';
import { assertContainerOfElements } from '../../utils/asserts.js';
import { test } from '../../utils/playwright.js';
const createFrame = async (
page: Page,
coord1: [number, number],
coord2: [number, number]
) => {
await _createFrame(page, coord1, coord2);
await autoFit(page);
};
test.beforeEach(async ({ page }) => {
await edgelessCommonSetup(page);
await zoomResetByKeyboard(page);
});
test.describe('frame copy and paste', () => {
test('copy of frame should keep relationship of child elements', async ({
page,
}) => {
await createFrame(page, [50, 50], [450, 450]);
await createShapeElement(page, [200, 200], [300, 300], Shape.Square);
const frameTitle = page.locator('affine-frame-title');
await pressEscape(page);
await frameTitle.click();
await copyByKeyboard(page);
await deleteAll(page);
await moveView(page, [500, 500]); // center copy
await pasteByKeyboard(page);
const frameId = await getFirstContainerId(page);
const shapeId = (await getAllSortedIds(page)).filter(id => id !== frameId);
await assertContainerOfElements(page, shapeId, frameId);
});
test('copy of frame by alt/option dragging should keep relationship of child elements', async ({
page,
}) => {
await createFrame(page, [50, 50], [450, 450]);
await createShapeElement(page, [200, 200], [300, 300], Shape.Square);
await createShapeElement(page, [250, 250], [350, 350], Shape.Square);
await createShapeElement(page, [300, 300], [400, 400], Shape.Square);
await pressEscape(page);
const frameTitles = page.locator('affine-frame-title');
await shiftClickView(page, [260, 260]);
await shiftClickView(page, [310, 310]);
await triggerComponentToolbarAction(page, 'addGroup');
await pressEscape(page);
await frameTitles.nth(0).click();
await page.keyboard.down('Alt');
await dragBetweenViewCoords(page, [60, 60], [460, 460]);
await page.keyboard.up('Alt');
await pressEscape(page);
await frameTitles.nth(0).click({ modifiers: ['Shift'] });
await shiftClickView(page, [250, 250]);
await shiftClickView(page, [350, 350]);
await pressBackspace(page); // remove original elements
const frameId = await getFirstContainerId(page);
const groupId = await getFirstContainerId(page, [frameId]);
const shapeIds = (await getIds(page)).filter(
id => ![frameId, groupId].includes(id)
);
await assertContainerOfElements(page, [groupId], frameId);
await assertContainerOfElements(page, [shapeIds[0]], frameId);
await assertContainerOfElements(page, [shapeIds[1]], groupId);
await assertContainerOfElements(page, [shapeIds[2]], groupId);
});
test('duplicate element in frame', async ({ page }) => {
await createFrame(page, [50, 50], [450, 450]);
await createShapeElement(page, [100, 100], [200, 200], Shape.Square);
await pressEscape(page);
const frameTitles = page.locator('affine-frame-title');
await frameTitles.nth(0).click();
const moreMenu = page.getByLabel('More menu');
await moreMenu.click();
await moreMenu
.locator('editor-menu-action', { hasText: 'Duplicate' })
.click();
await pressEscape(page);
await frameTitles.nth(0).click();
await shiftClickView(page, [150, 150]);
await pressBackspace(page); // remove original elements
const frameId = await getFirstContainerId(page);
const shapeIds = (await getIds(page)).filter(id => id !== frameId);
await assertContainerOfElements(page, shapeIds, frameId);
});
test('copy of element by alt/option dragging in frame should belong to frame', async ({
page,
}) => {
await createFrame(page, [50, 50], [450, 450]);
await createShapeElement(page, [100, 100], [200, 200], Shape.Square);
await pressEscape(page);
await clickView(page, [150, 150]);
await page.keyboard.down('Alt');
await dragBetweenViewCoords(page, [150, 150], [250, 250]);
await page.keyboard.up('Alt');
const frameId = await getFirstContainerId(page);
const shapeIds = (await getIds(page)).filter(id => id !== frameId);
await assertContainerOfElements(page, shapeIds, frameId);
});
test('copy of element by alt/option dragging out of frame should not belong to frame', async ({
page,
}) => {
await createFrame(page, [50, 50], [450, 450]);
await createShapeElement(page, [100, 100], [200, 200], Shape.Square);
await pressEscape(page);
await clickView(page, [150, 150]);
await page.keyboard.down('Alt');
await dragBetweenViewCoords(page, [150, 150], [550, 550]);
await page.keyboard.up('Alt');
const frameId = await getFirstContainerId(page);
const shapeIds = (await getIds(page)).filter(id => id !== frameId);
await assertContainerOfElements(page, [shapeIds[0]], frameId);
await assertContainerOfElements(page, [shapeIds[1]], null);
});
});