E2E Smoke Test: 16 tests covering all new endpoints
Tests: root serving, export (CSV/KML/clipboard), GPS proximity, sessions CRUD, assign-machine-id, bulk-assign, sw.js, index.html
This commit is contained in:
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
# E2E Smoke Test for exif-test new features
|
||||
# Tests: Export, Assign Machine ID, GPS Proximity, Sessions, Bulk Assign
|
||||
set -euo pipefail
|
||||
|
||||
BASE="http://localhost:8903"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
green() { echo "✅ $1"; PASS=$((PASS+1)); }
|
||||
red() { echo "❌ $1"; FAIL=$((FAIL+1)); }
|
||||
|
||||
echo "═══ E2E Smoke Test — exif-test ═══"
|
||||
echo
|
||||
|
||||
# 1. Root / static serving
|
||||
echo "--- 1. Root page ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/")
|
||||
[ "$HTTP" = "200" ] && green "Root returns 200" || red "Root returned $HTTP"
|
||||
|
||||
# 2. Export clipboard (empty DB = empty result)
|
||||
echo "--- 2. Export: clipboard ---"
|
||||
DATA=$(curl -sf "$BASE/api/export?format=clipboard")
|
||||
echo "$DATA" | grep -q '"count":0' && green "Export clipboard: empty DB returns count=0" || red "Export clipboard failed: $DATA"
|
||||
|
||||
# 3. Export CSV (empty)
|
||||
echo "--- 3. Export: CSV ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/api/export?format=csv")
|
||||
[ "$HTTP" = "200" ] && green "Export CSV returns 200" || red "Export CSV returned $HTTP"
|
||||
|
||||
# 4. Export KML (empty)
|
||||
echo "--- 4. Export: KML ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/api/export?format=kml")
|
||||
[ "$HTTP" = "200" ] && green "Export KML returns 200" || red "Export KML returned $HTTP"
|
||||
|
||||
# 5. Export with session_id
|
||||
echo "--- 5. Export with session_id ---"
|
||||
DATA=$(curl -sf "$BASE/api/export?format=clipboard&session_id=1")
|
||||
echo "$DATA" | grep -q '"count":0' && green "Export with session_id works" || red "Export with session_id failed: $DATA"
|
||||
|
||||
# 6. GPS Proximity (no photos = empty)
|
||||
echo "--- 6. GPS Proximity ---"
|
||||
DATA=$(curl -sf "$BASE/api/nearby?lat=28.5&lng=-81.5&radius=10")
|
||||
echo "$DATA" | grep -qF '"nearby":[]' && green "Nearby returns empty array" || red "Nearby failed: $DATA"
|
||||
|
||||
# 7. GPS Proximity with exclude
|
||||
echo "--- 7. GPS Proximity with exclude ---"
|
||||
DATA=$(curl -sf "$BASE/api/nearby?lat=28.5&lng=-81.5&radius=10&exclude_photo_id=1")
|
||||
echo "$DATA" | grep -qF '"count":0' && green "Nearby with exclude works" || red "Nearby with exclude failed: $DATA"
|
||||
|
||||
# 8. Sessions list (any array is fine)
|
||||
echo "--- 8. Sessions list ---"
|
||||
DATA=$(curl -sf "$BASE/api/sessions")
|
||||
echo "$DATA" | grep -qF '"sessions"' && green "Sessions returns array" || red "Sessions failed: $DATA"
|
||||
|
||||
# 9. Create session
|
||||
echo "--- 9. Create session ---"
|
||||
DATA=$(curl -sf -X POST "$BASE/api/sessions" -H "Content-Type: application/json" -d '{"name":"Smoke Test","building":"Test Bldg","floor":"1"}')
|
||||
echo "$DATA" | grep -qF '"id"' && green "Session created" || red "Create session failed: $DATA"
|
||||
|
||||
# 10. Get session detail
|
||||
SESSION_ID=$(echo "$DATA" | grep -o '"id":[0-9]*' | grep -o '[0-9]*')
|
||||
echo "--- 10. Get session $SESSION_ID ---"
|
||||
DATA=$(curl -sf "$BASE/api/sessions/$SESSION_ID")
|
||||
echo "$DATA" | grep -q '"id":'"$SESSION_ID" && green "Get session $SESSION_ID works" || red "Get session failed: $DATA"
|
||||
|
||||
# 11. Close session
|
||||
echo "--- 11. Close session ---"
|
||||
DATA=$(curl -sf -X POST "$BASE/api/sessions/$SESSION_ID/close")
|
||||
echo "$DATA" | grep -q '"ok":true' && green "Session closed" || red "Close session failed: $DATA"
|
||||
|
||||
# 12. Sessions list (now has 1)
|
||||
echo "--- 12. Sessions list (after create) ---"
|
||||
DATA=$(curl -sf "$BASE/api/sessions")
|
||||
echo "$DATA" | grep -q '"sessions"' && green "Sessions list works" || red "Sessions list failed: $DATA"
|
||||
|
||||
# 13. Assign machine ID (no photo_id = 404)
|
||||
echo "--- 13. Assign machine ID (invalid photo) ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$BASE/api/assign-machine-id" -H "Content-Type: application/json" -d '{"photo_id":99999,"machine_id":"12345"}')
|
||||
[ "$HTTP" = "404" ] || [ "$HTTP" = "500" ] && green "Assign machine ID handles invalid photo gracefully (HTTP $HTTP)" || red "Assign machine ID unexpected: $HTTP"
|
||||
|
||||
# 14. Bulk assign endpoint exists and validates
|
||||
echo "--- 14. Bulk assign endpoint ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$BASE/api/bulk-assign" -H "Content-Type: application/json" -d '{"photo_ids":[99999],"machine_id":"12345"}')
|
||||
[ "$HTTP" != "000" ] && [ "$HTTP" != "404" ] && green "Bulk assign endpoint responds (HTTP $HTTP)" || red "Bulk assign endpoint unexpected: $HTTP"
|
||||
|
||||
# 15. Static files: sw.js exists
|
||||
echo "--- 15. Service Worker ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/sw.js")
|
||||
[ "$HTTP" = "200" ] && green "sw.js served" || red "sw.js returned $HTTP"
|
||||
|
||||
# 16. Static files: index.html
|
||||
echo "--- 16. index.html ---"
|
||||
HTTP=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/index.html")
|
||||
[ "$HTTP" = "200" ] && green "index.html served (HTTP $HTTP)" || red "index.html returned $HTTP"
|
||||
|
||||
echo
|
||||
echo "═══ Results: $PASS passed, $FAIL failed ═══"
|
||||
[ "$FAIL" -eq 0 ] && exit 0 || exit 1
|
||||
Reference in New Issue
Block a user