mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
feat(core): completely remove the dependence on EditorHost (#13110)
Close [AI-260](https://linear.app/affine-design/issue/AI-260) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added theme support to AI chat and message components, enabling dynamic theming based on the current app theme. * Introduced a reactive theme signal to the theme service for improved theme handling. * Integrated notification and theme services across various AI chat, playground, and message components for consistent user experience. * **Refactor** * Simplified component APIs by removing dependencies on editor host and related properties across AI chat, message, and tool components. * Centralized and streamlined clipboard and markdown conversion utilities, reducing external dependencies. * Standardized the interface for context file addition and improved type usage for better consistency. * Reworked notification service to a class-based implementation for improved encapsulation. * Updated AI chat components to use injected notification and theme services instead of host-based retrieval. * **Bug Fixes** * Improved reliability of copy and notification actions by decoupling them from editor host dependencies. * **Chores** * Updated and cleaned up internal imports and removed unused properties to enhance maintainability. * Added test IDs for sidebar close button to improve test reliability. * Updated test prompts in end-to-end tests for consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -19,14 +19,14 @@ test.describe('AIBasic/Authority', () => {
|
||||
page,
|
||||
utils,
|
||||
}) => {
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await expect(page.getByTestId('ai-error')).toBeVisible();
|
||||
await expect(page.getByTestId('ai-error-action-button')).toBeVisible();
|
||||
});
|
||||
|
||||
test('should support login in error state', async ({ page, utils }) => {
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
const loginButton = page.getByTestId('ai-error-action-button');
|
||||
await loginButton.click();
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ test.describe('AIInsertion/AddToEdgelessAsNote', () => {
|
||||
utils,
|
||||
}) => {
|
||||
await utils.editor.focusToEditor(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -47,12 +47,12 @@ test.describe('AIInsertion/AddToEdgelessAsNote', () => {
|
||||
await page.keyboard.press('Delete');
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
|
||||
@@ -22,12 +22,12 @@ test.describe('AIInsertion/Insert', () => {
|
||||
await page.keyboard.insertText('World Block');
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -60,12 +60,12 @@ test.describe('AIInsertion/Insert', () => {
|
||||
await page.keyboard.insertText('World Block');
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -101,12 +101,12 @@ test.describe('AIInsertion/Insert', () => {
|
||||
await page.keyboard.insertText('World Block');
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -139,12 +139,12 @@ test.describe('AIInsertion/Insert', () => {
|
||||
await page.keyboard.insertText('World Block');
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -173,12 +173,12 @@ test.describe('AIInsertion/Insert', () => {
|
||||
await page.keyboard.press('Delete');
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
|
||||
@@ -13,12 +13,12 @@ test.describe('AIInsertion/SaveAsBlock', () => {
|
||||
utils,
|
||||
}) => {
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -45,12 +45,12 @@ test.describe('AIInsertion/SaveAsBlock', () => {
|
||||
await utils.editor.switchToEdgelessMode(page);
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
|
||||
@@ -13,12 +13,12 @@ test.describe('AIInsertion/SaveAsDoc', () => {
|
||||
utils,
|
||||
}) => {
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
@@ -45,12 +45,12 @@ test.describe('AIInsertion/SaveAsDoc', () => {
|
||||
await utils.editor.switchToEdgelessMode(page);
|
||||
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.chatPanel.makeChat(page, 'Hello');
|
||||
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
||||
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'Hello',
|
||||
content: 'Hello. Answer in 50 words.',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
|
||||
@@ -37,7 +37,7 @@ export class ChatPanelUtils {
|
||||
}
|
||||
|
||||
public static async closeChatPanel(page: Page) {
|
||||
await page.getByTestId('right-sidebar-toggle').click({
|
||||
await page.getByTestId('right-sidebar-close').click({
|
||||
delay: 200,
|
||||
});
|
||||
await expect(page.getByTestId('sidebar-tab-content-chat')).toBeHidden();
|
||||
|
||||
Reference in New Issue
Block a user