snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-16 04:01:20 +05:00
commit 702cc698a7
9990 changed files with 1073618 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/BrainstormIdeasWithMindMap', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate a mind map for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { brainstormMindMap } = await utils.editor.askAIWithText(
page,
'Panda'
);
const { answer, responses } = await brainstormMindMap();
await expect(answer.locator('mini-mindmap-preview')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate a mind map for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { brainstormMindMap } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'Panda');
}
);
const { answer, responses } = await brainstormMindMap();
await expect(answer.locator('mini-mindmap-preview')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate a mind map for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { brainstormMindMap } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'Panda');
}
);
const { answer, responses } = await brainstormMindMap();
await expect(answer.locator('mini-mindmap-preview')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
});

View File

@@ -0,0 +1,87 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/ChangeTone', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support changing the tone of the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { changeTone } = await utils.editor.askAIWithText(
page,
'AFFiNE is a great note-taking app'
);
const { answer, responses } = await changeTone('informal');
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support changing the tone of the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { changeTone } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a great note-taking app'
);
}
);
const { answer, responses } = await changeTone('informal');
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support changing the tone of the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { changeTone } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a great note-taking app'
);
}
);
const { answer, responses } = await changeTone('informal');
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { changeTone } = await utils.editor.askAIWithText(
page,
'AFFiNE is a great note-taking app'
);
const { answer } = await changeTone('informal');
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Change tone/);
await expect(actionName).toHaveText(/Change tone/);
});
});

View File

@@ -0,0 +1,55 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/CheckCodeError', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support check code error', async ({
loggedInPage: page,
utils,
}) => {
const { checkCodeError } = await utils.editor.askAIWithCode(
page,
'console.log("Hello,World!"',
'javascript'
);
const { answer, responses } = await checkCodeError();
const answerText = await answer.innerText();
expect(answerText).toMatch(/syntax|parenthesis|unexpected|missing/i);
expect(answerText).not.toMatch(/No syntax errors were found/i);
await expect(responses).toEqual(
new Set(['insert-below', 'replace-selection'])
);
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { checkCodeError } = await utils.editor.askAIWithCode(
page,
'consloe.log("Hello,World!");',
'javascript'
);
const { answer } = await checkCodeError();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await utils.chatPanel.waitForHistory(page, [{ role: 'action' }]);
const {
message,
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(
message.getByTestId('original-text').locator('affine-code')
).toBeVisible();
await expect(panelAnswer).toHaveText(/console/);
await expect(prompt).toHaveText(/Check the code error of the follow code/);
await expect(actionName).toHaveText(/Check code error/);
});
});

View File

@@ -0,0 +1,20 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/ContinueWithAI', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
});
test('should support continue in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { continueWithAi } = await utils.editor.askAIWithText(page, 'Apple');
await continueWithAi();
const chatPanelInput = await page.getByTestId('chat-panel-input-container');
const quote = await chatPanelInput.getByTestId('chat-selection-quote');
await expect(quote).toHaveText(/Apple/, { timeout: 10000 });
});
});

View File

@@ -0,0 +1,92 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/ContinueWriting', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support continue writing the selected content', async ({
loggedInPage: page,
utils,
}) => {
await page.setViewportSize({ width: 1280, height: 2000 });
const { continueWriting } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await continueWriting();
await expect(answer).toHaveText(/,*/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support continue writing the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { continueWriting } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await continueWriting();
await expect(answer).toHaveText(/,*/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support continue writing the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { continueWriting } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await continueWriting();
await expect(answer).toHaveText(/,*/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { continueWriting } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await continueWriting();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await utils.chatPanel.waitForHistory(
page,
[
{
role: 'action',
},
],
10000
);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/,*/);
await expect(prompt).toHaveText(/Continue the following text/);
await expect(actionName).toHaveText(/Continue writing/);
});
});

View File

