diff --git a/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts b/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts index f14bb3f9d7..32f336923b 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/text-renderer.ts @@ -358,6 +358,7 @@ export const createTextRenderer: ( ) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => { return (answer, state) => { return html` { await utils.chatPanel.clearChat(page); await utils.chatPanel.waitForHistory(page, []); }); - test('should support copying answer', async ({ loggedInPage: page, utils, @@ -360,6 +360,58 @@ test.describe('AIBasic/Chat', () => { }).toPass({ timeout: 5000 }); }); + test('should support copying selected answer content', async ({ + loggedInPage: page, + utils, + }) => { + await utils.chatPanel.openChatPanel(page); + await utils.chatPanel.makeChat( + page, + 'Help me write a two-line love poem, return two paragraphs for me.' + ); + await utils.chatPanel.waitForHistory(page, [ + { + role: 'user', + content: + 'Help me write a two-line love poem, return two paragraphs for me.', + }, + { + role: 'assistant', + status: 'success', + }, + ]); + + await expect(async () => { + const { content, message } = + await utils.chatPanel.getLatestAssistantMessage(page); + // Select multiple rich text + const firstParagraph = await message + .locator('affine-paragraph rich-text v-text') + .first() + .boundingBox(); + const lastParagraph = await message + .locator('affine-paragraph rich-text v-text') + .last() + .boundingBox(); + + if (firstParagraph && lastParagraph) { + await page.mouse.move(firstParagraph.x, firstParagraph.y); + await page.mouse.down(); + await page.mouse.move( + lastParagraph.x + lastParagraph.width, + lastParagraph.y + lastParagraph.height + ); + await page.mouse.up(); + } + + await copyByKeyboard(page); + const clipboardText = await page.evaluate(() => + navigator.clipboard.readText() + ); + expect(clipboardText).toBe(content); + }).toPass({ timeout: 5000 }); + }); + test('chat with ask ai input in page mode', async ({ loggedInPage: page, utils, diff --git a/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts b/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts index 3608ce32eb..c3a5bda722 100644 --- a/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts +++ b/tests/affine-cloud-copilot/e2e/utils/editor-utils.ts @@ -319,7 +319,8 @@ export class EditorUtils { ) { // Create tag const tags = await page.getByTestId('explorer-tags'); - await tags.getByTestId('explorer-bar-add-favorite-button').click(); + await tags.hover(); + await tags.getByTestId('explorer-bar-add-tag-button').click(); const input = await page.getByTestId('rename-modal-input'); await input.focus(); await input.pressSequentially(tagName);