mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(core): in edgeless mode, an error occurs when asking AI questions without selecting any content (#12437)
### TL;DR fix: in edgeless mode, an error occurs when asking AI questions without selecting any content > CLOSE AI-133 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for asking AI input in edgeless mode when no content is selected. - Enhanced AI panel behavior with improved input handling and chat message sending in edgeless mode. - **Bug Fixes** - Improved handling of AI chat input visibility and context extraction in edgeless mode. - **Tests** - Introduced new end-to-end tests to verify chat interactions with AI in edgeless mode. - Centralized editor content removal logic in test utilities for better maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -484,4 +484,31 @@ test.describe('AIBasic/Chat', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should support chat with ask ai input in edgeless mode when nothing selected', async ({
|
||||
loggedInPage: page,
|
||||
utils,
|
||||
}) => {
|
||||
await utils.chatPanel.closeChatPanel(page);
|
||||
await utils.editor.switchToEdgelessMode(page);
|
||||
await utils.editor.removeAll(page);
|
||||
|
||||
await page.mouse.move(300, 300);
|
||||
await page.mouse.down({ button: 'right' });
|
||||
await page.mouse.move(350, 350);
|
||||
await page.mouse.up({ button: 'right' });
|
||||
|
||||
await page.keyboard.type('Who are you?');
|
||||
await page.keyboard.press('Enter');
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Who are you?',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
status: 'success',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -386,14 +386,18 @@ export class EditorUtils {
|
||||
);
|
||||
}
|
||||
|
||||
public static async removeAll(page: Page) {
|
||||
await selectAllByKeyboard(page);
|
||||
await page.keyboard.press('Delete');
|
||||
}
|
||||
|
||||
public static async askAIWithEdgeless(
|
||||
page: Page,
|
||||
createBlock: () => Promise<void>,
|
||||
afterSelected?: () => Promise<void>
|
||||
) {
|
||||
await this.switchToEdgelessMode(page);
|
||||
await selectAllByKeyboard(page);
|
||||
await page.keyboard.press('Delete');
|
||||
await this.removeAll(page);
|
||||
await createBlock();
|
||||
await pressEscape(page, 5);
|
||||
await selectAllByKeyboard(page);
|
||||
|
||||
Reference in New Issue
Block a user