Payfrit: - Tab API contract tests (bash + python) — all 13 endpoints - Param validation, response time, cross-env parity checks Grubflip: - API endpoint test stubs — menu, restaurant, order, auth - Ready to activate as Mike deploys endpoints Shared: - test_helpers.sh + test_helpers.py — HTTP helpers, pass/fail/skip, JSON output mode - Master test runner (scripts/run-all.sh) - Infrastructure health checker (disk, RAM, services, SSL certs) Test data: - Grubflip seed SQL (QA test restaurants, menus, orders) - Payfrit tab seeder script All Payfrit tab tests confirmed passing against dev + prod.
64 lines
1.9 KiB
Bash
Executable file
64 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# ============================================================
|
|
# test_endpoints.sh — Grubflip API smoke tests (bash)
|
|
# Quick connectivity and endpoint existence checks.
|
|
# Usage: ./grubflip/api/test_endpoints.sh [dev|prod] [--json]
|
|
# Author: Luna (@luna) — QA
|
|
# ============================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
source "$REPO_ROOT/shared/lib/test_helpers.sh"
|
|
|
|
ENV="${1:-dev}"
|
|
case "$ENV" in
|
|
dev) BASE="https://dev.grubflip.com/api" ;;
|
|
prod) BASE="https://api.grubflip.com" ;;
|
|
*) echo "Usage: $0 [dev|prod] [--json]"; exit 1 ;;
|
|
esac
|
|
|
|
$JSON_MODE || {
|
|
echo "============================================"
|
|
echo " GRUBFLIP API SMOKE TESTS ($ENV)"
|
|
echo " $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
|
|
echo "============================================"
|
|
}
|
|
|
|
section "CONNECTIVITY"
|
|
result=$(http_get "$BASE")
|
|
IFS='|' read -r code body ms <<< "$result"
|
|
if [ "$code" != "000" ] && [ -n "$code" ]; then
|
|
pass "API base responds (HTTP $code, ${ms}ms)"
|
|
else
|
|
fail "API base unreachable" "HTTP $code"
|
|
test_summary
|
|
exit $?
|
|
fi
|
|
|
|
section "ENDPOINT DISCOVERY"
|
|
ENDPOINTS=(
|
|
"GET|/menus|List menus"
|
|
"GET|/menus/1|Get menu"
|
|
"GET|/menu-items|List menu items"
|
|
"GET|/restaurants|List restaurants"
|
|
"GET|/restaurants/1|Get restaurant"
|
|
"GET|/orders|List orders"
|
|
"GET|/orders/1|Get order"
|
|
)
|
|
|
|
for entry in "${ENDPOINTS[@]}"; do
|
|
IFS='|' read -r method path label <<< "$entry"
|
|
result=$(http_get "$BASE$path")
|
|
IFS='|' read -r code body ms <<< "$result"
|
|
|
|
case "$code" in
|
|
000) skip "$label ($path)" "unreachable" ;;
|
|
404) skip "$label ($path)" "not deployed yet" ;;
|
|
200|201|400|401|422|403)
|
|
pass "$label ($path) — HTTP $code (${ms}ms)" ;;
|
|
*)
|
|
fail "$label ($path)" "HTTP $code" ;;
|
|
esac
|
|
done
|
|
|
|
test_summary
|