mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-12 14:40:22 +08:00
ee899a267b
#### PR Dependency Tree * **PR #15448** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added workspace artifact upload, browsing, removal, deduplication, and library ownership support. * Copilot now supports scoped document and artifact search, canvas reading, live editor context, and frontend tools. * Added scope and focus selectors with source-resolution receipts in chat. * Added embedding health, progress, synchronization, and retrieval capabilities. * Added BYOK policy visibility, provider restrictions, endpoint dialect selection, and validation. * Added delegated editor interactions and userdata document authorization. * **Bug Fixes** * Improved attachment handling, cancellation, access control, retrieval fallbacks, workspace synchronization, and configuration validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
125 lines
3.9 KiB
TypeScript
125 lines
3.9 KiB
TypeScript
import { expect } from '@playwright/test';
|
|
|
|
import { test } from '../base/base-test';
|
|
|
|
test.describe.configure({ mode: 'serial' });
|
|
|
|
test.describe('AIChatWith/Collections', () => {
|
|
test.beforeEach(async ({ loggedInPage: page, utils }) => {
|
|
await utils.testUtils.setupTestEnvironment(page);
|
|
await utils.chatPanel.openChatPanel(page);
|
|
await utils.editor.clearAllCollections(page);
|
|
|
|
await utils.testUtils.createNewPage(page);
|
|
});
|
|
|
|
test.afterEach(async ({ loggedInPage: page, utils }) => {
|
|
// clear all collections
|
|
await utils.editor.clearAllCollections(page);
|
|
});
|
|
|
|
test('should support chat with collection', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
const randomStr = Math.random().toString(36).substring(2, 6);
|
|
// Create two collections
|
|
await utils.editor.createCollectionAndDoc(
|
|
page,
|
|
'Collection 1',
|
|
`Collection${randomStr} is a cute dog`
|
|
);
|
|
|
|
await utils.chatPanel.chatWithCollections(page, ['Collection 1']);
|
|
await utils.settings.openSettingsPanel(page);
|
|
await utils.settings.disableWorkspaceEmbedding(page);
|
|
await utils.settings.closeSettingsPanel(page);
|
|
await utils.chatPanel.makeChat(
|
|
page,
|
|
`What is Collection${randomStr}? Use English and answer with a citation.`
|
|
);
|
|
await expect(
|
|
page.getByText(
|
|
'One or more selected sources are unavailable. Check the sources or workspace AI indexing settings, then retry.'
|
|
)
|
|
).toBeVisible();
|
|
expect(
|
|
(await utils.chatPanel.collectHistory(page)).filter(
|
|
message => message.role === 'user'
|
|
)
|
|
).toHaveLength(1);
|
|
await utils.settings.openSettingsPanel(page);
|
|
await utils.settings.enableWorkspaceEmbedding(page);
|
|
await utils.settings.closeSettingsPanel(page);
|
|
await page.getByTestId('ai-error-action-button').click();
|
|
await utils.chatPanel.waitForHistory(page, [
|
|
{
|
|
role: 'user',
|
|
content: `What is Collection${randomStr}? Use English and answer with a citation.`,
|
|
},
|
|
{
|
|
role: 'assistant',
|
|
status: 'success',
|
|
},
|
|
]);
|
|
|
|
await expect(async () => {
|
|
const { content, message } =
|
|
await utils.chatPanel.getLatestAssistantMessage(page);
|
|
expect(content).toMatch(new RegExp(`Collection${randomStr}.*dog`));
|
|
expect(
|
|
await message.locator('affine-footnote-node').count()
|
|
).toBeGreaterThanOrEqual(1);
|
|
}).toPass();
|
|
});
|
|
|
|
test('should support chat with multiple collections', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
const randomStr1 = Math.random().toString(36).substring(2, 6);
|
|
const randomStr2 = Math.random().toString(36).substring(2, 6);
|
|
// Create two collections
|
|
await utils.editor.createCollectionAndDoc(
|
|
page,
|
|
'Collection 2',
|
|
`Collection${randomStr1} is a cute cat`
|
|
);
|
|
|
|
await utils.editor.createCollectionAndDoc(
|
|
page,
|
|
'Collection 3',
|
|
`Collection${randomStr2} is a cute dog`
|
|
);
|
|
|
|
await utils.chatPanel.chatWithCollections(page, [
|
|
'Collection 2',
|
|
'Collection 3',
|
|
]);
|
|
await utils.chatPanel.makeChat(
|
|
page,
|
|
`What is Collection${randomStr1}? What is Collection${randomStr2}? Use English and cite both sources.`
|
|
);
|
|
await utils.chatPanel.waitForHistory(page, [
|
|
{
|
|
role: 'user',
|
|
content: `What is Collection${randomStr1}? What is Collection${randomStr2}? Use English and cite both sources.`,
|
|
},
|
|
{
|
|
role: 'assistant',
|
|
status: 'success',
|
|
},
|
|
]);
|
|
|
|
await expect(async () => {
|
|
const { content, message } =
|
|
await utils.chatPanel.getLatestAssistantMessage(page);
|
|
expect(content).toMatch(new RegExp(`Collection${randomStr1}.*cat`));
|
|
expect(content).toMatch(new RegExp(`Collection${randomStr2}.*dog`));
|
|
expect(
|
|
await message.locator('affine-footnote-node').count()
|
|
).toBeGreaterThanOrEqual(2);
|
|
}).toPass();
|
|
});
|
|
});
|