@@ -0,0 +1,38 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('expand mindmap node', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should expand the mindmap node', async ({
loggedInPage: page,
utils,
}) => {
let id: string;
const { expandMindMapNode } = await utils.editor.askAIWithEdgeless(
page,
async () => {
id = await utils.editor.createMindmap(page);
},
async () => {
// Select the first child in the mindmap
const { id: childId } = await utils.editor.getMindMapNode(
page,
id!,
[0, 0]
);
await utils.editor.selectElementInEdgeless(page, [childId]);
}
);
await expandMindMapNode();
// Child node should be expanded
await expect(async () => {
const newChild = await utils.editor.getMindMapNode(page, id!, [0, 0, 0]);
expect(newChild).toBeDefined();
}).toPass({ timeout: 60000 });
});
});

View File

@@ -0,0 +1,47 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/ExplainCode', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support explain code', async ({ loggedInPage: page, utils }) => {
const { explainCode } = await utils.editor.askAIWithCode(
page,
'console.log("Hello, World!");',
'javascript'
);
const { answer } = await explainCode();
await expect(answer).toContainText(/(console\.log|Hello,\s*World)/i);
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { explainCode } = await utils.editor.askAIWithCode(
page,
'console.log("Hello, World!");',
'javascript'
);
const { answer } = await explainCode();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await utils.chatPanel.waitForHistory(page, [{ role: 'action' }]);
const {
message,
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(
message.getByTestId('original-text').locator('affine-code')
).toBeVisible();
await expect(panelAnswer).toHaveText(/console.log/);
await expect(prompt).toHaveText(/Analyze and explain the follow code/);
await expect(actionName).toHaveText(/Explain this code/);
});
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,87 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/ExplainSelection', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support explaining the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { explainSelection } = await utils.editor.askAIWithText(
page,
'LLM(AI)'
);
const { answer, responses } = await explainSelection();
await expect(answer).toHaveText(
/Large Language Model|LLM|artificial intelligence/i,
{ timeout: 20000 }
);
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support explaining the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { explainSelection } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'LLM(AI)');
}
);
const { answer, responses } = await explainSelection();
await expect(answer).toHaveText(
/Large Language Model|LLM|artificial intelligence/i,
{ timeout: 20000 }
);
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support explaining the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { explainSelection } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'LLM(AI)');
}
);
const { answer, responses } = await explainSelection();
await expect(answer).toHaveText(
/Large Language Model|LLM|artificial intelligence/i,
{ timeout: 20000 }
);
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { explainSelection } = await utils.editor.askAIWithText(page, 'LLM');
const { answer } = await explainSelection();
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/Large Language Model/);
await expect(prompt).toHaveText(/Analyze and explain the follow text/);
await expect(actionName).toHaveText(/Explain this/);
});
});

View File

@@ -0,0 +1,146 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/FindActions', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should find actions for selected content', async ({
loggedInPage: page,
utils,
}) => {
const { findActions } = await utils.editor.askAIWithText(
page,
`Choose a Booking Platform
Enter Travel Details
Compare and Select Flights`
);
const { answer, responses } = await findActions();
const todos = await answer.locator('affine-list').all();
const expectedTexts = [
/Choose a Booking Platform/i,
/Enter Travel Details/i,
/Compare and Select Flights/i,
];
await Promise.all(
todos.map(async (todo, index) => {
await expect(
todo.locator('.affine-list-block__todo-prefix')
).toBeVisible();
await expect(todo).toHaveText(expectedTexts[index]);
})
);
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should find actions for selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { findActions } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'Choose a Booking Platform'
);
}
);
const { answer, responses } = await findActions();
const todos = await answer.locator('affine-list').all();
const expectedTexts = [
/Choose a Booking Platform/i,
/Enter Travel Details/i,
/Compare and Select Flights/i,
];
await Promise.all(
todos.map(async (todo, index) => {
await expect(
todo.locator('.affine-list-block__todo-prefix')
).toBeVisible();
await expect(todo).toHaveText(expectedTexts[index]);
})
);
expect(responses).toEqual(new Set(['insert-below']));
});
test('should find actions for selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { findActions } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'Choose a Booking Platform'
);
}
);
const { answer, responses } = await findActions();
const todos = await answer.locator('affine-list').all();
const expectedTexts = [
/Choose a Booking Platform/i,
/Enter Travel Details/i,
/Compare and Select Flights/i,
];
await Promise.all(
todos.map(async (todo, index) => {
await expect(
todo.locator('.affine-list-block__todo-prefix')
).toBeVisible();
await expect(todo).toHaveText(expectedTexts[index]);
})
);
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { findActions } = await utils.editor.askAIWithText(
page,
`Choose a Booking Platform
Enter Travel Details
Compare and Select Flights`
);
const { answer } = await findActions();
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
const todos = await panelAnswer.locator('affine-list').all();
const expectedTexts = [
/Choose a Booking Platform/i,
/Enter Travel Details/i,
/Compare and Select Flights/i,
];
await Promise.all(
todos.map(async (todo, index) => {
await expect(
todo.locator('.affine-list-block__todo-prefix')
).toBeVisible();
await expect(todo).toHaveText(expectedTexts[index]);
})
);
await expect(prompt).toHaveText(/Find action items of the follow text/);
await expect(actionName).toHaveText(/Find action items from it/);
});
});

