refactor(core): lazy create copilot session and context (#10170)

This commit is contained in:
akumatus
2025-02-14 14:48:46 +00:00
parent 5a42edf076
commit 631c8b8145
11 changed files with 179 additions and 170 deletions

View File

@@ -104,12 +104,14 @@ const clearChat = async (page: Page) => {
};
const collectChat = async (page: Page) => {
await page.waitForTimeout(ONE_SECOND);
const chatPanel = await page.waitForSelector('.chat-panel-messages');
if (await chatPanel.$('.chat-panel-messages-placeholder')) {
return [];
}
// wait ai response
await page.waitForSelector('.chat-panel-messages .message chat-copy-more');
await page.waitForTimeout(ONE_SECOND);
const lastMessage = await chatPanel.$$('.message').then(m => m[m.length - 1]);
await lastMessage.waitForSelector('chat-copy-more');
await page.waitForTimeout(ONE_SECOND);
@@ -489,7 +491,6 @@ test.describe('chat panel', () => {
await page.getByTestId('chat-network-search').click();
await typeChatSequentially(page, 'What is the weather in Shanghai today?');
await page.keyboard.press('Enter');
await page.waitForTimeout(3000);
let history = await collectChat(page);
expect(history[0]).toEqual({
name: 'You',
@@ -505,7 +506,6 @@ test.describe('chat panel', () => {
await page.getByTestId('chat-network-search').click();
await typeChatSequentially(page, 'What is the weather in Shanghai today?');
await page.keyboard.press('Enter');
await page.waitForTimeout(3000);
history = await collectChat(page);
expect(history[0]).toEqual({
name: 'You',
@@ -859,7 +859,6 @@ test.describe('chat with doc', () => {
await typeChatSequentially(page, 'What is AFFiNE AI?');
await page.keyboard.press('Enter');
await page.waitForTimeout(3000);
const history = await collectChat(page);
expect(history[0]).toEqual({
name: 'You',