mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 08:36:22 +08:00
91ad783973
#### PR Dependency Tree * **PR #14749** 👈 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 * **Bug Fixes** * Improved link preview reliability by updating request identification to better match modern browsers. * **Tests** * Made end-to-end and integration tests deterministic and more robust, improving AI chat, image generation, attachment handling, settings visibility, and editor flows. * **Chores** * Updated underlying tooling versions to enhance stability and compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import { expect } from '@playwright/test';
|
|
|
|
import { test } from '../base/base-test';
|
|
|
|
test.describe('AIInsertion/SaveAsBlock', () => {
|
|
test.beforeEach(async ({ loggedInPage: page, utils }) => {
|
|
await utils.testUtils.setupTestEnvironment(page);
|
|
await utils.chatPanel.openChatPanel(page);
|
|
});
|
|
|
|
test('should save content as a chat block in page mode', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
await utils.chatPanel.openChatPanel(page);
|
|
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
|
|
|
await utils.chatPanel.waitForHistory(page, [
|
|
{
|
|
role: 'user',
|
|
content: 'Hello. Answer in 50 words.',
|
|
},
|
|
{
|
|
role: 'assistant',
|
|
status: 'success',
|
|
},
|
|
]);
|
|
|
|
const { actions } = await utils.chatPanel.getLatestAssistantMessage(page);
|
|
await actions.saveAsBlock();
|
|
await page.getByText('Successfully saved chat to a block').waitFor();
|
|
|
|
await utils.editor.isEdgelessMode(page);
|
|
|
|
await page.waitForSelector('affine-edgeless-ai-chat');
|
|
const aiBlock = await page.locator('affine-edgeless-ai-chat');
|
|
await expect(aiBlock).toBeVisible();
|
|
});
|
|
|
|
test('should save content as a chat block in edgeless mode', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
await utils.editor.switchToEdgelessMode(page);
|
|
|
|
await utils.chatPanel.openChatPanel(page);
|
|
await utils.chatPanel.makeChat(page, 'Hello. Answer in 50 words.');
|
|
|
|
await utils.chatPanel.waitForHistory(page, [
|
|
{
|
|
role: 'user',
|
|
content: 'Hello. Answer in 50 words.',
|
|
},
|
|
{
|
|
role: 'assistant',
|
|
status: 'success',
|
|
},
|
|
]);
|
|
|
|
const { actions } = await utils.chatPanel.getLatestAssistantMessage(page);
|
|
await actions.saveAsBlock();
|
|
await page.getByText('Successfully saved chat to a block');
|
|
|
|
// Verify the ai block is created
|
|
await page.waitForSelector('affine-edgeless-ai-chat');
|
|
const aiBlock = await page.locator('affine-edgeless-ai-chat');
|
|
await expect(aiBlock).toBeVisible();
|
|
});
|
|
});
|