mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 07:17:00 +08:00
> CLOSE AF-2774 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated translation tests to use Simplified Chinese instead of German as the target language. * Adjusted expected results in assertions to match Chinese characters "苹果" instead of the German word "Apfel" across relevant test cases. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
75 lines
2.5 KiB
TypeScript
75 lines
2.5 KiB
TypeScript
import { expect } from '@playwright/test';
|
|
|
|
import { test } from '../base/base-test';
|
|
|
|
test.describe('AIAction/Translate', () => {
|
|
test.beforeEach(async ({ loggedInPage: page, utils }) => {
|
|
await utils.testUtils.setupTestEnvironment(page);
|
|
await utils.chatPanel.openChatPanel(page);
|
|
});
|
|
|
|
test('should support translating the selected content', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
const { translate } = await utils.editor.askAIWithText(page, 'Apple');
|
|
const { answer, responses } = await translate('Simplified Chinese');
|
|
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
|
|
expect(responses).toEqual(new Set(['insert-below', 'replace-selection']));
|
|
});
|
|
|
|
test('should support translating the selected text block in edgeless', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
const { translate } = await utils.editor.askAIWithEdgeless(
|
|
page,
|
|
async () => {
|
|
await utils.editor.createEdgelessText(page, 'Apple');
|
|
}
|
|
);
|
|
const { answer, responses } = await translate('Simplified Chinese');
|
|
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
|
|
expect(responses).toEqual(new Set(['insert-below']));
|
|
});
|
|
|
|
test('should support translating the selected note block in edgeless', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
const { translate } = await utils.editor.askAIWithEdgeless(
|
|
page,
|
|
async () => {
|
|
await utils.editor.createEdgelessNote(page, 'Apple');
|
|
}
|
|
);
|
|
const { answer, responses } = await translate('Simplified Chinese');
|
|
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
|
|
expect(responses).toEqual(new Set(['insert-below']));
|
|
});
|
|
|
|
test.skip('should show chat history in chat panel', async ({
|
|
loggedInPage: page,
|
|
utils,
|
|
}) => {
|
|
const { translate } = await utils.editor.askAIWithText(page, 'Apple');
|
|
const { answer } = await translate('Simplified Chinese');
|
|
await expect(answer).toHaveText(/苹果/, { timeout: 10000 });
|
|
const replace = answer.getByTestId('answer-replace');
|
|
await replace.click();
|
|
await utils.chatPanel.waitForHistory(page, [
|
|
{
|
|
role: 'action',
|
|
},
|
|
]);
|
|
const {
|
|
answer: panelAnswer,
|
|
prompt,
|
|
actionName,
|
|
} = await utils.chatPanel.getLatestAIActionMessage(page);
|
|
await expect(panelAnswer).toHaveText(/苹果/);
|
|
await expect(prompt).toHaveText(/Translate/);
|
|
await expect(actionName).toHaveText(/Translate/);
|
|
});
|
|
});
|