mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-02 02:00:49 +08:00
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:
@@ -29,7 +29,6 @@ const config: PlaywrightTestConfig = {
|
||||
webServer: [
|
||||
{
|
||||
command: 'yarn run -T affine dev -p @affine/web',
|
||||
port: 8080,
|
||||
stdout: 'ignore',
|
||||
stderr: 'ignore',
|
||||
timeout: 120 * 1000,
|
||||
@@ -37,10 +36,10 @@ const config: PlaywrightTestConfig = {
|
||||
env: {
|
||||
COVERAGE: process.env.COVERAGE || 'false',
|
||||
},
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
{
|
||||
command: 'yarn run -T affine dev -p @affine/server',
|
||||
port: 3010,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
stdout: 'ignore',
|
||||
@@ -60,6 +59,7 @@ const config: PlaywrightTestConfig = {
|
||||
MAILER_USER: 'noreply@toeverything.info',
|
||||
MAILER_PASSWORD: 'affine',
|
||||
},
|
||||
url: 'http://localhost:3010/graphql',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -32,16 +32,15 @@ const config: PlaywrightTestConfig = {
|
||||
// we could download the builds from archives
|
||||
// and then run the web with simple http serve, it's will be faster
|
||||
command: 'yarn run -T affine dev -p @affine/web',
|
||||
port: 8080,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
env: {
|
||||
COVERAGE: process.env.COVERAGE || 'false',
|
||||
},
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
{
|
||||
command: 'yarn run -T affine dev -p @affine/server',
|
||||
port: 3010,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
env: {
|
||||
@@ -59,6 +58,7 @@ const config: PlaywrightTestConfig = {
|
||||
MAILER_USER: 'noreply@toeverything.info',
|
||||
MAILER_PASSWORD: 'affine',
|
||||
},
|
||||
url: 'http://localhost:3010/graphql',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -24,7 +24,6 @@ const config: PlaywrightTestConfig = {
|
||||
// Intentionally not building the web, reminds you to run it by yourself.
|
||||
{
|
||||
command: 'yarn run -T affine dev -p @affine/electron-renderer',
|
||||
port: 8080,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
stdout: 'pipe',
|
||||
@@ -32,10 +31,10 @@ const config: PlaywrightTestConfig = {
|
||||
COVERAGE: process.env.COVERAGE || 'false',
|
||||
DISTRIBUTION: 'desktop',
|
||||
},
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
{
|
||||
command: 'yarn run -T affine dev -p @affine/server',
|
||||
port: 3010,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
stdout: 'pipe',
|
||||
@@ -51,6 +50,7 @@ const config: PlaywrightTestConfig = {
|
||||
DEBUG_COLORS: 'true',
|
||||
MAILER_SENDER: 'noreply@toeverything.info',
|
||||
},
|
||||
url: 'http://localhost:3010/graphql',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -41,12 +41,12 @@ if (process.env.DEV_SERVER_URL) {
|
||||
config.webServer = [
|
||||
{
|
||||
command: 'yarn run -T affine bundle -p @affine/electron-renderer --dev',
|
||||
port: 8080,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
env: {
|
||||
COVERAGE: process.env.COVERAGE || 'false',
|
||||
},
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
};
|
||||
@@ -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) {
|
||||
|
||||
@@ -50,12 +50,12 @@ const config: PlaywrightTestConfig = {
|
||||
// Intentionally not building the web, reminds you to run it by yourself.
|
||||
{
|
||||
command: 'yarn run -T affine dev -p @affine/mobile',
|
||||
port: 8080,
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
env: {
|
||||
COVERAGE: process.env.COVERAGE || 'false',
|
||||
},
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -15,11 +15,11 @@ export default defineConfig({
|
||||
command: process.env.CI
|
||||
? 'yarn workspace @blocksuite/playground run preview'
|
||||
: 'yarn workspace @blocksuite/playground run dev',
|
||||
port: process.env.CI ? 4173 : 5173,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
env: {
|
||||
COVERAGE: process.env.COVERAGE ?? '',
|
||||
},
|
||||
url: process.env.CI ? 'http://localhost:4173' : 'http://localhost:5173',
|
||||
},
|
||||
use: {
|
||||
browserName:
|
||||
|
||||
Reference in New Issue
Block a user