test(core): add e2e test for share page copy function (#11555)

related pr https://github.com/toeverything/AFFiNE/pull/11538
To close [BS-1915](https://linear.app/affine-design/issue/BS-1915/public-page-页面应该允许选中和复制内容)
This commit is contained in:
donteatfriedrice
2025-04-10 06:34:15 +00:00
parent e376aa57c5
commit dbb8451adb
3 changed files with 81 additions and 23 deletions

View File

@@ -3,6 +3,8 @@ import { pasteContent } from '@affine-test/kit/utils/clipboard';
import {
clickEdgelessModeButton,
clickPageModeButton,
getCodeBlockIds,
getParagraphIds,
locateEditorContainer,
} from '@affine-test/kit/utils/editor';
import {
@@ -84,28 +86,6 @@ async function verifyCodeBlockContent(
);
}
// Helper function to get block ids
async function getBlockIds<T extends BlockComponent>(
page: Page,
selector: string
) {
const blocks = page.locator(selector);
const blockIds = await blocks.evaluateAll((blocks: T[]) =>
blocks.map(block => block.model.id)
);
return { blockIds };
}
// Helper functions using the generic getBlockIds
async function getParagraphIds(page: Page) {
return getBlockIds<ParagraphBlockComponent>(page, paragraphLocator);
}
// Helper functions using the generic getBlockIds
async function getCodeBlockIds(page: Page) {
return getBlockIds<CodeBlockComponent>(page, codeBlockLocator);
}
test.beforeEach(async ({ page }) => {
await openHomePage(page);
await clickNewPageButton(page, 'Clipboard Test');