fix(editor): paste surface-ref block to another doc as embed-linked-doc block (#10274)

[BS-2155](https://linear.app/affine-design/issue/BS-2155/复制-insert-frame-group-粘贴后,应当变为-block-ref-link)
This commit is contained in:
donteatfriedrice
2025-02-19 07:02:26 +00:00
parent 751f229e30
commit 319d909ac8
6 changed files with 98 additions and 15 deletions

View File

@@ -1,5 +1,10 @@
import { test } from '@affine-test/kit/playwright';
import { pasteContent } from '@affine-test/kit/utils/clipboard';
import {
clickEdgelessModeButton,
clickPageModeButton,
locateEditorContainer,
} from '@affine-test/kit/utils/editor';
import {
copyByKeyboard,
pasteByKeyboard,
@@ -8,6 +13,7 @@ import {
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
getBlockSuiteEditorTitle,
type,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
@@ -141,3 +147,62 @@ test.describe('paste in multiple blocks text selection', () => {
await verifyParagraphContent(page, 3, 'test world');
});
});
test('paste surface-ref block to another doc as embed-linked-doc block', async ({
page,
}) => {
await openHomePage(page);
await clickNewPageButton(page, 'Clipboard Test');
await waitForEditorLoad(page);
await clickEdgelessModeButton(page);
const container = locateEditorContainer(page);
await container.click();
// add a shape
await page.keyboard.press('s');
// click to add a shape
await container.click({ position: { x: 100, y: 500 } });
await page.waitForTimeout(50);
// add a frame
await page.keyboard.press('f');
await page.waitForTimeout(50);
// click on the frame title to trigger the change frame button toolbar
const frameTitle = page.locator('affine-frame-title');
await frameTitle.click();
await page.waitForTimeout(50);
const changeFrameButton = page.locator('edgeless-change-frame-button');
// get insert into page button which with aria-label 'Insert into Page'
const insertIntoPageButton = changeFrameButton.locator(
`editor-icon-button[aria-label="Insert into Page"]`
);
await insertIntoPageButton.click();
await clickPageModeButton(page);
await page.waitForTimeout(50);
// copy surface-ref block
const surfaceRefBlock = page.locator('.affine-surface-ref');
await surfaceRefBlock.click();
await page.waitForTimeout(50);
await copyByKeyboard(page);
// paste to another doc
await clickNewPageButton(page);
await waitForEditorLoad(page);
const title2 = getBlockSuiteEditorTitle(page);
await title2.pressSequentially('page2');
await page.keyboard.press('Enter');
await page.waitForTimeout(50);
// paste the surface-ref block
await pasteByKeyboard(page);
await page.waitForTimeout(50);
const embedLinkedDocBlock = page.locator('affine-embed-linked-doc-block');
await expect(embedLinkedDocBlock).toBeVisible();
const embedLinkedDocBlockTitle = embedLinkedDocBlock.locator(
'.affine-embed-linked-doc-content-title-text'
);
await expect(embedLinkedDocBlockTitle).toHaveText('Clipboard Test');
});