test(mobile): createTestServer() binds an ephemeral port (#440)

The helper cached servers by port, but every mobile file starts exactly one, so the cache was never shared: it is now a Set that stopAllTestServers() walks. PORTS leaves helpers/constants.ts, the nine tests set baseUrl after start(), and the README drops the port column and the pick-a-port step.

Committed without the pre-commit hook: accessibility, subagent-windows and visual-regression were not prettier-clean on master already; formatting them would bury the port lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Randalix
2026-10-09 16:29:01 +02:00
co-authored by Claude Opus 5.5
parent aa4217b8b1
commit 6f87186deb
12 changed files with 164 additions and 180 deletions
+13 -13
View File
@@ -1,7 +1,7 @@
// Port 3207 - Mobile accessibility tests
// Ephemeral port - Mobile accessibility tests
import { describe, it, expect, beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
import type { Page, BrowserContext } from 'playwright';
import { PORTS, SELECTORS, KEYBOARD, MIN_TOUCH_TARGET, WAIT } from './helpers/constants.js';
import { SELECTORS, KEYBOARD, MIN_TOUCH_TARGET, WAIT } from './helpers/constants.js';
import { createTestServer, stopTestServer } from './helpers/server.js';
import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
import { showKeyboard, hideKeyboard } from './helpers/keyboard-sim.js';
@@ -12,14 +12,14 @@ import {
import { REPRESENTATIVE_DEVICES } from './devices.js';
import type { WebServer } from '../src/web/server.js';
const PORT = PORTS.ACCESSIBILITY;
const BASE_URL = `http://localhost:${PORT}`;
let baseUrl: string;
describe('Mobile Accessibility', () => {
let server: WebServer;
beforeAll(async () => {
server = await createTestServer(PORT);
server = await createTestServer();
baseUrl = `http://localhost:${server.boundPort}`;
});
afterAll(async () => {
@@ -39,7 +39,7 @@ describe('Mobile Accessibility', () => {
it('all visible interactive elements >= 44x44px on phones', async () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
@@ -64,7 +64,7 @@ describe('Mobile Accessibility', () => {
it('all visible interactive elements >= 44x44px on tablets', async () => {
const device = REPRESENTATIVE_DEVICES['standard-tablet'];
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
@@ -83,7 +83,7 @@ describe('Mobile Accessibility', () => {
it('keyboard accessory bar buttons meet size requirement', async () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
@@ -118,7 +118,7 @@ describe('Mobile Accessibility', () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
beforeEach(async () => {
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
});
@@ -159,7 +159,7 @@ describe('Mobile Accessibility', () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
beforeEach(async () => {
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
});
@@ -229,7 +229,7 @@ describe('Mobile Accessibility', () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
beforeEach(async () => {
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
});
@@ -294,7 +294,7 @@ describe('Mobile Accessibility', () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
beforeEach(async () => {
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
});
@@ -357,7 +357,7 @@ describe('Mobile Accessibility', () => {
const device = REPRESENTATIVE_DEVICES['standard-phone'];
beforeEach(async () => {
const result = await createDevicePage(device, BASE_URL, 'chromium');
const result = await createDevicePage(device, baseUrl, 'chromium');
page = result.page;
context = result.context;
});