Spaces:
Sleeping
Sleeping
Integration Tests
Available Tests
1. Authentication API Test
Tests the complete auth flow: register, login, profile management.
node tests/integration/test_auth_api.js
2. Invitation Flow Test
Tests the complete invitation workflow:
- Login as platform admin
- Create contractor organization
- Invite user to organization
- Validate invitation token
- List invitations
node tests/integration/test_invitation_flow.js
Configuration
Both tests use:
- Server:
https://kamau1-swiftops-backend.hf.space - Admin Email:
lewis.kamau421@gmail.com - Admin Password:
TestPass123
Invitation Test Configuration
- Invitee Email:
irene@example.com - Invitee Phone:
+254799456976 - Role:
field_agent - Organization: TechInstall Kenya Ltd (contractor)
Expected Output
Successful Invitation Flow
π SwiftOps User Invitation Flow Test
π Server: https://kamau1-swiftops-backend.hf.space
π€ Admin: lewis.kamau421@gmail.com
π§ Inviting: irene@example.com (+254799456976)
π Step 1: Login as Platform Admin
β
Login successful
π’ Step 2: Create Contractor Organization
β
Contractor created successfully
π§ Step 3: Invite User to Contractor
β
Invitation created successfully
π± Invitation URL:
https://swiftops.atomio.tech/accept-invitation?token=xxx
β
Step 4: Validate Invitation Token (Public)
β
Invitation validated successfully
π Step 5: List All Invitations
β
Invitations retrieved successfully
π All steps completed successfully!
Troubleshooting
Server Not Reachable
- Check if the server is running
- Verify the BASE_URL is correct
- Check network connectivity
Authentication Failed
- Verify admin credentials are correct
- Check if user exists in database
- Ensure Supabase Auth is configured
Invitation Failed
- Check environment variables are set (WASENDER_API_KEY, RESEND_API_KEY)
- Verify contractor was created successfully
- Check database migrations are applied
WhatsApp Not Sent
- Verify WASENDER_API_KEY is valid
- Check phone number format (+country code)
- System will fallback to email automatically
Next Steps After Successful Test
- Check WhatsApp - Irene should receive invitation on +254799456976
- Click Link - Opens registration page with pre-filled email
- Complete Registration - Irene fills name and password
- Auto Login - User is created and logged in automatically
Manual Testing
You can also test the API manually using cURL:
Create Invitation
curl -X POST "https://kamau1-swiftops-backend.hf.space/api/v1/invitations" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "irene@example.com",
"phone": "+254799456976",
"role": "field_agent",
"contractor_id": "YOUR_CONTRACTOR_ID",
"invitation_method": "whatsapp"
}'
Validate Token (Public)
curl -X POST "https://kamau1-swiftops-backend.hf.space/api/v1/invitations/validate" \
-H "Content-Type: application/json" \
-d '{
"token": "INVITATION_TOKEN"
}'
Accept Invitation (Public)
curl -X POST "https://kamau1-swiftops-backend.hf.space/api/v1/invitations/accept" \
-H "Content-Type: application/json" \
-d '{
"token": "INVITATION_TOKEN",
"first_name": "Irene",
"last_name": "Wanjiku",
"password": "SecurePass123!",
"phone": "+254799456976"
}'