workspace-v1/projects/gamilit/apps/backend/scripts/test-grading-pagination.sh
Adrian Flores Cortes 967ab360bb Initial commit: Workspace v1 with 3-layer architecture
Structure:
- control-plane/: Registries, SIMCO directives, CI/CD templates
- projects/: Gamilit, ERP-Suite, Trading-Platform, Betting-Analytics
- shared/: Libs catalog, knowledge-base

Key features:
- Centralized port, domain, database, and service registries
- 23 SIMCO directives + 6 fundamental principles
- NEXUS agent profiles with delegation rules
- Validation scripts for workspace integrity
- Dockerfiles for all services
- Path aliases for quick reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:35:19 -06:00

92 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
# Test script for grading API pagination
# Tests the corrected response structure
BASE_URL="http://localhost:3000/api/teacher/submissions"
TOKEN="${AUTH_TOKEN:-your-auth-token-here}"
echo "========================================"
echo "Testing Grading API Pagination"
echo "========================================"
echo ""
# Test 1: Get all pending submissions
echo "Test 1: Get pending submissions (page 1, limit 10)"
echo "--------------------------------------"
curl -s -X GET "${BASE_URL}?status=pending&page=1&limit=10" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" | jq '.'
echo ""
# Test 2: Verify response structure
echo "Test 2: Verify response has pagination structure"
echo "--------------------------------------"
RESPONSE=$(curl -s -X GET "${BASE_URL}?status=pending&page=1&limit=5" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json")
echo "Response structure:"
echo "$RESPONSE" | jq 'keys'
echo ""
# Check for required fields
echo "Checking required fields:"
echo " - submissions: $(echo "$RESPONSE" | jq -e 'has("submissions")' && echo "✅ EXISTS" || echo "❌ MISSING")"
echo " - total: $(echo "$RESPONSE" | jq -e 'has("total")' && echo "✅ EXISTS" || echo "❌ MISSING")"
echo " - page: $(echo "$RESPONSE" | jq -e 'has("page")' && echo "✅ EXISTS" || echo "❌ MISSING")"
echo " - limit: $(echo "$RESPONSE" | jq -e 'has("limit")' && echo "✅ EXISTS" || echo "❌ MISSING")"
echo ""
# Test 3: Get graded submissions
echo "Test 3: Get graded submissions"
echo "--------------------------------------"
curl -s -X GET "${BASE_URL}?status=graded&limit=5" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" | jq '.total, .page, .limit, (.submissions | length)'
echo ""
# Test 4: Filter by classroom
echo "Test 4: Filter by classroom_id"
echo "--------------------------------------"
CLASSROOM_ID="${CLASSROOM_ID:-your-classroom-id}"
curl -s -X GET "${BASE_URL}?classroom_id=${CLASSROOM_ID}&limit=10" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" | jq '{total, page, limit, submissions_count: (.submissions | length)}'
echo ""
# Test 5: Filter by date range
echo "Test 5: Filter by date range"
echo "--------------------------------------"
curl -s -X GET "${BASE_URL}?start_date=2025-01-01&end_date=2025-01-31&limit=10" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" | jq '{total, page, limit, submissions_count: (.submissions | length)}'
echo ""
# Test 6: Pagination test (multiple pages)
echo "Test 6: Pagination - Page 1"
echo "--------------------------------------"
curl -s -X GET "${BASE_URL}?status=pending&page=1&limit=3" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" | jq '{page, limit, total, submissions_count: (.submissions | length)}'
echo ""
echo "Test 6: Pagination - Page 2"
echo "--------------------------------------"
curl -s -X GET "${BASE_URL}?status=pending&page=2&limit=3" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" | jq '{page, limit, total, submissions_count: (.submissions | length)}'
echo ""
echo "========================================"
echo "Testing Complete"
echo "========================================"
echo ""
echo "Expected Response Structure:"
echo "{"
echo " \"submissions\": [ ... ], // Array of Submission objects"
echo " \"total\": number, // Total count of submissions"
echo " \"page\": number, // Current page"
echo " \"limit\": number // Items per page"
echo "}"