From d2ed667f0c788cb114be49a8c75669c7869bb898 Mon Sep 17 00:00:00 2001 From: openclaw Date: Wed, 4 Mar 2026 18:28:50 +0000 Subject: [PATCH] chore: add mandatory test concept and smoke-test workflow --- TESTING.md | 36 ++++++++++++++++++++++++++++++++++ backend/package.json | 5 +++-- backend/scripts/smoke-test.mjs | 20 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 TESTING.md create mode 100644 backend/scripts/smoke-test.mjs diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..f009dc1 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,36 @@ +# Testkonzept – helpyourneighbour + +Dieses Testkonzept ist **verpflichtend vor jedem Push**. + +## Ziel +Stabile, sichere Releases durch standardisierte Tests in Docker auf dem Unraid-Host. + +## Pflichtablauf (immer) +1. **Lokaler Schnelltest** + - `cd backend && npm ci && npm test` +2. **Docker-Test auf Unraid** + - Image bauen und Smoke-Test im Container ausführen. +3. **Erst danach pushen** + - Wenn ein Test fehlschlägt: kein Push, zuerst Fix. + +## Docker-Standard (Unraid) +Im Repo-Root ausführen: + +```bash +docker run --rm -t \ + -v "$PWD":/app \ + -w /app/backend \ + node:22-bookworm \ + bash -lc "npm ci && npm test" +``` + +## Mindest-Testumfang +- Syntax-Validierung aller Backend-JS-Dateien (`node --check`) +- Smoke-Test-Exitcode 0 + +## Erweiterung (nächster Schritt) +- API-Integrationstests (Auth, Requests, Offers, Contacts) +- DB-Container für reproduzierbare End-to-End-Tests + +## Verbindlichkeit +Dieses Konzept gilt als Standardprozess für alle weiteren Änderungen in `helpyourneighbour`. diff --git a/backend/package.json b/backend/package.json index 1e3c0da..9a5a875 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,11 +4,12 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "npm run test:smoke", "start": "node src/server.js", "dev": "node --watch src/server.js", "db:init": "node src/db/init.js", - "db:seed": "node src/db/seed.js" + "db:seed": "node src/db/seed.js", + "test:smoke": "node scripts/smoke-test.mjs" }, "keywords": [], "author": "", diff --git a/backend/scripts/smoke-test.mjs b/backend/scripts/smoke-test.mjs new file mode 100644 index 0000000..8052106 --- /dev/null +++ b/backend/scripts/smoke-test.mjs @@ -0,0 +1,20 @@ +import { spawn } from 'node:child_process'; + +const run = (cmd, args, opts = {}) => + new Promise((resolve, reject) => { + const p = spawn(cmd, args, { stdio: 'inherit', ...opts }); + p.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`${cmd} exited with ${code}`)))); + }); + +const main = async () => { + await run('bash', ['-lc', 'find src -name "*.js" -print0 | xargs -0 -n1 node --check'], { + cwd: process.cwd(), + }); + + console.log('Smoke test passed: syntax checks OK'); +}; + +main().catch((err) => { + console.error('Smoke test failed:', err.message); + process.exit(1); +});