mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 06:16:59 +08:00
fix(core): unable to copy the selected ai answer content across multiple lines (#11806)
> CLOSE AI-76
This commit is contained in:
@@ -358,6 +358,7 @@ export const createTextRenderer: (
|
|||||||
) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => {
|
) => AffineAIPanelWidgetConfig['answerRenderer'] = (host, options) => {
|
||||||
return (answer, state) => {
|
return (answer, state) => {
|
||||||
return html`<text-renderer
|
return html`<text-renderer
|
||||||
|
contenteditable="false"
|
||||||
.host=${host}
|
.host=${host}
|
||||||
.answer=${answer}
|
.answer=${answer}
|
||||||
.state=${state}
|
.state=${state}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { copyByKeyboard } from '@affine-test/kit/utils/keyboard';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
import { test } from '../base/base-test';
|
import { test } from '../base/base-test';
|
||||||
@@ -330,7 +331,6 @@ test.describe('AIBasic/Chat', () => {
|
|||||||
await utils.chatPanel.clearChat(page);
|
await utils.chatPanel.clearChat(page);
|
||||||
await utils.chatPanel.waitForHistory(page, []);
|
await utils.chatPanel.waitForHistory(page, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should support copying answer', async ({
|
test('should support copying answer', async ({
|
||||||
loggedInPage: page,
|
loggedInPage: page,
|
||||||
utils,
|
utils,
|
||||||
@@ -360,6 +360,58 @@ test.describe('AIBasic/Chat', () => {
|
|||||||
}).toPass({ timeout: 5000 });
|
}).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 ({
|
test('chat with ask ai input in page mode', async ({
|
||||||
loggedInPage: page,
|
loggedInPage: page,
|
||||||
utils,
|
utils,
|
||||||
|
|||||||
@@ -319,7 +319,8 @@ export class EditorUtils {
|
|||||||
) {
|
) {
|
||||||
// Create tag
|
// Create tag
|
||||||
const tags = await page.getByTestId('explorer-tags');
|
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');
|
const input = await page.getByTestId('rename-modal-input');
|
||||||
await input.focus();
|
await input.focus();
|
||||||
await input.pressSequentially(tagName);
|
await input.pressSequentially(tagName);
|
||||||
|
|||||||
Reference in New Issue
Block a user