Spaces:
Sleeping
Sleeping
Test Payloads for TDS-PROJ-1
This directory contains JSON payload files to test your TDS-PROJ-1 application with various scenarios.
📁 Available Test Payloads
1. payload-sales-summary.json
Task: Sum of Sales Calculator
- Tests CSV file handling from attachments
- Validates fetch() usage
- Checks dynamic calculation and display
- Attachment:
sales.csvwith product sales data
2. payload-calculator.json
Task: Basic Calculator
- Tests interactive UI creation
- Validates multiple button elements
- Checks for display element and math operations
- Attachment: None
3. payload-todo-list.json
Task: To-Do List Application
- Tests form input handling
- Validates Bootstrap integration
- Checks dynamic list manipulation
- Attachment: None
4. payload-weather-dashboard.json
Task: Weather Dashboard
- Tests search functionality
- Validates display areas
- Checks Bootstrap styling
- Attachment: None
5. payload-json-viewer.json
Task: JSON Data Viewer
- Tests JSON file loading from attachments
- Validates tree view rendering
- Checks search/filter functionality
- Attachment:
data.jsonwith sample user data
6. payload-github-user.json
Task: GitHub User Lookup
- Tests external API integration (GitHub API)
- Validates form handling
- Checks date formatting
- Attachment: None
7. payload-markdown-enhanced.json
Task: Enhanced Markdown Editor (Round 2)
- Tests round 2 functionality
- Validates tab switching UI
- Checks word count feature
- Attachment:
input.mdwith sample markdown
🚀 How to Use
Option 1: Run All Tests (Automated)
# Make sure your server is running first:
# Terminal 1:
python -m uvicorn main:app --host 0.0.0.0 --port 8000
# Terminal 2:
./run_tests.sh
Option 2: Test Individual Payloads
# Test a specific payload
curl -X POST http://127.0.0.1:8000/build \
-H "Content-Type: application/json" \
-d @test_payloads/payload-sales-summary.json
# With pretty output
curl -X POST http://127.0.0.1:8000/build \
-H "Content-Type: application/json" \
-d @test_payloads/payload-calculator.json | jq '.'
Option 3: Test with Python
# Using the test_live_api.py script
python test_live_api.py
# Or use Python requests directly
python3 -c "
import requests
import json
with open('test_payloads/payload-todo-list.json') as f:
payload = json.load(f)
response = requests.post(
'http://127.0.0.1:8000/build',
json=payload
)
print(f'Status: {response.status_code}')
print(f'Response: {response.json()}')
"
📊 Understanding Test Results
✅ Success Response (HTTP 200)
{
"message": "Request received. Buildling Application..."
}
❌ Unauthorized (HTTP 401)
{
"message": "Unauthorized: Invalid secret key."
}
Fix: Check that your .env file has API_SECRET=11032003
⚠️ Validation Error (HTTP 422)
{
"detail": [...]
}
Fix: Check the payload structure matches the Pydantic model
🔍 What Happens After Testing
For each successful test request:
- ✅ Request Accepted - Returns HTTP 200
- 🤖 LLM Processing - Generates app based on brief
- 📦 GitHub Repo Created - Creates repository with task name
- 📝 Code Pushed - Pushes README.md, LICENSE, index.html
- 🌐 Pages Enabled - Activates GitHub Pages
- 📤 Evaluation Sent - Posts results to evaluation_url
📁 Created Repositories
After running tests, check your GitHub account for repositories named:
sum-of-sales-test-001calculator-app-test-002todo-list-test-003weather-dashboard-test-004json-viewer-test-005github-user-lookup-test-006markdown-editor-test-007
Each will be live at: https://your-username.github.io/repo-name/
🛠️ Creating Your Own Test Payloads
Template structure:
{
"email": "your-email@example.com",
"secret": "11032003",
"task": "unique-task-id",
"round": 1,
"nonce": "unique-nonce",
"brief": "Description of what app should do...",
"checks": ["JavaScript validation check 1", "JavaScript validation check 2"],
"evaluation_url": "http://127.0.0.1:8000/_eval",
"attachments": [
{
"name": "filename.ext",
"url": "data:mime/type;base64,BASE64_ENCODED_CONTENT"
}
]
}
Encoding Attachments
# Encode a file to base64
base64 -w 0 myfile.csv
# Or with data URI prefix
echo "data:text/csv;base64,$(base64 -w 0 myfile.csv)"
💡 Tips
- Test Locally First - Always test on
localhost:8000before deploying - Check Server Logs - Monitor the uvicorn terminal for detailed processing info
- One at a Time - Run tests one by one to avoid GitHub API rate limits
- Clean Up - Delete test repositories from GitHub after testing
- Secret Match - Ensure
.envhasAPI_SECRET=11032003
🐛 Troubleshooting
Server not responding?
# Check if server is running
curl http://127.0.0.1:8000/
# Restart server
python -m uvicorn main:app --host 0.0.0.0 --port 8000
401 Unauthorized?
# Check environment variable
cat .env | grep API_SECRET
# Should show: API_SECRET=11032003
JSON parsing errors?
- Check recent fixes to
llm.pyare applied - Verify prompts in
app/services/prompts/are updated - Fall back to mock service if aipipe fails
📚 Related Files
/test_live_api.py- Tests live Hugging Face deployment/test_functionality.py- Runs comprehensive functionality tests/run_tests.sh- Automated test runner for all payloads/payload.markdown-to-html.json- Original example payload
Happy Testing! 🚀