From 7f7edce62df14fd748d7a80b9d0f9d9a1220726a Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 25 Mar 2026 09:47:58 +0100 Subject: [PATCH] chore: add pipeline system test scripts (Issue #28) --- test-pipeline-api.sh | 68 ++++++++++++++++++++++++++++++++++++++++ test-pipeline-backend.sh | 51 ++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 test-pipeline-api.sh create mode 100644 test-pipeline-backend.sh diff --git a/test-pipeline-api.sh b/test-pipeline-api.sh new file mode 100644 index 0000000..62b1957 --- /dev/null +++ b/test-pipeline-api.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# API-Tests für Pipeline-System (Issue #28) +# Ausführen auf Server oder lokal: bash test-pipeline-api.sh + +echo "═══════════════════════════════════════════════════════════" +echo "Pipeline-System API Tests" +echo "═══════════════════════════════════════════════════════════" +echo "" + +# Configuration +API_URL="https://dev.mitai.jinkendo.de" +TOKEN="" # <-- Füge deinen Admin-Token hier ein + +if [ -z "$TOKEN" ]; then + echo "❌ Bitte TOKEN in Zeile 11 eintragen (Admin-Token von dev.mitai.jinkendo.de)" + echo "" + echo "1. In Browser einloggen: https://dev.mitai.jinkendo.de" + echo "2. Developer Tools öffnen (F12)" + echo "3. Application/Storage → localStorage → auth_token kopieren" + exit 1 +fi + +echo "Test 1: GET /api/prompts/pipeline-configs" +echo "─────────────────────────────────────────────────────────" +curl -s "$API_URL/api/prompts/pipeline-configs" \ + -H "X-Auth-Token: $TOKEN" | jq -r '.[] | "\(.name) (default: \(.is_default), active: \(.active))"' +echo "" + +echo "Test 2: GET /api/prompts/pipeline-configs - Full JSON" +echo "─────────────────────────────────────────────────────────" +curl -s "$API_URL/api/prompts/pipeline-configs" \ + -H "X-Auth-Token: $TOKEN" | jq '.[0] | {name, is_default, modules, stage1_prompts, stage2_prompt}' +echo "" + +echo "Test 3: POST /api/insights/pipeline (default config)" +echo "─────────────────────────────────────────────────────────" +echo "Hinweis: Dies startet eine echte KI-Analyse (kann 30-60s dauern)" +read -p "Fortfahren? (y/n) " -n 1 -r +echo +if [[ $REPLY =~ ^[Yy]$ ]]; then + RESULT=$(curl -s -X POST "$API_URL/api/insights/pipeline" \ + -H "X-Auth-Token: $TOKEN" \ + -H "Content-Type: application/json") + + echo "$RESULT" | jq '{ + scope, + config: .config, + stage1_results: (.stage1 | keys), + content_length: (.content | length) + }' + echo "" + echo "Full content (first 500 chars):" + echo "$RESULT" | jq -r '.content' | head -c 500 + echo "..." +else + echo "Übersprungen." +fi +echo "" + +echo "Test 4: GET /api/prompts - Prüfe auf is_system_default" +echo "─────────────────────────────────────────────────────────" +curl -s "$API_URL/api/prompts" \ + -H "X-Auth-Token: $TOKEN" | jq -r '.[] | select(.slug | startswith("pipeline_")) | "\(.slug): is_system_default=\(.is_system_default // false)"' | head -6 +echo "" + +echo "═══════════════════════════════════════════════════════════" +echo "API-Tests abgeschlossen!" +echo "═══════════════════════════════════════════════════════════" diff --git a/test-pipeline-backend.sh b/test-pipeline-backend.sh new file mode 100644 index 0000000..3c26dae --- /dev/null +++ b/test-pipeline-backend.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Test-Script für Pipeline-System Backend (Issue #28) +# Ausführen auf Server: bash test-pipeline-backend.sh + +echo "═══════════════════════════════════════════════════════════" +echo "Pipeline-System Backend Tests" +echo "═══════════════════════════════════════════════════════════" +echo "" + +# Container Name +CONTAINER="bodytrack-dev_backend_1" + +echo "Test 1: Migration 019 ausgeführt" +echo "─────────────────────────────────────────────────────────" +docker exec $CONTAINER psql -h db -U bodytrack -d bodytrack -c \ + "SELECT version, applied_at FROM schema_migrations WHERE version = '019';" +echo "" + +echo "Test 2: Tabelle pipeline_configs existiert" +echo "─────────────────────────────────────────────────────────" +docker exec $CONTAINER psql -h db -U bodytrack -d bodytrack -c \ + "\d pipeline_configs" | head -40 +echo "" + +echo "Test 3: Seed-Daten (3 Configs erwartet)" +echo "─────────────────────────────────────────────────────────" +docker exec $CONTAINER psql -h db -U bodytrack -d bodytrack -c \ + "SELECT name, is_default, active, stage2_prompt, stage3_prompt FROM pipeline_configs ORDER BY is_default DESC, name;" +echo "" + +echo "Test 4: ai_prompts erweitert (is_system_default)" +echo "─────────────────────────────────────────────────────────" +docker exec $CONTAINER psql -h db -U bodytrack -d bodytrack -c \ + "SELECT slug, is_system_default, (default_template IS NOT NULL) as has_default FROM ai_prompts WHERE slug LIKE 'pipeline_%' ORDER BY slug;" +echo "" + +echo "Test 5: stage1_prompts Array-Inhalte" +echo "─────────────────────────────────────────────────────────" +docker exec $CONTAINER psql -h db -U bodytrack -d bodytrack -c \ + "SELECT name, stage1_prompts FROM pipeline_configs WHERE name = 'Alltags-Check';" +echo "" + +echo "Test 6: modules JSONB" +echo "─────────────────────────────────────────────────────────" +docker exec $CONTAINER psql -h db -U bodytrack -d bodytrack -c \ + "SELECT name, jsonb_pretty(modules) as modules FROM pipeline_configs WHERE name = 'Alltags-Check';" +echo "" + +echo "═══════════════════════════════════════════════════════════" +echo "Alle DB-Tests abgeschlossen!" +echo "═══════════════════════════════════════════════════════════"