@samitouri / QOSami-HFS / commits / f4a37c13

some optimization for coding agents (port 81 was unaccessible for OS-level permissions)

Massimo Melina committed Jan 24, 2026 at 14:48 UTC f4a37c13e5e6d1deee4847022f6428988658864b
6 files changed +13 -9
AGENTS.md
+3 -1
@@ -7,7 +7,7 @@ Core server logic sits in `src/` (TypeScript, Koa middleware, plugins). Shared R
7 - `npm run watch-server` — start the TypeScript server with hot reload (set `FRONTEND_PROXY`/`ADMIN_PROXY` when pairing with dev UIs).
8 - `npm run watch-server-full` — boot both React apps plus the API server for integrated development.
9 - `npm run build-server` / `npm run build-frontend` / `npm run build-admin` — compile individual targets into `dist/`.
10 -- `npm run build-all` — audit dependencies, rebuild everything, run API tests, and kick off frontend/admin builds in parallel.
10 +- `npm run build-all` — audit dependencies, rebuild everything, run API tests, and kick off frontend/admin builds in parallel. Use a 100s timeout.
11 - `npm run test-with-server` — execute the Node test suite (`tests/test.ts`) with related server. May require escalated permissions in sandboxed environments to bind to port 81.
12 - `npm run test-ui` — launch Playwright’s headless CI.
13
@@ -16,7 +16,9 @@ Use TypeScript/ES2022 with 4-space indentation and single quotes except when JSO
16
17 ## Testing Guidelines
18 Node-side tests rely on the built-in `node --test` runner via `npm test`. Place fixtures under `tests/work` where scripts already expect them. UI coverage uses Playwright (`tests-ui`/`frontend` suites); target critical upload/download flows and plugin management. Name new tests after the behavior they assert (e.g., `plugin-disable.test.ts`). Before pushing, run at least `npm test` and, when touching UI, the relevant Playwright suite.
19 +When you want to run fewer tests, use `npm run test-with-server -- --test-name-pattern="<pattern>"`.
20 For long-running commands like tests/builds, use a 30s timeout unless a different value is requested.
21 +Changes to the config are automatically reloaded and applied asap, no need to restart.
22
23 ## Commit & Pull Request Guidelines
24 Recent history favors short, component-scoped subjects (`admin/plugins: faster list on get-more`). Follow that pattern: `<area>: <concise change>`. Keep commits focused and self-contained. Pull requests should describe motivation, summarize key changes, call out affected packages (`src`, `frontend`, etc.), and mention how to reproduce or verify. Include screenshots for UI changes and note which commands/tests were run. Reference GitHub issues when applicable and flag any follow-up work.
e2e/common.ts
+1 -1
@@ -3,7 +3,7 @@ import fs from 'fs'
3
4 export const username = 'rejetto'
5 export const password = 'password'
6 -export const URL = 'http://[::1]:81/'
6 +export const URL = 'http://[::1]:8081/'
7 export const uploadName = 'uploaded'
8
9 const t = Date.UTC(2025, 0, 20, 3, 0, 0, 0) / 1000 // a fixed timestamp, for visual comparison
package.json
+2 -2
@@ -20,8 +20,8 @@
20 "server-for-test": "node dist/src --cwd tests/work --config tests --debug",
21 "server-for-test-dev": "cross-env DEV=1 FRONTEND_PROXY=3005 ADMIN_PROXY=3006 nodemon --ignore tests/ --watch src -e ts,tsx --exec tsx src -- --cwd tests/work --config tests",
22 "test": "node --import tsx --test tests/test.ts",
23 - "test-with-server": "npm run port-is-free && tsc && rm -rf tests/work tests/tmp && (node dist/src --cwd tests/work --config tests & echo $! > .server_pid) && sleep 2 && node --import tsx --test tests/test.ts; _exit=$?; if [ -f ./.server_pid ]; then SERVER_PID=$(cat ./.server_pid); kill \"$SERVER_PID\" 2>/dev/null || true; rm -f ./.server_pid; fi; exit $_exit",
24 - "port-is-free": "node -e \"process.exit(await fetch('http://localhost:81').then(() => console.log('BUSY') || 1, () => 0))\"",
23 + "test-with-server": "sh -c 'npm run port-is-free && tsc && rm -rf tests/work tests/tmp && (node dist/src --cwd tests/work --config tests & echo $! > .server_pid) && sleep 2 && node --import tsx --test \"$@\" tests/test.ts; _exit=$?; if [ -f ./.server_pid ]; then SERVER_PID=$(cat ./.server_pid); kill \"$SERVER_PID\" 2>/dev/null || true; rm -f ./.server_pid; fi; exit $_exit' --",
24 + "port-is-free": "node -e \"process.exit(await fetch('http://localhost:8081').then(() => console.log('BUSY') || 1, () => 0))\"",
25 "test-ui": "npx playwright test frontend && npx playwright test serial",
26 "test-with-ui": "npx playwright test --ui",
27 "pub": "cd dist && npm publish",
playwright.config.ts
+1 -1
@@ -95,7 +95,7 @@ export default defineConfig({
95 /* Run your local dev server before starting the tests */
96 webServer: [{
97 command: 'npm run server-for-test', // you can run server-for-test-dev instead, but then you need frontend and admin to be running too
98 - url: 'http://127.0.0.1:81',
98 + url: 'http://127.0.0.1:8081',
99 reuseExistingServer: !process.env.CI,
100 }, { // launch a second server for tests with an empty/default config
101 command: 'rm -rf tests/work2 && node dist/src --cwd tests/work2 --debug --port 82 --open_browser_at_start false',
tests/config.yaml
+1 -1
@@ -1,4 +1,4 @@
1 -port: 81
1 +port: 8081
2 open_browser_at_start: false
3 allowed_referer: x.com
4 localhost_admin: false
tests/test.ts
+5 -3
@@ -1,10 +1,11 @@
1 import test, { describe, before, after } from 'node:test';
2 import { promisify } from 'util'
3 import { srpClientSequence } from '../src/srp'
4 -import { createReadStream, existsSync, statfsSync, statSync } from 'fs'
4 +import { createReadStream, existsSync, readFileSync, statfsSync, statSync } from 'fs'
5 import { basename, dirname, resolve } from 'path'
6 import { exec } from 'child_process'
7 import _ from 'lodash'
8 +import yaml from 'yaml'
9 import { findDefined, pathEncode, randomId, try_, tryJson, UPLOAD_TEMP_HASH, wait } from '../src/cross'
10 import { httpStream, stream2string, XRequestOptions } from '../src/util-http'
11 import { ThrottledStream, ThrottleGroup } from '../src/ThrottledStream'
@@ -23,8 +24,9 @@ const password = 'password'
24 const auth = `${username}:${password}`
25 const API = '/~/api/'
26 const ROOT = 'tests/'
26 -const BASE_URL = 'http://[::1]:81'
27 -const BASE_URL_127 = 'http://127.0.0.1:81'
27 +const TEST_PORT = Number(yaml.parse(readFileSync(resolve(__dirname, 'config.yaml'), 'utf8')).port)
28 +const BASE_URL = `http://[::1]:${TEST_PORT}`
29 +const BASE_URL_127 = `http://127.0.0.1:${TEST_PORT}`
30 const UPLOAD_ROOT = '/for-admins/upload/'
31 const VIRTUAL_UPLOAD_ROOT = '/renameChild/'
32 const FUNNY_NAME = 'x%25#x'