mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
test(core): chat with collection & tags (#11388)
### TL:DR * AI chat with collection E2E * AI chat with tag E2E > Close BS-3007
This commit is contained in:
@@ -1,3 +1,79 @@
|
||||
import { loginUser } from '@affine-test/kit/utils/cloud';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { test } from '../base/base-test';
|
||||
|
||||
test.describe('AIChatWith/Collections', () => {});
|
||||
test.describe('AIChatWith/Collections', () => {
|
||||
test.beforeEach(async ({ page, utils }) => {
|
||||
const user = await utils.testUtils.getUser();
|
||||
await loginUser(page, user);
|
||||
await utils.testUtils.setupTestEnvironment(page);
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
|
||||
// Create two collections
|
||||
await utils.editor.createCollectionAndDoc(
|
||||
page,
|
||||
'Collection 1',
|
||||
'EEee is a cute cat'
|
||||
);
|
||||
await utils.editor.createCollectionAndDoc(
|
||||
page,
|
||||
'Collection 2',
|
||||
'FFff is a cute dog'
|
||||
);
|
||||
});
|
||||
|
||||
test('should support chat with collection', async ({ page, utils }) => {
|
||||
await utils.chatPanel.chatWithCollections(page, ['Collection 1']);
|
||||
await utils.chatPanel.makeChat(page, 'What is EEee(Use English)');
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'What is EEee(Use English)',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
status: 'success',
|
||||
},
|
||||
]);
|
||||
|
||||
await expect(async () => {
|
||||
const { content, message } =
|
||||
await utils.chatPanel.getLatestAssistantMessage(page);
|
||||
expect(content).toMatch(/EEee.*cat/);
|
||||
expect(await message.locator('affine-footnote-node').count()).toBe(1);
|
||||
}).toPass();
|
||||
});
|
||||
|
||||
test('should support chat with multiple collections', async ({
|
||||
page,
|
||||
utils,
|
||||
}) => {
|
||||
await utils.chatPanel.chatWithCollections(page, [
|
||||
'Collection 1',
|
||||
'Collection 2',
|
||||
]);
|
||||
await utils.chatPanel.makeChat(
|
||||
page,
|
||||
'What is EEee? What is FFff?(Use English)'
|
||||
);
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'What is EEee? What is FFff?(Use English)',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
status: 'success',
|
||||
},
|
||||
]);
|
||||
|
||||
await expect(async () => {
|
||||
const { content, message } =
|
||||
await utils.chatPanel.getLatestAssistantMessage(page);
|
||||
expect(content).toMatch(/EEee.*cat/);
|
||||
expect(content).toMatch(/FFff.*dog/);
|
||||
expect(await message.locator('affine-footnote-node').count()).toBe(2);
|
||||
}).toPass();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,61 @@
|
||||
import { loginUser } from '@affine-test/kit/utils/cloud';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { test } from '../base/base-test';
|
||||
|
||||
test.describe('AIChatWith/tags', () => {});
|
||||
test.describe('AIChatWith/tags', () => {
|
||||
test.beforeEach(async ({ page, utils }) => {
|
||||
const user = await utils.testUtils.getUser();
|
||||
await loginUser(page, user);
|
||||
await utils.testUtils.setupTestEnvironment(page);
|
||||
await utils.chatPanel.openChatPanel(page);
|
||||
await utils.editor.createTagAndDoc(page, 'Tag 1', 'EEee is a cute cat');
|
||||
await utils.editor.createTagAndDoc(page, 'Tag 2', 'FFff is a cute dog');
|
||||
});
|
||||
|
||||
test('should support chat with tag', async ({ page, utils }) => {
|
||||
await utils.chatPanel.chatWithTags(page, ['Tag 1']);
|
||||
await utils.chatPanel.makeChat(page, 'What is EEee(Use English)');
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'What is EEee(Use English)',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
status: 'success',
|
||||
},
|
||||
]);
|
||||
await expect(async () => {
|
||||
const { content, message } =
|
||||
await utils.chatPanel.getLatestAssistantMessage(page);
|
||||
expect(content).toMatch(/EEee.*cat/);
|
||||
expect(await message.locator('affine-footnote-node').count()).toBe(1);
|
||||
}).toPass();
|
||||
});
|
||||
|
||||
test('should support chat with multiple tags', async ({ page, utils }) => {
|
||||
await utils.chatPanel.chatWithTags(page, ['Tag 1', 'Tag 2']);
|
||||
await utils.chatPanel.makeChat(
|
||||
page,
|
||||
'What is EEee? What is FFff?(Use English)'
|
||||
);
|
||||
await utils.chatPanel.waitForHistory(page, [
|
||||
{
|
||||
role: 'user',
|
||||
content: 'What is EEee? What is FFff?(Use English)',
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
status: 'success',
|
||||
},
|
||||
]);
|
||||
await expect(async () => {
|
||||
const { content, message } =
|
||||
await utils.chatPanel.getLatestAssistantMessage(page);
|
||||
expect(content).toMatch(/EEee.*cat/);
|
||||
expect(content).toMatch(/FFff.*dog/);
|
||||
expect(await message.locator('affine-footnote-node').count()).toBe(2);
|
||||
}).toPass();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user