### 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
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { testResultDir } from '@affine-test/kit/playwright';
|
|
import type {
|
|
PlaywrightTestConfig,
|
|
PlaywrightWorkerOptions,
|
|
} from '@playwright/test';
|
|
|
|
const config: PlaywrightTestConfig = {
|
|
testDir: './e2e',
|
|
fullyParallel: true,
|
|
timeout: 120_000,
|
|
outputDir: testResultDir,
|
|
globalSetup: './global-setup.ts',
|
|
use: {
|
|
baseURL: 'http://localhost:8080/',
|
|
browserName:
|
|
(process.env.BROWSER as PlaywrightWorkerOptions['browserName']) ??
|
|
'chromium',
|
|
permissions: ['clipboard-read', 'clipboard-write'],
|
|
viewport: { width: 1440, height: 800 },
|
|
actionTimeout: 10 * 1000,
|
|
locale: 'en-US',
|
|
trace: 'retain-on-failure',
|
|
video: 'retain-on-failure',
|
|
},
|
|
forbidOnly: !!process.env.CI,
|
|
workers: 4,
|
|
retries: 3,
|
|
reporter: process.env.CI ? 'github' : 'list',
|
|
webServer: [
|
|
{
|
|
command: 'yarn run -T affine dev -p @affine/web',
|
|
port: 8080,
|
|
stdout: 'ignore',
|
|
stderr: 'ignore',
|
|
timeout: 120 * 1000,
|
|
reuseExistingServer: !process.env.CI,
|
|
env: {
|
|
COVERAGE: process.env.COVERAGE || 'false',
|
|
},
|
|
},
|
|
{
|
|
command: 'yarn run -T affine dev -p @affine/server',
|
|
port: 3010,
|
|
timeout: 120 * 1000,
|
|
reuseExistingServer: !process.env.CI,
|
|
stdout: 'ignore',
|
|
stderr: 'ignore',
|
|
env: {
|
|
DATABASE_URL:
|
|
process.env.DATABASE_URL ??
|
|
'postgresql://affine:affine@localhost:5432/affine',
|
|
NODE_ENV: 'test',
|
|
AFFINE_ENV: process.env.AFFINE_ENV ?? 'dev',
|
|
DEBUG: 'affine:*',
|
|
FORCE_COLOR: 'true',
|
|
DEBUG_COLORS: 'true',
|
|
MAILER_HOST: '0.0.0.0',
|
|
MAILER_PORT: '1025',
|
|
MAILER_SENDER: 'noreply@toeverything.info',
|
|
MAILER_USER: 'noreply@toeverything.info',
|
|
MAILER_PASSWORD: 'affine',
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
if (process.env.CI) {
|
|
config.retries = 3;
|
|
}
|
|
|
|
export default config;
|