Files
AFFiNE-Mirror/tests/affine-cloud-copilot/e2e/ai-action/generate-an-image-with-text.spec.ts
T
Wu Yue b2c09825ac feat(core): do not show AI actions in history (#13198)
Close [AI-351](https://linear.app/affine-design/issue/AI-351)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Disabled action updates related to document IDs and sessions in the AI
chat content panel.

* **Tests**
* Skipped all end-to-end tests for the "should show chat history in chat
panel" scenario across various AI action test suites. These tests will
no longer run during automated testing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-14 07:53:14 +00:00

91 lines
2.9 KiB
TypeScript

import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/GenerateAnImageWithText', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
});
test('should generate an image for the selected content', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithText(page, 'Panda');
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an image for the selected text block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(page, 'Panda');
}
);
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an image for the selected note block in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(page, 'Panda');
}
);
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test('should generate an image for the selected shape in edgeless', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createShape(page, 'HelloWorld');
}
);
const { answer, responses } = await generateImage();
await expect(answer.getByTestId('ai-answer-image')).toBeVisible();
expect(responses).toEqual(new Set(['insert-below']));
});
test.skip('should show chat history in chat panel', async ({
loggedInPage: page,
utils,
}) => {
const { generateImage } = await utils.editor.askAIWithText(page, 'Panda');
const { answer } = await generateImage();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await page.waitForSelector('.affine-image-container');
await page.reload();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const { answer: panelAnswer, actionName } =
await utils.chatPanel.getLatestAIActionMessage(page);
await expect(
panelAnswer.getByTestId('generated-image').locator('img')
).toBeVisible();
await expect(actionName).toHaveText(/image/);
});
});