Files
AFFiNE-Mirror/tests/affine-cloud-copilot/e2e/chat-with/attachments.spec.ts
DarkSky 9c55edeb62 feat(server): adapt gemini3.1 preview (#14583)
#### PR Dependency Tree


* **PR #14583** 👈

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 Gemini 3.1 Pro Preview support (text, image, audio) and new
GPT‑5 variants as defaults; centralized persistent telemetry state for
more reliable client identity.

* **UX**
  * Improved model submenu placement in chat preferences.
* More robust mindmap parsing, preview, regeneration and replace
behavior.

* **Chores**
  * Bumped AI SDK and related dependencies.

* **Tests**
  * Expanded/updated tests and increased timeouts for flaky flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-03-08 00:53:16 +08:00

100 lines
2.7 KiB
TypeScript

import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe.configure({ mode: 'serial' });
test.describe('AIChatWith/Attachments', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(
page,
'claude-sonnet-4-5@20250929'
);
await utils.chatPanel.openChatPanel(page);
});
test('support chat with attachment', async ({
loggedInPage: page,
utils,
}) => {
const textContent = 'AttachmentEEee is a cute cat';
const buffer = Buffer.from(textContent);
await utils.chatPanel.chatWithAttachments(
page,
[
{
name: 'test.txt',
mimeType: 'text/plain',
buffer: buffer,
},
],
'What is AttachmentEEee?'
);
await utils.chatPanel.waitForHistory(page, [
{
role: 'user',
content: 'What is AttachmentEEee?',
},
{
role: 'assistant',
status: 'success',
},
]);
await expect(async () => {
const { content } = await utils.chatPanel.getLatestAssistantMessage(page);
expect(content).toMatch(/EEee/);
}).toPass({ timeout: 10000 });
});
test('support chat with multiple attachments', async ({
loggedInPage: page,
utils,
}) => {
const randomStr1 = Math.random().toString(36).substring(2, 6);
const randomStr2 = Math.random().toString(36).substring(2, 6);
const textContent1 = `Attachment${randomStr1} is a cute cat`;
const textContent2 = `Attachment${randomStr2} is a cute dog`;
const buffer1 = Buffer.from(textContent1);
const buffer2 = Buffer.from(textContent2);
await utils.chatPanel.chatWithAttachments(
page,
[
{
name: 'document1.txt',
mimeType: 'text/plain',
buffer: buffer1,
},
{
name: 'document2.txt',
mimeType: 'text/plain',
buffer: buffer2,
},
],
`Which animal is Attachment${randomStr1} and which animal is Attachment${randomStr2}? Answer with both attachment names.`
);
await utils.chatPanel.waitForHistory(page, [
{
role: 'user',
content: `Which animal is Attachment${randomStr1} and which animal is Attachment${randomStr2}? Answer with both attachment names.`,
},
{
role: 'assistant',
status: 'success',
},
]);
await expect(async () => {
const { content } = await utils.chatPanel.getLatestAssistantMessage(page);
expect(content).toMatch(new RegExp(`Attachment${randomStr1}`));
expect(content).toMatch(new RegExp(`Attachment${randomStr2}`));
expect(content).toMatch(/cat/i);
expect(content).toMatch(/dog/i);
}).toPass({ timeout: 20000 });
});
});