# Quick Testing Guide - CURA Jobs UX Improvements

## Setup Instructions
1. No database migrations needed (JobSave table already exists)
2. Changes are backward compatible with existing functionality
3. All features work with authenticated and unauthenticated users

## Feature 1: Quick Filter Presets ⚡

### Location
Right sidebar of `/jobs` page (jobs/index.blade.php)

### What to Test
1. Click "🌐 Remote" button
   - Expected: Filter for Remote work mode
   - URL should show: `?work_mode=Remote`

2. Click "📋 Visa" button
   - Expected: Filter for visa sponsorship
   - URL should show: `?visa_only=1`

3. Click "📦 Relocation" button
   - Expected: Filter for relocation support
   - URL should show: `?relocation_only=1`

4. Click "💰 $80K+" button
   - Expected: Filter for minimum salary
   - URL should show: `?min_salary=80000`

5. Click "✈️ Travel" button
   - Expected: Filter for travel employment type
   - URL should show: `?employment_type=Travel`

6. Click "⭐ Best Starter" button
   - Expected: Filter for full-time + visa + relocation
   - URL should show: `?employment_type=Full-time&visa_only=1&relocation_only=1`

7. Combine presets (e.g., click "Remote" then "Visa")
   - Expected: Both filters applied
   - Should show "Filtered by: Remote, Visa sponsorship" tags

### Common Issues & Solutions
- **Preset links not working**: Check that `/jobs` route exists
- **Filter not applying**: Verify JobController filters include the parameters
- **Filter tags not showing**: Check activeFilters are being built correctly

---

## Feature 2: Save Jobs Button 💾

### Location
Bottom right of each job card in `/jobs` page (partials/cards.blade.php)

### What to Test
1. **When Logged Out**
   - Expected: Save button NOT visible
   - (Only shows for authenticated users)

2. **When Logged In - Unsaved State**
   - Button shows: "Save" with bookmark icon
   - Button color: white background, slate text
   - Expected URL: `POST /jobs/{jobId}/save`

3. **Click Save Button**
   - Expected: Button changes to amber background
   - Button text changes to "Saved"
   - No page reload
   - Save count in sidebar updates

4. **Click Saved Button Again (Unsave)**
   - Expected: Button returns to white background
   - Button text changes back to "Save"
   - Save count in sidebar updates

5. **Test on Multiple Jobs**
   - Save 3-5 different jobs
   - Sidebar count should show correct total
   - All saved buttons should show "Saved" state

6. **Test Across Pages**
   - Save a job on page 1
   - Navigate to page 2
   - Saved state should persist
   - All previously saved jobs still show as saved

### Network Testing (Browser DevTools)
- Open Network tab
- Click save button
- Should see `POST /jobs/{id}/save`
- Response should be `{"saved": true}` or `{"saved": false}`
- Response code: 200 OK

### JavaScript Console
- No errors should appear
- Check: `console.log()` for successful save/unsave messages

---

## Feature 3: Saved Jobs Count Widget 📊

### Location
Right sidebar, above "Popular Locations" (jobs/index.blade.php)

### What to Test
1. **When Not Logged In**
   - Widget should NOT appear

2. **When Logged In - No Saves**
   - Shows: "You have 0 saved jobs"
   - Shows: "Start saving jobs to build your list of favorites!"
   - "View Saved Jobs" button DISABLED

3. **After Saving First Job**
   - Widget updates: "You have 1 saved job"
   - "View Saved Jobs →" button appears and is ENABLED

4. **After Saving Multiple Jobs**
   - Counter increases: "You have 5 saved jobs"
   - Plural form is correct: "jobs" not "job"

5. **Click "View Saved Jobs →" Button**
   - Expected: Redirects to `/jobs/saved`
   - Should be protected route (login required)

---

## Feature 4: Saved Jobs Page 📄

### Location
`/jobs/saved` (Requires authentication)

### What to Test

#### A. Access Control
1. When not logged in:
   - Redirect to login page
   - URL: `/login` with redirect parameter

2. When logged in:
   - Full access to page
   - Can view all saved jobs

#### B. With Saved Jobs (Test with 5+ saved jobs)
1. Page header shows:
   - "Saved Jobs" title
   - "💾 Your Saved Jobs" heading
   - Blue info box showing count

2. Job grid displays:
   - All saved jobs in 2-column grid (responsive)
   - Each card shows full job details
   - Save button visible on each card (should show "Saved" state)

