# Quick Start Guide - Phase I Testing

## Prerequisites
- ✅ PHP 8.2+
- ✅ Composer installed
- ✅ Node.js & npm installed
- ✅ MySQL or SQLite database
- ✅ Git (optional)

## Setup Instructions

### 1. Environment Configuration
The `.env` file should already be configured. Verify these settings:

```env
APP_NAME=CuraHealthLine
APP_ENV=local
APP_DEBUG=true
DB_CONNECTION=sqlite  # or mysql
MAIL_MAILER=log
```

### 2. Database Setup
The migrations are already run. To verify:

```bash
php artisan migrate:status
```

To start fresh (WARNING: This will delete all data):

```bash
php artisan migrate:fresh
```

### 3. Storage Link
Already created. Verify:

```bash
php artisan about
```

Look for "Storage" section showing "LINKED".

### 4. Asset Compilation
Compile frontend assets:

```bash
npm run build
```

For development with hot reload:

```bash
npm run dev
```

### 5. Start Development Server
```bash
php artisan serve
```

Visit: http://localhost:8000

## Testing Scenarios

### Scenario 1: Nurse Journey (15 minutes)

1. **Register as Nurse**
   - Visit http://localhost:8000/register?role=nurse
   - Fill in: Name, Email, Password
   - Click Register
   - ✅ Should redirect to nurse dashboard

2. **Complete Profile**
   - Click "Edit Profile" (or go to /nurse/profile/edit)
   - Fill in:
     - Full Name
     - Primary Specialty: "ICU" or "Emergency"
     - Country: "US" or "UK"
     - City: Your city
     - Years of Experience: 5
     - NCLEX Status: "Passed" or "Not taken"
     - Willing to Relocate: Yes
   - Click Save
   - ✅ Profile should save successfully

3. **Upload Documents**
   - On profile page, find "Upload Document" section
   - Choose File: Upload a PDF or DOC file (max 5MB)
   - Type: "CV" or "License"
   - Click Upload
   - ✅ Document should appear in documents list

4. **Browse Jobs**
   - Click "Jobs" in navigation
   - Use search filters:
     - Keyword: "nurse"
     - Location: Your country
   - Click Search
   - ✅ Jobs should appear (create some as employer first)

5. **Apply to Job**
   - Click "View details" on a job
   - Click "Apply Now"
   - Add optional cover letter
   - Submit
   - ✅ Should see success message
   - ✅ Trying to apply again should show error

6. **View Applications**
   - Go to "My Applications"
   - ✅ Your application should appear with status

### Scenario 2: Employer Journey (15 minutes)

1. **Register as Employer**
   - Visit http://localhost:8000/register?role=employer
   - Fill in: Name, Email, Password, Employer Name
   - Click Register
   - ✅ Should redirect to employer dashboard

2. **Complete Company Profile**
   - Click "Edit Profile"
   - Fill in:
     - Company Name
     - Website: https://example.com
     - Country
     - City
     - Industry: "Healthcare"
     - About: Brief description
   - Click Save
   - ✅ Profile should save

3. **Create Job Posting**
   - Click "Post a Job" or "Jobs" > "Create New"
   - Fill in:
     - Title: "ICU Nurse Needed"
     - Location: "New York, NY"
     - Location Country: "US"
     - Location City: "New York"
     - Employment Type: "Full-time"
     - Visa Sponsorship: Yes
     - Required Specialty: "ICU"
     - Required Experience: 3 years
     - Salary Range: 70000 - 90000
     - Currency: USD
     - Description: Job details
   - Click Post
   - ✅ Job should appear in your jobs list

4. **View Applicants**
   - After nurse applies (see Scenario 1)
   - Go to your job
   - Click "View Applicants"
   - ✅ Should see list of applicants

5. **Review Application**
   - Click on an applicant
   - ✅ Should see application details
   - Click "View Profile" to see full nurse profile
   - ✅ Should see nurse qualifications and documents

6. **Update Application Status**
   - On application detail page
   - Change status to "Shortlisted"
   - Add notes (optional)
   - Click Update
   - ✅ Status should change
   - ✅ Nurse should see updated status in "My Applications"

### Scenario 3: Nurse Networking (10 minutes)

1. **Browse Nurses** (as Nurse A)
   - Login as first nurse
   - Go to "Connections"
   - ✅ Should see list of other nurses
   - Use filters: Country, Specialty, NCLEX status

2. **Send Connection Request**
   - Click "Connect" on another nurse
   - ✅ Should see success message
   - ✅ Clicking again should show "already exists" error

3. **Accept Connection** (as Nurse B)
   - Login as second nurse
   - Go to "Connections"
   - ✅ Should see pending request
   - Click "Accept"
   - ✅ Status should change to "Accepted"

4. **Send Message**
   - Login as Nurse A
   - Go to "Messages"
   - ✅ Should see conversation with Nurse B
   - Click on conversation
   - Type message
   - Send
   - ✅ Message should appear

5. **Receive Message**
   - Login as Nurse B
   - Go to "Messages"
   - Open conversation with Nurse A
   - ✅ Should see message from Nurse A
   - Reply
   - ✅ Messages should display in order

