# Testing Checklist: Foto Absensi Guru

## Pre-Test: Verifikasi System

### ✅ 1. Storage Symlink
```powershell
Get-Item public\storage | Select-Object LinkType, Target
```
**Expected:**
```
LinkType: Junction
Target: C:\laragon\www\laravel-13\storage\app\public
```

### ✅ 2. View Code
**File:** `resources/views/simaju/absensi-guru/index.blade.php`
```blade
{{ asset('storage/' . $a->foto_masuk) }}
{{ asset('storage/' . $a->foto_pulang) }}
```

### ✅ 3. Controller Code
**File:** `app/Http/Controllers/Simaju/AbsensiGuruController.php`
```php
Storage::put('public/' . $fotoPath, base64_decode($fotoData));
```

## Manual Test Cases

### Test 1: Absen Masuk dengan Foto ✅

**Steps:**
1. Login sebagai guru (username: guru password)
2. Navigate to: `http://localhost/simaju/absensi-guru/create`
3. Browser akan meminta izin kamera - **Allow**
4. Browser akan meminta izin lokasi - **Allow**
5. Tunggu hingga:
   - ✅ Wajah terdeteksi (tampil di preview kamera)
   - ✅ GPS OK (koordinat muncul)
6. Klik tombol **"Ambil Foto"**
7. Foto preview muncul
8. Klik **"Simpan Absensi"**
9. Redirect ke index

**Verify:**
- [ ] Success message muncul
- [ ] Record baru tampil di tabel
- [ ] Foto masuk tampil dengan border **HIJAU**
- [ ] Badge "Masuk" tampil di pojok kanan bawah foto
- [ ] Hover foto → scale animation
- [ ] Klik foto → Modal fullscreen terbuka
- [ ] Browser console tidak ada error 404

**Database Check:**
```sql
SELECT foto_masuk FROM absensi_gurus ORDER BY id DESC LIMIT 1;
```
**Expected Result:**
```
absensi-guru/{nama-guru-slug}/masuk_2026-08-07_HHMMSS.jpg
```

**File Check:**
```powershell
Get-ChildItem storage\app\public\absensi-guru -Recurse -File | Select-Object Name
```

---

### Test 2: Absen Pulang dengan Foto ✅

**Steps:**
1. Di halaman index absensi
2. Cari record yang **belum pulang** (jam_pulang = NULL)
3. Klik tombol **"Absen Pulang"** (hijau)
4. Modal terbuka dengan kamera aktif
5. Browser minta izin kamera & lokasi - **Allow**
6. Tunggu hingga wajah terdeteksi & GPS OK
7. Klik **"Ambil Foto"**
8. Klik **"Simpan Absensi Pulang"**

**Verify:**
- [ ] Success message muncul
- [ ] Foto pulang tampil dengan border **BIRU**
- [ ] Badge "Pulang" tampil di pojok kanan bawah foto
- [ ] Jam pulang terisi di kolom tabel
- [ ] Tombol "Absen Pulang" hilang (karena sudah pulang)
- [ ] Klik foto pulang → Modal fullscreen dengan title "Foto Pulang - Nama Guru"

**Database Check:**
```sql
SELECT foto_pulang, jam_pulang FROM absensi_gurus ORDER BY id DESC LIMIT 1;
```

---

### Test 3: Placeholder untuk Data Tanpa Foto ✅

**Scenario A: Foto Masuk NULL**
- [ ] Placeholder tampil dengan background **gray solid**
- [ ] Border **solid** gray
- [ ] Icon **camera** tampil
- [ ] Text **"No Photo"** tampil
- [ ] Ukuran 64x80px (w-16 h-20)

**Scenario B: Foto Pulang NULL**
- [ ] Placeholder tampil dengan background **gray light**
- [ ] Border **dashed** gray
- [ ] Icon **clock** tampil
- [ ] Text **"Belum"** tampil
- [ ] Ukuran 64x80px (w-16 h-20)

---

### Test 4: Modal Preview Fullscreen ✅

**Steps:**
1. Klik foto masuk atau pulang yang ada
2. Modal fullscreen terbuka

**Verify:**
- [ ] Background hitam semi-transparan
- [ ] Foto tampil ukuran besar di tengah
- [ ] Title tampil: "Foto Masuk - Nama Guru" atau "Foto Pulang - Nama Guru"
- [ ] Tombol close (X) di pojok kanan atas
- [ ] Klik tombol close → modal tertutup
- [ ] Tekan ESC key → modal tertutup
- [ ] Klik area gelap → modal tertutup

---

### Test 5: URL Accessibility ✅

**Test Direct URL Access:**
```
http://localhost/storage/absensi-guru/{nama-guru-slug}/masuk_2026-08-07_HHMMSS.jpg
```

**Verify:**
- [ ] Foto tampil langsung di browser
- [ ] HTTP Status 200 OK
- [ ] Content-Type: image/jpeg
- [ ] File size > 0 bytes

**If 404 Error:**
```powershell
# Check symlink
Get-Item public\storage

# Recreate if broken
Remove-Item public\storage
php artisan storage:link
```

---

## Expected Results Summary

| Test Case | Expected Behavior | Status |
|-----------|-------------------|--------|
| **Absen Masuk** | Foto border hijau, badge "Masuk" | ✅ |
| **Absen Pulang** | Foto border biru, badge "Pulang" | ✅ |
| **Placeholder Masuk** | Icon camera, "No Photo", solid border | ✅ |
| **Placeholder Pulang** | Icon clock, "Belum", dashed border | ✅ |
| **Modal Preview** | Fullscreen, ESC close, click outside close | ✅ |
| **Direct URL** | HTTP 200, image/jpeg | ✅ |

---

## Troubleshooting

### Issue: Foto tidak tampil (404)
**Solution:**
```powershell
# 1. Check symlink
Get-Item public\storage | Select-Object LinkType, Target

# 2. If broken, recreate
Remove-Item public\storage -Force
php artisan storage:link

# 3. Verify
Get-ChildItem public\storage
```

### Issue: Placeholder tidak tampil dengan benar
**Solution:**
```powershell
# Clear cache
php artisan view:clear
php artisan cache:clear

# Hard refresh browser
Ctrl + F5
```

### Issue: Kamera tidak muncul
**Causes:**
- Browser tidak support getUserMedia API
- HTTPS required (use localhost exception)
- Permission denied by user
- Kamera digunakan aplikasi lain

**Solution:**
- Use Chrome/Firefox/Edge (modern browser)
- Allow camera permission in browser
- Close other apps using camera
- Restart browser

### Issue: GPS tidak terdeteksi
**Causes:**
- Browser tidak support Geolocation API
- Permission denied
- Location services disabled

**Solution:**
- Enable location in Windows settings
- Allow location in browser
- Use modern browser

---

**Created:** 07 Agustus 2026  
**Status:** System already correct, testing to verify functionality
