Files
AFFiNE-Mirror/tests/affine-cloud-copilot/e2e/ai-action/make-it-real.spec.ts
yoyoyohamapi 030af6f426 test(core): edgeless shape e2e (#11446)
### TL;DR

Add Edgeless shape ai e2e tests.

### What Changed

- Add Edgeless shape make it real e2e
- Add Edgeless shape generate image e2e
- Fix Edgeless generate headings e2e
2025-04-03 16:53:20 +00:00

102 lines
3.2 KiB
TypeScript

import { loginUser } from '@affine-test/kit/utils/cloud';
import { expect } from '@playwright/test';
import { test } from '../base/base-test';
test.describe('AIAction/MakeItReal', () => {
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);
});
test('should support making the selected content to real', async ({
page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected text block to real in edgeless', async ({
page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessText(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected note block to real in edgeless', async ({
page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createEdgelessNote(
page,
'AFFiNE is a workspace with fully merged docs'
);
}
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should support making the selected element to real in edgeless', async ({
page,
utils,
}) => {
const { makeItReal } = await utils.editor.askAIWithEdgeless(
page,
async () => {
await utils.editor.createShape(page, 'HelloWorld');
}
);
const { answer, responses } = await makeItReal();
await expect(answer.locator('iframe')).toBeVisible({ timeout: 30000 });
expect(responses).toEqual(new Set(['insert-below']));
});
test('should show chat history in chat panel', async ({ page, utils }) => {
const { makeItReal } = await utils.editor.askAIWithText(
page,
'AFFiNE is a workspace with fully merged docs'
);
const { answer } = await makeItReal();
const insert = answer.getByTestId('answer-insert-below');
await insert.click();
await utils.chatPanel.waitForHistory(page, [
{
role: 'action',
},
]);
const {
answer: panelAnswer,
prompt,
actionName,
} = await utils.chatPanel.getLatestAIActionMessage(page);
await expect(panelAnswer.locator('affine-code')).toBeVisible();
await expect(prompt).toHaveText(/Write a web page of follow text/);
await expect(actionName).toHaveText(/Make it real with text/);
});
});