View File

@@ -0,0 +1,84 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/FixGrammar', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support fixing grammatical errors in the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { fixGrammar } = await utils.editor.askAIWithText(
page,
'I is a student'
);
const { answer, responses } = await fixGrammar();
await expect(answer).toHaveText(/I am a student/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support fixing grammatical errors in the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { fixGrammar } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'I is a student');
}
);
const { answer, responses } = await fixGrammar();
await expect(answer).toHaveText(/I am a student/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support fixing grammatical errors in the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { fixGrammar } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'I is a student');
}
);
const { answer, responses } = await fixGrammar();
await expect(answer).toHaveText(/I am a student/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { fixGrammar } = await utils.editor.askAIWithText(
page,
'I is a student'
);
const { answer } = await fixGrammar();
await expect(answer).toHaveText(/I am a student/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/I am a student/);
await expect(prompt).toHaveText(
/Improve the grammar of the following text/
);
await expect(actionName).toHaveText(/Improve grammar for it/);
});
});

View File

@@ -0,0 +1,78 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/FixSpelling', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support fixing spelling errors in the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { fixSpelling } = await utils.editor.askAIWithText(page, 'Appel');
const { answer, responses } = await fixSpelling();
await expect(answer).toHaveText(/Apple/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support fixing spelling errors in the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { fixSpelling } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'Appel');
}
);
const { answer, responses } = await fixSpelling();
await expect(answer).toHaveText(/Apple/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support fixing spelling errors in the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { fixSpelling } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'Appel');
}
);
const { answer, responses } = await fixSpelling();
await expect(answer).toHaveText(/Apple/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { fixSpelling } = await utils.editor.askAIWithText(page, 'Appel');
const { answer } = await fixSpelling();
await expect(answer).toHaveText(/Apple/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/Apple/);
await expect(prompt).toHaveText(
/Correct the spelling of the following text/
);
await expect(actionName).toHaveText(/Fix spelling for it/);
});
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/GenerateAnImageWithText', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate an image for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithText(page, 'Panda');
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an image for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'Panda');
}
);
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an image for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'Panda');
}
);
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an image for the selected shape in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createShape(page, 'HelloWorld');
}
);
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithText(page, 'Panda');
const { answer } = await generateImage();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await page.waitForSelector('.affine-image-container');
await page.reload();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const { answer: panelAnswer, actionName } =
await utils.chatPanel.getLatestAIActionMessage(page);
await expect(
panelAnswer.getByTestId('generated-image').locator('img')
).toBeVisible();
await expect(actionName).toHaveText(/image/);
});
});

View File

