Sometimes, missing `await` in the test code can cause timing issues, leading to test failures. This PR enables the `no-floating-promises` rule for the test code to ensure that such errors do not occur.
### TL:DR
By sharing initialization logic, accelerate test case execution.
### What Changed
* Global setup for copilot e2e
* Login
* Create Workspace
* Enable fully parallel for ci
### Optimization Comparison
Comparing with PR [fix(core): ask AI input box in the whiteboard is blocked by the menu …](https://github.com/toeverything/AFFiNE/pull/11634):
| | Shard 1 |2|3|4|5|6|7|8|
| ------|----|----|----|----|----|---|---|--|
|Before|15min|14min|14min|14min|14min|13min|15min|10min|
|After|8min|11min|8min|8min|8min|8min|8min|7min|
### Trade-Off
Since all copilot use cases currently share a single user and workspace, some test cases need to focus on **isolation** and **independence**.
For example, when testing Embedding-related workflows:
* Different document contents should be used to avoid interference.
* After each test case execution, **cleanup** operations are also required.
* Some tests should be configured to **serial** mode.
```ts
test.describe.configure({ mode: 'serial' });
test.describe('AIChatWith/Collections', () => {
test.beforeEach(async ({ loggedInPage: page, utils }) => {
await utils.testUtils.setupTestEnvironment(page);
await utils.chatPanel.openChatPanel(page);
await utils.editor.clearAllCollections(page);
await utils.testUtils.createNewPage(page);
});
test.afterEach(async ({ loggedInPage: page, utils }) => {
// clear all collections
await utils.editor.clearAllCollections(page);
});
test('should support chat with collection', async ({
loggedInPage: page,
utils,
}) => {
// Create two collections
await utils.editor.createCollectionAndDoc(
page,
'Collection 1',
'CollectionAAaa is a cute dog'
);
await utils.chatPanel.chatWithCollections(page, ['Collection 1']);
await utils.chatPanel.makeChat(page, 'What is CollectionAAaa(Use English)');
// ...
});
test('should support chat with multiple collections', async ({
loggedInPage: page,
utils,
}) => {
// Create two collections
await utils.editor.createCollectionAndDoc(
page,
'Collection 2',
'CollectionEEee is a cute cat'
);
await utils.editor.createCollectionAndDoc(
page,
'Collection 3',
'CollectionFFff is a cute dog'
);
await utils.chatPanel.chatWithCollections(page, [
'Collection 2',
'Collection 3',
]);
await utils.chatPanel.makeChat(
page,
'What is CollectionEEee? What is CollectionFFff?(Use English)'
);
// ...
});
});
```
> CLOSE AI-51
### TL;DR
Split and enhance copilot e2e tests.
### What Changed
#### Tests Structure
The e2e tests are organized into the following categories:
1. **Basic Tests (`/basic`)**: Tests for verifying core AI capabilities including feature onboarding, authorization workflows, and basic chat interactions.
2. **Chat Interaction Tests (`/chat-with`)**: Tests for verifying the AI's interaction with various object types, such as attachments, images, text content, Edgeless elements, etc.
3. **AI Action Tests (`/ai-action`)**: Tests for verifying the AI's actions, such as text translation, gramma correction, etc.
4. **Insertion Tests (`/insertion`)**: Tests for verifying answer insertion functionality.
#### Tests Writing
Writing a copilot test cases is easier and clear
e.g.
```ts
test('support chat with specified doc', async ({ page, utils }) => {
// Initialize the doc
await focusDocTitle(page);
await page.keyboard.insertText('Test Doc');
await page.keyboard.press('Enter');
await page.keyboard.insertText('EEee is a cute cat');
await utils.chatPanel.chatWithDoc(page, 'Test Doc');
await utils.chatPanel.makeChat(page, 'What is EEee?');
await utils.chatPanel.waitForHistory(page, [
{
role: 'user',
content: 'What is EEee?',
},
{
role: 'assistant',
status: 'success',
},
]);
const { content } = await utils.chatPanel.getLatestAssistantMessage(page);
expect(content).toMatch(/EEee/);
});
```
#### Summary
||Cases|
|------|----|
|Before|19||
|After|151||
> Close BS-2769