feat: add initial project configuration and smoke tests
- Created pnpm workspace configuration to manage packages. - Added a placeholder .gitkeep file in the scripts directory. - Implemented a smoke test script to validate core API and web endpoints. - Established TypeScript base configuration for consistent compilation settings. - Introduced Turbo configuration for task management and build processes.
This commit is contained in:
108
smoke-test.sh
Normal file
108
smoke-test.sh
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Smoke tests for davinci-platform.
|
||||
# Validates core endpoints are responding correctly.
|
||||
#
|
||||
# Ports are configurable via environment variables so the smoke tests
|
||||
# can run against either the dev stack (3001/3000) or the isolated test
|
||||
# stack (3101/3100).
|
||||
#
|
||||
# Usage:
|
||||
# bash smoke-test.sh # Against dev stack
|
||||
# API_PORT=4301 WEB_PORT=4001 bash smoke-test.sh # Against test stack
|
||||
# SKIP_WEB=1 bash smoke-test.sh # API only (no web container)
|
||||
# make smoke # Against dev stack (via Makefile)
|
||||
|
||||
API="http://localhost:${API_PORT:-4300}"
|
||||
WEB="http://localhost:${WEB_PORT:-4000}"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
RESULTS=""
|
||||
|
||||
smoke() {
|
||||
local label="$1"
|
||||
local expect_code="$2"
|
||||
local actual_code="$3"
|
||||
local body="$4"
|
||||
|
||||
if [ "$actual_code" = "$expect_code" ]; then
|
||||
PASS=$((PASS + 1))
|
||||
RESULTS="$RESULTS\n ✅ $label → $actual_code"
|
||||
else
|
||||
FAIL=$((FAIL + 1))
|
||||
RESULTS="$RESULTS\n ❌ $label → $actual_code (expected $expect_code)"
|
||||
if [ -n "$body" ]; then
|
||||
RESULTS="$RESULTS\n Body: $(echo "$body" | head -c 200)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo " DAVINCI PLATFORM SMOKE TESTS"
|
||||
echo " API: $API"
|
||||
echo " Web: $WEB"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
|
||||
# ─── API Tests ────────────────────────────────────────────────────
|
||||
|
||||
# 1. Health endpoint
|
||||
RESP=$(curl -s -w "\n%{http_code}" "$API/health")
|
||||
BODY=$(echo "$RESP" | sed '$d')
|
||||
CODE=$(echo "$RESP" | tail -1)
|
||||
smoke "GET /health" "200" "$CODE" "$BODY"
|
||||
|
||||
# 2. Health response contains status:ok
|
||||
if echo "$BODY" | grep -q '"status":"ok"'; then
|
||||
smoke "Health body contains status:ok" "200" "200"
|
||||
else
|
||||
smoke "Health body contains status:ok" "200" "FAIL" "$BODY"
|
||||
fi
|
||||
|
||||
# 3. Unknown API route returns 404
|
||||
RESP=$(curl -s -w "\n%{http_code}" "$API/api/nonexistent")
|
||||
CODE=$(echo "$RESP" | tail -1)
|
||||
smoke "GET /api/nonexistent" "404" "$CODE"
|
||||
|
||||
# ─── Web Tests ────────────────────────────────────────────────────
|
||||
|
||||
if [ -n "$SKIP_WEB" ]; then
|
||||
echo " ⏭ Skipping web tests (SKIP_WEB is set)"
|
||||
else
|
||||
|
||||
# 4. Web root redirects to locale
|
||||
RESP=$(curl -s -o /dev/null -w "%{http_code}" "$WEB/")
|
||||
smoke "GET / (redirect to locale)" "307" "$RESP"
|
||||
|
||||
# 5. Web /en returns 200
|
||||
RESP=$(curl -sL -w "\n%{http_code}" "$WEB/en")
|
||||
BODY=$(echo "$RESP" | sed '$d')
|
||||
CODE=$(echo "$RESP" | tail -1)
|
||||
smoke "GET /en" "200" "$CODE"
|
||||
|
||||
# 6. Web page contains expected content
|
||||
if echo "$BODY" | grep -q "Davinci Platform"; then
|
||||
smoke "Page contains 'Davinci Platform'" "200" "200"
|
||||
else
|
||||
smoke "Page contains 'Davinci Platform'" "200" "FAIL" "$BODY"
|
||||
fi
|
||||
|
||||
fi # end SKIP_WEB
|
||||
|
||||
# ─── Results ──────────────────────────────────────────────────────
|
||||
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo " RESULTS: $PASS passed, $FAIL failed"
|
||||
echo "========================================="
|
||||
echo -e "$RESULTS"
|
||||
echo ""
|
||||
|
||||
if [ "$FAIL" -gt 0 ]; then
|
||||
echo "❌ SMOKE TESTS FAILED"
|
||||
exit 1
|
||||
else
|
||||
echo "✅ ALL SMOKE TESTS PASSED"
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user