@@ -0,0 +1,108 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/GenerateHeadings', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate headings for selected content', async ({
loggedInPage: page,
utils,
}) => {
const { generateHeadings } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await generateHeadings();
await Promise.race([
answer.locator('h1').isVisible(),
answer.locator('h2').isVisible(),
answer.locator('h3').isVisible(),
]);
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-above', 'replace-selection']));
});
test('should generate headings for selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateHeadings } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await generateHeadings();
await Promise.race([
answer.locator('h1').isVisible(),
answer.locator('h2').isVisible(),
answer.locator('h3').isVisible(),
]);
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate headings for selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateHeadings } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await generateHeadings();
await Promise.race([
answer.locator('h1').isVisible(),
answer.locator('h2').isVisible(),
answer.locator('h3').isVisible(),
]);
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { generateHeadings } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await generateHeadings();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await Promise.race([
panelAnswer.locator('h1').isVisible(),
panelAnswer.locator('h2').isVisible(),
panelAnswer.locator('h3').isVisible(),
]);
await expect(prompt).toHaveText(/Create headings of the follow text/);
await expect(actionName).toHaveText(/Create headings/);
});
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/GenerateOutline', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate outline for selected content', async ({
loggedInPage: page,
utils,
}) => {
const { generateOutline } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await generateOutline();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should generate outline for selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateOutline } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await generateOutline();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate outline for selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateOutline } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await generateOutline();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { generateOutline } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await generateOutline();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Write an outline about this/);
await expect(actionName).toHaveText(/Write outline/);
});
});

View File

@@ -0,0 +1,61 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/GeneratePresentation', () => {
test.describe.configure({ timeout: 240000 });
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate a presentation for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { generatePresentation } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await generatePresentation();
await expect(answer.locator('ai-slides-renderer')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate a presentation for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generatePresentation } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await generatePresentation();
await expect(answer.locator('ai-slides-renderer')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate a presentation for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generatePresentation } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await generatePresentation();
await expect(answer.locator('ai-slides-renderer')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/ImproveWriting', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support improving the writing of the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { improveWriting } = await utils.editor.askAIWithText(
page,
'AFFiNE is so smart'
);
const { answer, responses } = await improveWriting();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support improving the writing of the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { improveWriting } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'AFFiNE is so smart');
}
);
const { answer, responses } = await improveWriting();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support improving the writing of the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { improveWriting } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'AFFiNE is so smart');
}
);
const { answer, responses } = await improveWriting();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { improveWriting } = await utils.editor.askAIWithText(
page,
'AFFiNE is so smart'
);
const { answer } = await improveWriting();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Improve the follow text/);
await expect(actionName).toHaveText(/Improve writing for it/);
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/MakeItLonger', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support making the selected content longer', async ({
loggedInPage: page,
utils,
}) => {
const { makeItLonger } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await makeItLonger();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support making the selected text block longer in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItLonger } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await makeItLonger();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected note block longer in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItLonger } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await makeItLonger();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { makeItLonger } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await makeItLonger();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Expand the following text/);
await expect(actionName).toHaveText(/Make it longer/);
});
});

View File

@@ -0,0 +1,91 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/MakeItReal', () => {
test.describe.configure({ timeout: 180000 });
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support making the selected content to real', async ({
loggedInPage: page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithText(page, 'Hello');
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected text block to real in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'Hello');
}
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected note block to real in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'Hello');
}
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected element to real in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createShape(page, 'HelloWorld');
}
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithText(page, 'Hello');
const { answer } = await makeItReal();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer.locator('affine-code')).toBeVisible();
await expect(prompt).toHaveText(/Write a web page of follow text/);
await expect(actionName).toHaveText(/Make it real with text/);
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/MakeItShorter', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support making the selected content shorter', async ({
loggedInPage: page,
utils,
}) => {
const { makeItShorter } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await makeItShorter();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support making the selected text block shorter in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItShorter } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await makeItShorter();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected note block shorter in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { makeItShorter } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await makeItShorter();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { makeItShorter } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await makeItShorter();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Shorten the follow text/);
await expect(actionName).toHaveText(/Make it shorter/);
});
});