3. Pagination (if more than 20 jobs):
   - Next/Previous buttons work
   - Current page indicator shows
   - Filter context maintained across pages

4. Unsave Functionality:
   - Click "Save" button on a card (shows "Unsave" action)
   - Card should fade out and be removed
   - Total count decrements
   - Page reloads if all jobs removed

#### C. Empty State (Test when no jobs saved)
1. Page displays:
   - Large bookmark icon
   - "No Saved Jobs Yet" heading
   - Helpful message
   - "Browse All Jobs →" button
   - Three feature boxes explaining save functionality

2. Feature Boxes Show:
   - ✅ "Save Your Favorites"
   - ✅ "Compare & Review"
   - ✅ "Apply When Ready"

#### D. Navigation
1. Back button works:
   - "← Jobs" link at top
   - Returns to `/jobs`
   - Maintains previous filter state

2. "Browse All Jobs →" button:
   - Links to `/jobs`
   - Works from empty state

---

## Feature 5: Response to Edge Cases

### Test Scenarios

1. **Double-Click Save Button**
   - Only one request should be sent
   - UI should handle concurrent operations

2. **Network Error While Saving**
   - Should show error message
   - Button should revert to previous state
   - User can retry

3. **Save Job, Then Delete Job (Admin)**
   - Saved reference should be removed
   - No errors in saved jobs page

4. **Session Timeout While on Saved Jobs**
   - Should redirect to login
   - Should maintain saved jobs after re-login

5. **Very Long Job Titles**
   - Text should truncate cleanly
   - No layout breaking
   - Tooltip shows full title

---

## Verification Checklist

### ✅ Backend
- [ ] JobController passes `$savedJobIds` to view
- [ ] PublicJobController::toggleSave() works
- [ ] PublicJobController::savedJobs() returns data
- [ ] Routes configured correctly
- [ ] Authentication middleware works
- [ ] CSRF tokens validated

### ✅ Frontend
- [ ] Quick filters display correctly
- [ ] Save buttons appear for logged-in users
- [ ] Save button AJAX works without reload
- [ ] Sidebar count updates on save
- [ ] Visual feedback (amber color) shows
- [ ] Saved jobs page displays correctly
- [ ] Empty state shows when no saves
- [ ] Pagination works on saved jobs page
- [ ] Responsive design on mobile

### ✅ User Experience
- [ ] Filters are easy to find and use
- [ ] Save action is obvious
- [ ] Saved state is clearly indicated
- [ ] Easy to navigate between jobs and saved jobs
- [ ] Clear feedback on all actions

---

## Performance Testing

1. **Page Load Time**
   - Jobs page: Should load in <1 second
   - Saved jobs page: Should load in <1 second

2. **Save/Unsave Speed**
   - AJAX response: <200ms
   - No lag when clicking buttons

3. **Large Save List**
   - 100+ saved jobs should still work
   - Pagination handles loading

---

## Browser Testing

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

---

## Rollback Instructions

If issues occur:

### Option 1: Quick Disable
Comment out in `jobs/index.blade.php`:
```blade
{{-- @if(auth()->check()) --}}
{{-- Saved Jobs widget code --}}
{{-- @endif --}}

{{-- Quick filters section --}}
```

### Option 2: Full Rollback
```bash
git revert <commit-hash>
```

### Option 3: Database
No database changes required - just revert code files.

---

## Support & Debugging

### If Save Button Doesn't Work

1. Check browser console: `F12 → Console`
   - Look for JavaScript errors
   - Look for CSRF token warnings

2. Check Network tab: `F12 → Network`
   - Look for failed requests
   - Check response codes (should be 200)
   - Check CSRF token header

3. Check User is Authenticated
   - Login required to save
   - Check `auth()->check()`

### If Saved Jobs Page Doesn't Load

1. Check user is logged in
   - Should redirect to `/login` if not
   
2. Check JobSave relationship
   - Verify `User::jobSaves()` exists
   - Check foreign keys

3. Check route exists
   - `php artisan route:list | grep saved`

### If Filters Don't Work

1. Check query parameters are correct
2. Verify JobController filters include parameter
3. Check filter options are returned

---

## Success Criteria

✅ All features implemented and tested
✅ No breaking changes to existing functionality
✅ Authentication properly enforced
✅ Database integrity maintained
✅ Performance acceptable
✅ Mobile responsive
✅ CSRF protection active
✅ Proper error handling
✅ User feedback on all actions
✅ No console errors

**Happy Testing! 🚀**
