- Configure workspace Git repository with comprehensive .gitignore - Add Odoo as submodule for ERP reference code - Include documentation: SETUP.md, GIT-STRUCTURE.md - Add gitignore templates for projects (backend, frontend, database) - Structure supports independent repos per project/subproject level Workspace includes: - core/ - Reusable patterns, modules, orchestration system - projects/ - Active projects (erp-suite, gamilit, trading-platform, etc.) - knowledge-base/ - Reference code and patterns (includes Odoo submodule) - devtools/ - Development tools and templates - customers/ - Client implementations template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
92 lines
3.5 KiB
Bash
Executable File
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 "}"
|