View File

@@ -0,0 +1,35 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/RegenerateMindMap', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support regenerate the mind map for mindmap root', async ({
loggedInPage: page,
utils,
}) => {
let id: string;
const { regenerateMindMap } = await utils.editor.askAIWithEdgeless(
page,
async () => {
id = await utils.editor.createMindmap(page);
},
async () => {
const { id: rootId } = await utils.editor.getMindMapNode(
page,
id!,
[0]
);
await utils.editor.selectElementInEdgeless(page, [rootId]);
}
);
const { answer, responses } = await regenerateMindMap();
await expect(answer.locator('mini-mindmap-preview')).toBeVisible();
expect(responses).toEqual(new Set(['replace-selection']));
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/Summarize', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support summarizing the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { summarize } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await summarize();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support summarizing the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { summarize } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await summarize();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support summarizing the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { summarize } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await summarize();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { summarize } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await summarize();
await expect(answer).toHaveText(/AFFiNE/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Summary the follow text/);
await expect(actionName).toHaveText(/Summary/);
});
});

View File

@@ -0,0 +1,74 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/Translate', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should support translating the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { translate } = await utils.editor.askAIWithText(page, 'Apple');
const { answer, responses } = await translate('Simplified Chinese');
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support translating the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { translate } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'Apple');
}
);
const { answer, responses } = await translate('Simplified Chinese');
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support translating the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { translate } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'Apple');
}
);
const { answer, responses } = await translate('Simplified Chinese');
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { translate } = await utils.editor.askAIWithText(page, 'Apple');
const { answer } = await translate('Simplified Chinese');
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/苹果/);
await expect(prompt).toHaveText(/Translate/);
await expect(actionName).toHaveText(/Translate/);
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/WriteAnArticleAboutThis', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate an article for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { writeArticle } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await writeArticle();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support writing an article for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writeArticle } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writeArticle();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support writing an article for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writeArticle } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writeArticle();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { writeArticle } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await writeArticle();
await expect(answer).toHaveText(/AFFiNE/);
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Write an article about this/);
await expect(actionName).toHaveText(/Write an article about this/);
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/WriteAnBlogPostAboutThis', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate an blog post for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { writeBlogPost } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await writeBlogPost();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should support writing an blog post for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writeBlogPost } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writeBlogPost();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support writing an blog post for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writeBlogPost } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writeBlogPost();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { writeBlogPost } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await writeBlogPost();
await expect(answer).toHaveText(/AFFiNE/);
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Write a blog post about this/);
await expect(actionName).toHaveText(/Write a blog post about this/);
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/WriteAnPoemAboutThis', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate an poem for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { writePoem } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await writePoem();
await expect(answer.locator('text-renderer')).toContainText(/\S/);
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should generate an poem for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writePoem } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writePoem();
await expect(answer.locator('text-renderer')).toContainText(/\S/);
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an poem for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writePoem } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writePoem();
await expect(answer.locator('text-renderer')).toContainText(/\S/);
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { writePoem } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await writePoem();
await expect(answer).toHaveText(/AFFiNE/);
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Write a poem about this/);
await expect(actionName).toHaveText(/Write a poem about this/);
});
});

View File

@@ -0,0 +1,86 @@
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/WriteAnTweetAboutThis', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate an tweet for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { writeTwitterPost } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await writeTwitterPost();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
});
test('should generate an tweet for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writeTwitterPost } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writeTwitterPost();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an tweet for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { writeTwitterPost } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await writeTwitterPost();
await expect(answer).toHaveText(/AFFiNE/);
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { writeTwitterPost } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await writeTwitterPost();
await expect(answer).toHaveText(/AFFiNE/);
const replace = answer.getByTestId('answer-replace');
await replace.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer).toHaveText(/AFFiNE/);
await expect(prompt).toHaveText(/Write a twitter about this/);
await expect(actionName).toHaveText(/Write a twitter about this/);
});
});