Files
TX/artifacts/api-server/package.json
T
riyadhafraa f6b5539004 Make the test workflow wait for the API server to be ready
Original task (#127): the `test` workflow ran `pnpm --filter
@workspace/api-server test` directly, which fires HTTP requests at
localhost:8080. On a freshly-started environment the API server
isn't up yet, so every test fails with ECONNREFUSED, drowning real
failures in noise.

Changes:
- Added `artifacts/api-server/scripts/wait-for-server.mjs`, a small
  pure-Node poller that hits `${TEST_API_BASE ?? "http://localhost:8080"}/api/healthz`
  every 500ms until it returns `{status: "ok"}` or the timeout
  (default 30s) elapses. On timeout it exits 1 with a clear
  "Start the API Server workflow (or set TEST_API_BASE) before
  running tests" message instead of a wall of fetch errors.
  Configurable via `TEST_API_BASE`, `TEST_API_WAIT_TIMEOUT_MS`,
  `TEST_API_WAIT_INTERVAL_MS`.
- Added `test:wait` script to `artifacts/api-server/package.json`.
- Updated the `test` workflow to run
  `pnpm --filter @workspace/api-server test:wait` before the
  api-server tests and the tx-os e2e tests.

Verified:
- `node ./scripts/wait-for-server.mjs` against a running server
  reports "ready ... after 86ms" and exits 0.
- Same script with TEST_API_BASE pointed at a dead port exits 1
  with the friendly message.
- The full `test` workflow now flows past the readiness gate and
  runs all 158 tests; 153 pass, 3 skip, and 2 fail for real reasons
  (PDF export endpoints returning 500). Filed follow-up #179 for
  the PDF bugs.

No deviations from the task. `.replit` was edited via the workflow
configuration tool (direct edits are blocked).

Replit-Task-Id: 99673314-dd15-4442-8c7d-f375431719c0
2026-04-29 19:28:14 +00:00

52 lines
1.5 KiB
JSON

{
"name": "@workspace/api-server",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "export NODE_ENV=development && pnpm run build && pnpm run start",
"build": "node ./build.mjs",
"start": "node --enable-source-maps ./dist/index.mjs",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test:wait": "node ./scripts/wait-for-server.mjs",
"test": "node --test 'tests/**/*.test.mjs'"
},
"dependencies": {
"@google-cloud/storage": "^7.19.0",
"@swc/helpers": "^0.5.21",
"@workspace/api-zod": "workspace:*",
"@workspace/db": "workspace:*",
"bcryptjs": "^3.0.3",
"bidi-js": "^1.0.3",
"connect-pg-simple": "^10.0.0",
"cookie-parser": "^1.4.7",
"cors": "^2",
"drizzle-orm": "catalog:",
"express": "^5",
"express-session": "^1.19.0",
"google-auth-library": "^10.6.2",
"pdfkit": "^0.18.0",
"pino": "^9",
"pino-http": "^10",
"sanitize-html": "^2.17.3",
"socket.io": "^4.8.3",
"zod": "catalog:"
},
"devDependencies": {
"@types/bcryptjs": "^3.0.0",
"@types/connect-pg-simple": "^7.0.3",
"@types/cookie-parser": "^1.4.10",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.6",
"@types/express-session": "^1.19.0",
"@types/node": "catalog:",
"@types/pdfkit": "^0.17.6",
"@types/sanitize-html": "^2.16.1",
"esbuild": "^0.27.3",
"esbuild-plugin-pino": "^2.3.3",
"pg": "^8.20.0",
"pino-pretty": "^13",
"thread-stream": "3.1.0"
}
}