dx: removed hard-coded test port

Massimo Melina committed Feb 28, 2026 at 19:09 UTC cf234bd1bf94910a5f196acbbd730a448e299856
3 files changed +15 -4
e2e/common.ts
+6 -1
@@ -1,9 +1,14 @@
1 import { Page, test } from '@playwright/test'
2 import fs from 'fs'
3 +import { readFileSync } from 'node:fs'
4 +import { resolve } from 'node:path'
5 +import yaml from 'yaml'
6
7 export const username = 'rejetto'
8 export const password = 'password'
6 -export const URL = 'http://[::1]:8081/'
9 +// keep e2e URL aligned with the same config file used by tests/test.ts and server-for-test
10 +const TEST_PORT = Number(yaml.parse(readFileSync(resolve(process.cwd(), 'tests/config.yaml'), 'utf8')).port)
11 +export const URL = `http://[::1]:${TEST_PORT}/`
12 export const uploadName = 'uploaded'
13
14 const t = Date.UTC(2025, 0, 20, 3, 0, 0, 0) / 1000 // a fixed timestamp, for visual comparison
playwright.config.ts
+6 -1
@@ -1,7 +1,12 @@
1 import { defineConfig, devices } from '@playwright/test';
2 import { execSync } from 'node:child_process';
3 +import { readFileSync } from 'node:fs';
4 +import { resolve } from 'node:path';
5 +import yaml from 'yaml';
6
7 const snapshotBranch = getSnapshotBranch()
8 +// use the same test port source as tests/test.ts to avoid config drift
9 +const testPort = Number(yaml.parse(readFileSync(resolve(process.cwd(), 'tests/config.yaml'), 'utf8')).port)
10
11 /**
12 * Read environment variables from file.
@@ -100,7 +105,7 @@ export default defineConfig({
105 /* Run your local dev server before starting the tests */
106 webServer: [{
107 command: 'npm run server-for-test' + (process.env.TEST_WITH_UI ? '-dev' : ''), // use server-for-test-dev only for "test-with-ui"
103 - url: 'http://127.0.0.1:8081',
108 + url: `http://127.0.0.1:${testPort}`,
109 reuseExistingServer: !process.env.CI,
110 }, { // launch a second server for tests with an empty/default config
111 command: 'rm -rf tests/work2 && node dist/src --cwd tests/work2 --debug --port 8082 --open_browser_at_start false', // the port here is just to avoid getting the "port busy" console warning
scripts/local-ci.sh
+3 -2
@@ -288,10 +288,11 @@ run_test() {
288
289 # Modify port in worktree to avoid conflicts (only for detached HEAD or non-tip commits)
290 if [ -z "$branch" ] || [ "$branch" = "detached" ]; then
291 - log "Changing port from 8081 to $TEST_PORT in worktree files"
291 + log "Changing tests/config.yaml port to $TEST_PORT in worktree files"
292 + sed -i '' -E "s/^port:[[:space:]]*[0-9]+/port: $TEST_PORT/" "$worktree_path/tests/config.yaml" 2>/dev/null || true
293 + # older commits can still hardcode 8081 in e2e files, so keep this fallback for compatibility
294 sed -i '' "s/8081/$TEST_PORT/g" "$worktree_path/e2e/common.ts" 2>/dev/null || true
295 sed -i '' "s/8081/$TEST_PORT/g" "$worktree_path/playwright.config.ts" 2>/dev/null || true
294 - sed -i '' "s/port: 8081/port: $TEST_PORT/g" "$worktree_path/tests/config.yaml" 2>/dev/null || true
296 fi
297
298 local exit_code=0