### Scenario 4: Admin Management (10 minutes)

1. **Create Admin User**
   First, manually create admin in database or update existing user:
   
   ```sql
   UPDATE users SET role = 'admin' WHERE email = 'your@email.com';
   ```

2. **Login as Admin**
   - Visit http://localhost:8000/login
   - Login with admin credentials
   - ✅ Should redirect to admin dashboard

3. **View Metrics**
   - On dashboard, verify:
     - Total jobs count
     - Open jobs count
     - Nurse count
     - Employer count
   - ✅ All counts should match database

4. **Manage Employers**
   - Click "Employers"
   - ✅ See list of all employers
   - Click "Verify" on an employer
   - ✅ Status should toggle
   - ✅ Verified badge should appear/disappear

5. **Manage Jobs**
   - Click "Jobs"
   - ✅ See all jobs from all employers
   - Change job status (e.g., to "Paused")
   - ✅ Status should update
   - Delete a job
   - ✅ Job should be removed

6. **Manage Users**
   - Click "Users"
   - ✅ See all registered users
   - Click "Deactivate" on a user
   - ✅ User status should change to inactive
   - Logout and try to login as that user
   - ✅ Should be logged out immediately or blocked

## Edge Cases to Test

### Duplicate Prevention
1. **Duplicate Application**
   - Apply to job as nurse
   - Try to apply again
   - ✅ Should show error message

2. **Duplicate Connection**
   - Send connection request
   - Try to send again
   - ✅ Should show error message

3. **Self Connection**
   - Try to connect with yourself (modify form)
   - ✅ Should show error message

### Authorization
1. **Nurse accessing Employer Routes**
   - Login as nurse
   - Visit http://localhost:8000/employer/jobs
   - ✅ Should get 403 Forbidden

2. **Employer accessing Nurse Routes**
   - Login as employer
   - Visit http://localhost:8000/nurse/connections
   - ✅ Should get 403 Forbidden

3. **Delete Another User's Document**
   - Login as Nurse A
   - Try to delete document belonging to Nurse B (modify URL)
   - ✅ Should get 403 Forbidden

### Validation
1. **Invalid File Upload**
   - Try to upload 10MB file
   - ✅ Should show size error
   - Try to upload .exe file
   - ✅ Should show file type error

2. **Invalid Job Data**
   - Create job without title
   - ✅ Should show validation error
   - Enter negative salary
   - ✅ Should show validation error

3. **XSS Prevention**
   - Send message with HTML: `<script>alert('XSS')</script>`
   - ✅ Should be stripped, only plain text shown

## Common Issues & Solutions

### Issue: "Route not found"
**Solution**: Clear route cache
```bash
php artisan route:clear
php artisan config:clear
```

### Issue: "Class not found"
**Solution**: Regenerate autoload files
```bash
composer dump-autoload
```

### Issue: "File not found" for uploaded files
**Solution**: Create storage link
```bash
php artisan storage:link
```

### Issue: Styles not loading
**Solution**: Rebuild assets
```bash
npm run build
```

### Issue: Database error on startup
**Solution**: Run migrations
```bash
php artisan migrate
```

## Quick Database Reset

To start completely fresh:

```bash
php artisan migrate:fresh
php artisan storage:link
```

## Performance Testing (Optional)

Test with multiple users:

1. Create 10 nurse accounts
2. Create 5 employer accounts
3. Create 20 job postings
4. Submit 50 applications
5. Test dashboard load times
6. Test search performance

## Security Checklist

- [ ] Try SQL injection in search fields
- [ ] Try XSS in message/comment fields
- [ ] Try accessing other users' data
- [ ] Try bypassing role restrictions
- [ ] Test CSRF protection (disable token temporarily)
- [ ] Test file upload restrictions

## Browser Compatibility

Test on:
- [ ] Chrome (latest)
- [ ] Firefox (latest)
- [ ] Safari (latest)
- [ ] Edge (latest)

## Mobile Responsiveness

Test all flows on:
- [ ] iPhone (Safari)
- [ ] Android (Chrome)
- [ ] Tablet (iPad/Android)

## Final Validation

Before marking complete:

1. All 4 scenarios run successfully
2. All edge cases handled correctly
3. No console errors in browser
4. No errors in `storage/logs/laravel.log`
5. All forms submit correctly
6. All redirects work
7. All authorization checks work
8. Database constraints prevent bad data

## Support

For issues during testing:

1. Check `storage/logs/laravel.log`
2. Check browser console (F12)
3. Run `php artisan route:list` to verify routes
4. Run `php artisan about` to check environment
5. Review PHASE_I_TESTING_REPORT.md for details

## Next Steps After Testing

1. Fix any bugs found
2. Optimize database queries if needed
3. Add indexes for frequently queried fields
4. Configure production environment variables
5. Set up proper email service (SendGrid, Mailgun, etc.)
6. Deploy to staging environment
7. Conduct user acceptance testing
8. Deploy to production

---

**Happy Testing! 🚀**
