CIA/e-voting-system/.claude/QUICK_START_TESTING.md
E-Voting Developer 3efdabdbbd fix: Implement vote check endpoint in frontend API proxy
- Created `/frontend/app/api/votes/check/route.ts` to handle GET requests for checking if a user has voted in a specific election.
- Added error handling for unauthorized access and missing election ID.
- Forwarded requests to the backend API and returned appropriate responses.
- Updated `/frontend/app/api/votes/history/route.ts` to fetch user's voting history with error handling.
- Ensured both endpoints utilize the authorization token for secure access.
2025-11-10 02:56:47 +01:00

5.9 KiB
Raw Permalink Blame History

Quick Start - User Testing Guide

Status: System Ready for Testing Date: November 7, 2025 All Bugs Fixed: Yes


🚀 System Access

Frontend

Backend API


New Features to Test

1 Upcoming Elections Page (NEW)

Endpoint: GET /api/elections/upcoming Frontend Route: /dashboard/votes/upcoming What it does: Shows elections that haven't started yet

To Test:

  1. Login to http://localhost:3000
  2. Go to Dashboard
  3. Click "Votes à Venir" (Upcoming Votes)
  4. Should see list of future elections

2 Archived Elections Page (NEW)

Endpoint: GET /api/elections/completed Frontend Route: /dashboard/votes/archives What it does: Shows elections that are finished

To Test:

  1. Login to http://localhost:3000
  2. Go to Dashboard
  3. Click "Archives"
  4. Should see list of past elections

3 Correct Auth State (FIXED)

What changed: has_voted now reflects actual database state Verification: Register → Check response has has_voted: false

To Test:

# Register
curl -X POST http://localhost:8000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user1@test.com",
    "password": "Pass123!",
    "first_name": "Test",
    "last_name": "User",
    "citizen_id": "ID001"
  }'

# Response should have: "has_voted": false

4 Vote Status Check (VERIFIED)

Endpoint: GET /api/votes/status?election_id=X What it does: Check if user already voted in election

To Test:

curl -X GET "http://localhost:8000/api/votes/status?election_id=1" \
  -H "Authorization: Bearer YOUR_TOKEN"

# Response: {"has_voted": false} or {"has_voted": true}

🧪 Testing Workflow

Quick Test (5 minutes)

1. Open http://localhost:3000
2. Click "Register"
3. Fill in test account:
   - Email: testuser@example.com
   - Password: TestPass123
   - First Name: Test
   - Last Name: User
   - Citizen ID: ID123456
4. Click "Register"
5. ✓ Should see Dashboard
6. Click "Votes Actifs" → Should see active elections
7. Click "Votes à Venir" → Should see upcoming elections
8. Click "Archives" → Should see completed elections
9. Try to vote
10. ✓ Should confirm vote works

Comprehensive Test (10 minutes)

Registration & Auth

  • Register new user
  • Verify has_voted: false in response
  • Logout
  • Login with same credentials
  • Verify has_voted value matches

Navigation

  • View Active Votes
  • View Upcoming Votes (NEW)
  • View Archives (NEW)
  • View Vote History
  • View Profile

Voting

  • Select an election
  • Choose a candidate
  • Submit vote
  • Verify success message
  • Try to vote again → Should see error
  • Check vote status shows voted

Blockchain

  • View blockchain page
  • Check transaction status
  • Verify vote on blockchain

🔍 Verification Checklist

Backend API

✅ GET /api/elections/active returns array
✅ GET /api/elections/upcoming returns array  ← NEW
✅ GET /api/elections/completed returns array ← NEW
✅ POST /api/auth/register includes has_voted
✅ POST /api/auth/login includes has_voted
✅ GET /api/votes/status works
✅ POST /api/votes submits votes correctly

Frontend

✅ Builds without errors
✅ All pages load
✅ Dashboard accessible
✅ Upcoming votes page shows
✅ Archives page shows
✅ Auth state correct

System

✅ Backend container healthy
✅ Frontend container healthy
✅ Database running
✅ Validators operational
✅ Blockchain functional

📋 Test Cases

Happy Path

  1. User Registration → Login → Vote → Check Results

    • Expected: All steps succeed
  2. Navigation All Pages

    • Expected: No 404 errors
  3. Election Filtering

    • Expected: Each endpoint returns correct elections

Edge Cases

  1. Vote Twice

    • Expected: Second vote rejected
  2. Invalid Election

    • Expected: Error returned
  3. Invalid Candidate

    • Expected: Error returned

🛠️ Troubleshooting

If Login Shows Wrong has_voted

  • Check: Response from /api/auth/login
  • Fix: Already fixed in this deployment

If Upcoming/Archives Pages Don't Load

  • Check: Browser console for errors
  • Verify: Endpoints exist: curl http://localhost:8000/api/elections/upcoming
  • Status: Already deployed

If Blockchain Fails

  • Expected: Fallback to local blockchain
  • Check: Vote still records in database
  • Status: Handled automatically

If Database Issue

  • Restart: docker compose restart mariadb
  • Check: docker compose logs mariadb

🎯 Success Criteria

System meets success criteria when:

  • Can register new users
  • Login shows correct has_voted
  • Can view all election lists (active, upcoming, completed)
  • Can submit votes
  • Can't vote twice
  • Can check vote status
  • Blockchain operations work (or fallback gracefully)
  • No errors in browser console
  • No errors in backend logs

📞 Quick Reference

Restart Everything:

docker compose down && sleep 5 && docker compose up -d --build

Check Status:

docker compose ps

View Logs:

docker compose logs backend -f      # Backend logs
docker compose logs frontend -f     # Frontend logs

Direct API Test:

curl http://localhost:8000/health

All Systems Ready!

BACKEND:     ✅ Healthy
FRONTEND:    ✅ Healthy
DATABASE:    ✅ Ready
VALIDATORS:  ✅ Connected
BLOCKCHAIN:  ✅ Running

READY TO TEST! 🚀

Generated: November 7, 2025 Deployment: Fresh build with all bug fixes Testing Time: ~10 minutes for full verification