Complete guide for testing the Lead Capture System.
Before testing, ensure you have:
- ✅ Cloned the repository
- ✅ Installed dependencies (
npm install) - ✅ Created
.env.localwith valid GitHub credentials - ✅ Dev server running (
npm run dev)
# Clone the repository
git clone https://github.com/omega-suite-finance/lead-capture-system.git
cd lead-capture-system
# Install dependencies
npm install
# Configure environment
cp .env.example .env.local
# Edit .env.local and add your GitHub token and repo
# GITHUB_TOKEN=ghp_your_token_here
# GITHUB_REPO=omega-suite-finance/lead-capture-system
# Start dev server
npm run devcurl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"company": "ACME Corp",
"message": "I am interested in your services. Please contact me."
}'Expected Response (201):
{
"success": true,
"message": "Your message has been received. We'll get back to you soon!",
"issueUrl": "https://github.com/omega-suite-finance/lead-capture-system/issues/1"
}Expected GitHub Issue:
- Title:
🎯 Lead: John Doe (ACME Corp) - Labels:
lead,contact-form - Body: Formatted table with all information
curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Jane Smith",
"email": "jane@example.com",
"message": "Looking forward to hearing from you!"
}'Expected Response (201):
{
"success": true,
"message": "Your message has been received. We'll get back to you soon!",
"issueUrl": "https://github.com/omega-suite-finance/lead-capture-system/issues/2"
}Expected GitHub Issue:
- Title:
🎯 Lead: Jane Smith - Company field: "Not provided"
curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"message": "This should fail"
}'Expected Response (400):
{
"error": "Missing required fields: name, email, and message are required"
}curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"message": "This should fail"
}'Expected Response (400):
{
"error": "Missing required fields: name, email, and message are required"
}curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "test@example.com"
}'Expected Response (400):
{
"error": "Missing required fields: name, email, and message are required"
}curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "invalid-email",
"message": "This should fail"
}'Expected Response (400):
{
"error": "Invalid email format"
}curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "François O'\''Brien-Smith",
"email": "francois@example.com",
"company": "Société Générale",
"message": "Testing with special characters: é, à, ñ, ü"
}'Expected Response (201):
{
"success": true,
"message": "Your message has been received. We'll get back to you soon!",
"issueUrl": "https://github.com/omega-suite-finance/lead-capture-system/issues/3"
}curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Sarah Johnson",
"email": "sarah@example.com",
"company": "TechCorp Inc",
"message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}'Expected Response (201): Should handle long messages without issues.
Before running this test, temporarily rename .env.local:
mv .env.local .env.local.backup
curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "test@example.com",
"message": "This should fail"
}'
# Restore .env.local
mv .env.local.backup .env.localExpected Response (500):
{
"error": "Server configuration error. Please contact the administrator."
}Expected Console Log:
Missing GitHub configuration
Edit .env.local temporarily with an invalid token:
# In .env.local, set:
# GITHUB_TOKEN=ghp_invalid_token_123456
curl -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "test@example.com",
"message": "This should fail"
}'
# Restore valid token after testExpected Response (500):
{
"error": "Failed to create GitHub Issue. Please try again later."
}- Open http://localhost:3000
- Fill out the form:
- Name: Your Name
- Email: your@email.com
- Company: (optional)
- Message: Test message
- Click "Send Message"
- Verify success message appears
- Check GitHub Issues for new issue
- Fill form with invalid email:
not-an-email - Submit form
- Verify error message appears in red box
- Fill form with valid data
- Submit and watch "Sending..." state
- Verify button is disabled during submission
After each successful test:
- Go to https://github.com/omega-suite-finance/lead-capture-system/issues
- Verify new issue was created
- Check issue title format:
🎯 Lead: [Name] ([Company]) - Verify issue has labels:
lead,contact-form - Check issue body has formatted table
- Verify email notification was sent to your GitHub email
Save this as test-all.sh:
#!/bin/bash
API_URL="http://localhost:3000/api/contact"
echo "🧪 Testing Lead Capture System..."
echo ""
# Test 1: Valid submission
echo "Test 1: Valid submission with all fields"
curl -s -X POST $API_URL \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"john@example.com","company":"ACME","message":"Test"}' | jq
echo ""
# Test 2: No company
echo "Test 2: Valid submission without company"
curl -s -X POST $API_URL \
-H "Content-Type: application/json" \
-d '{"name":"Jane Smith","email":"jane@example.com","message":"Test"}' | jq
echo ""
# Test 3: Missing name
echo "Test 3: Missing name (should fail)"
curl -s -X POST $API_URL \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","message":"Test"}' | jq
echo ""
# Test 4: Invalid email
echo "Test 4: Invalid email (should fail)"
curl -s -X POST $API_URL \
-H "Content-Type: application/json" \
-d '{"name":"Test","email":"not-an-email","message":"Test"}' | jq
echo ""
echo "✅ All tests completed!"Make it executable:
chmod +x test-all.sh
./test-all.shTest multiple submissions:
# Send 10 submissions
for i in {1..10}; do
curl -s -X POST http://localhost:3000/api/contact \
-H "Content-Type: application/json" \
-d "{\"name\":\"Test User $i\",\"email\":\"test$i@example.com\",\"message\":\"Performance test #$i\"}"
echo ""
doneVerify all 10 Issues were created in GitHub.
✅ All valid submissions create GitHub Issues
✅ All validation errors return appropriate error messages
✅ GitHub sends email notification for each new Issue
✅ Form resets after successful submission
✅ Loading state displays correctly
✅ Error messages display in UI
✅ Special characters handled correctly
✅ Long messages don't break formatting
✅ Configuration errors handled gracefully
Check GitHub notification settings: https://github.com/settings/notifications
- Verify GitHub token has
repopermission - Check token is not expired
- Verify repository name is correct in
.env.local - Check server console for error messages
This shouldn't happen with Next.js API routes, but if it does:
- Make sure you're accessing
http://localhost:3000(not127.0.0.1) - Clear browser cache
Ready to test! 🚀