chore(infra): add url test to playwright (#11795)

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

- **Chores**
  - Updated Playwright test configurations to use full URL strings instead of port numbers for web server identification.
  - Unified server startup approach in test environments by integrating web server configuration directly into Playwright, replacing custom setup scripts.
  - Removed obsolete development server setup files to streamline test initialization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
EYHN
2025-05-21 04:07:46 +00:00
parent 1831d291f1
commit 4217bfe02d
8 changed files with 20 additions and 36 deletions

View File

@@ -1,26 +0,0 @@
import { BundleCommand } from '@affine-tools/cli/bundle';
import { Package } from '@affine-tools/utils/workspace';
export default async () => {
await new Promise<void>((resolve, reject) => {
BundleCommand.dev(new Package('@affine/web'), {
onListening: server => {
// dev server has already started
if (server.options.port !== 8080) {
server.compiler.close(reject);
server.stop().catch(reject);
resolve();
} else {
server.middleware?.waitUntilValid?.(stats => {
if (stats?.hasErrors()) {
reject(new Error('Webpack build failed'));
} else {
resolve();
}
});
}
},
}).catch(reject);
});
console.log('Dev server started');
};

View File

@@ -18,7 +18,6 @@ const config: PlaywrightTestConfig = {
fullyParallel: true,
timeout: process.env.CI ? 50_000 : 30_000,
outputDir: testResultDir,
globalSetup: './dev-server.ts',
use: {
baseURL: 'http://localhost:8080/',
browserName:
@@ -42,6 +41,17 @@ const config: PlaywrightTestConfig = {
// default 'list' when running locally
// See https://playwright.dev/docs/test-reporters#github-actions-annotations
reporter: process.env.CI ? 'github' : 'list',
webServer: [
{
command: 'yarn run -T affine dev -p @affine/web',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
},
url: 'http://localhost:8080',
},
],
};
if (process.env.CI) {