Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(e2e): a Playwright run can take its own port and never adopts a foreign dev server

purple9e40efbb02ea
diff --git a/e2e/memory-sync.spec.ts b/e2e/memory-sync.spec.ts
index fdee0561..2ec8f203 100644
--- a/e2e/memory-sync.spec.ts
+++ b/e2e/memory-sync.spec.ts
@@ -2,6 +2,9 @@ import { expect, test, type Page } from '@playwright/test'
import type { SyncedMemoryRecord } from '../src/api/cloud/memory-sync'
import { isRecord } from './support/recorded'
+// The app's own port, from the configured baseURL, so a second config on another port still works.
+const appPort = () => new URL(test.info().project.use.baseURL ?? 'http://localhost:5273').port
+
async function accountFixture(page: Page) {
await page.evaluate(async () => {
const authPath = '/src/stores/cloudAuthStore.ts'
@@ -21,7 +24,7 @@ test('foreground cancellation stops a held pull and leaving the collection cance
let finish: (() => Promise<void>) | undefined
let hold = true
let reads = 0
- await page.route('**/*', route => new URL(route.request().url()).port === '5273' ? route.continue() : route.abort())
+ await page.route('**/*', route => new URL(route.request().url()).port === appPort() ? route.continue() : route.abort())
await page.route('**/api/memory/sync**', async route => {
expect(route.request().method()).toBe('GET')
reads++
@@ -69,7 +72,7 @@ test('foreground cancellation stops a held pull and leaving the collection cance
test('explicit UI sync uploads, downloads, preserves conflicts and persists shared deletion', async ({ page }, testInfo) => {
let records: SyncedMemoryRecord[] = []
let writes = 0
- await page.route('**/*', route => new URL(route.request().url()).port === '5273' ? route.continue() : route.abort())
+ await page.route('**/*', route => new URL(route.request().url()).port === appPort() ? route.continue() : route.abort())
await page.route('**/api/memory/sync**', async route => {
expect(route.request().headers().authorization).toBe('Bearer synthetic-proof-token')
if (route.request().method() === 'POST') {
@@ -187,7 +190,7 @@ test(`a ${responseMode} first-upload response cannot revive a locally deleted me
let records: SyncedMemoryRecord[] = []
let lostResponse = false
let finish: (() => Promise<void>) | undefined
- await page.route('**/*', route => new URL(route.request().url()).port === '5273' ? route.continue() : route.abort())
+ await page.route('**/*', route => new URL(route.request().url()).port === appPort() ? route.continue() : route.abort())
await page.route('**/api/memory/sync**', async route => {
if (route.request().method() === 'GET') return route.fulfill({ json: { ownerId: 'owner-a', records, next: null } })
const body: unknown = route.request().postDataJSON()
diff --git a/e2e/memory-write-fence.spec.ts b/e2e/memory-write-fence.spec.ts
index e83f845f..a9f62235 100644
--- a/e2e/memory-write-fence.spec.ts
+++ b/e2e/memory-write-fence.spec.ts
@@ -1,8 +1,11 @@
import { expect, test } from '@playwright/test'
import { DEFAULT_MODEL_NAME } from './support/tauri-mock'
+// The app's own port, from the configured baseURL, so a second config on another port still works.
+const appPort = () => new URL(test.info().project.use.baseURL ?? 'http://localhost:5273').port
+
test('deleting through Memory Settings survives a late automatic extraction and reload', async ({ page }) => {
- await page.route('**/*', route => new URL(route.request().url()).port === '5273' ? route.continue() : route.abort())
+ await page.route('**/*', route => new URL(route.request().url()).port === appPort() ? route.continue() : route.abort())
await page.goto('/e2e/memory-sensitive-proof.html')
await page.evaluate(async (modelName) => {
const memoryPath = '/src/stores/memoryStore.ts'
diff --git a/playwright.config.ts b/playwright.config.ts
index a8628878..7286d61c 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -14,6 +14,14 @@ import { defineConfig, devices } from '@playwright/test'
* dev middleware only spawns on `/local-api/*` requests, which the mock never
* triggers, so boot has no side effects.
*/
+// Several worktrees on one machine: the fixed port plus reuseExistingServer made
+// a run test the dev server of ANOTHER worktree (two red tests on 03.10.2026 that
+// pass on their own server). LU_E2E_PORT gives a run its own server on its own
+// port, and such a run never adopts a server that is already there.
+const ownPort = Number(process.env.LU_E2E_PORT) || 0
+const port = ownPort || 5273
+const origin = `http://localhost:${port}`
+
export default defineConfig({
testDir: './e2e',
fullyParallel: false,
@@ -24,7 +32,7 @@ export default defineConfig({
timeout: 60_000,
expect: { timeout: 15_000 },
use: {
- baseURL: 'http://localhost:5273',
+ baseURL: origin,
trace: 'on-first-retry',
headless: true,
},
@@ -32,9 +40,9 @@ export default defineConfig({
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
],
webServer: {
- command: 'npm run dev',
- url: 'http://localhost:5273',
- reuseExistingServer: !process.env.CI,
+ command: ownPort ? `npx vite --port ${port} --strictPort` : 'npm run dev',
+ url: origin,
+ reuseExistingServer: !process.env.CI && !ownPort,
timeout: 120_000,
stdout: 'ignore',
stderr: 'pipe',