- Open the app in your browser
- Press F12 to open DevTools
- Go to Console tab (keep it open for all tests)
- Go to Application tab → Storage → Clear site data → Clear all
- Close DevTools (or keep Console tab visible)
- Make sure you're ONLINE (WiFi/Ethernet connected)
- Login with your student credentials
- Check Console - you should see:
✅ Session saved for offline access: your-email@example.com ✅ Categories cached: X items ✅ Lectures cached: Y items - If you see this, Session and data are saved! ✅
- Go to the Lectures page
- Click "View PDF" on 2-3 different lectures
- Wait 3 seconds after each one (for background caching)
- Close the PDF tabs
- F12 → Application tab
- Local Storage →
http://localhost:5173 - Look for keys:
lms_cached_categories(subjects/stages)lms_cached_lectures(lectures list)
- Click on them to see JSON data
Option A - Chrome DevTools:
- Press F12 → Network tab
- Check the "Offline" checkbox at the top
- You should see "
⚠️ No internet" in the Network tab
Option B - Disable WiFi:
- Turn off WiFi or unplug ethernet
- Wait 2 seconds
- Press F5 or Ctrl+R to refresh
- Watch the Console - you should see:
✅ Found valid cached session: your-email@example.com Found cached session on mount
- ✅ You stay logged in
- ✅ You see the lectures page
- ✅ NO login screen!
- ❌ Check console for errors
- ❌ Check if session was saved (Step 2)
- ❌ Check Application → Local Storage →
lms_auth_session
Check Console for these messages:
-
If you see:
❌ No cached session found- Cause: Session wasn't saved
- Fix:
- Go back online
- Login again
- Make sure you see:
✅ Session saved for offline access - Try offline again
-
If you see:
⏰ Session expired- Cause: More than 7 days passed
- Fix: Login again while online
-
If you see:
Error getting cached session- Cause: localStorage is disabled or corrupted
- Fix:
- Check if you're in Incognito mode (doesn't work there)
- Clear site data and try again
- Check browser settings for localStorage
- F12 → Application tab
- Local Storage →
http://localhost:5173 - Look for key:
lms_auth_session - Click on it - you should see JSON with your user data
- F12 → Application tab
- Local Storage →
http://localhost:5173 - Look for keys:
lms_cached_categories(subjects/stages)lms_cached_lectures(lectures list)
- Click on them to see JSON data
Example:
{
"user": {
"id": "abc123",
"email": "student@test.com",
"name": "Student Name",
"role": "student",
...
},
"expiresAt": 1234567890,
"lastActivity": 1234567890
}If you don't see this:
- Session wasn't saved
- Login again while online
- F12 → Application tab
- IndexedDB → LectureCache → lectures
- You should see entries for each lecture you viewed
If you don't see any:
- Lectures weren't cached
- View some lectures while online
- Wait 3 seconds after each
- Check again
✅ Session saved for offline access: email@example.com
✅ Found valid cached session: email@example.com
Found cached session on mount
📦 Loading cached categories for immediate display
📦 Loading cached lectures for immediate display
📡 Fetching fresh categories from Firebase
📡 Fetching fresh lectures from Firebase
✅ Categories updated from Firebase: 3 items
✅ Lectures updated from Firebase: 5 items
📱 Offline mode: Using cached categories only
📱 Offline mode: Using cached lectures only
✅ Lectures cached: 5 items
✅ Categories cached: 3 items
✅ Found cached lectures: 5 items
✅ Found cached categories: 3 items
Using cached session (offline mode - error handler)
No Firebase auth, using cached session
❌ No cached session found
⏰ Session expired
Error fetching user data: [error details]
Error fetching categories: [error details]
Run this complete test:
1. Clear all site data
2. Login while ONLINE
→ Console: "✅ Session saved for offline access"
3. View 2 lectures
→ Wait 3 seconds
4. Check localStorage
→ Application tab → Local Storage → lms_auth_session exists
5. Check IndexedDB
→ Application tab → IndexedDB → LectureCache → 2 lectures
6. Go OFFLINE
→ Network tab → Check "Offline"
7. Refresh (F5)
→ Console: "✅ Found valid cached session"
→ Console: "Found cached session on mount"
→ Still logged in! ✅
8. Click a cached lecture
→ Opens from cache (instant) ✅
9. Go back ONLINE
→ Uncheck "Offline"
10. Refresh (F5)
→ Everything works normally ✅
| Action | Expected Console Log | Expected Behavior |
|---|---|---|
| Login online | ✅ Session saved |
Normal login |
| Refresh online | ✅ Found valid cached session |
Stays logged in |
| Go offline | No error | Works normally |
| Refresh offline | ✅ Found valid cached sessionFound cached session on mount |
Stays logged in |
| Click cached lecture offline | Background caching failed (expected) |
PDF opens from cache |
| Go back online | No error | Syncs changes |
- Always check Console - it tells you exactly what's happening
- Keep DevTools open - easier to debug
- Test in regular window - NOT incognito (localStorage doesn't persist)
- Wait 2-3 seconds after login before going offline
- Clear cache between tests for clean testing
You know it's working when:
- ✅ Console shows:
📦 Loading cached categories for immediate display - ✅ Console shows:
📦 Loading cached lectures for immediate display - ✅ Console shows:
✅ Session saved for offline access - ✅ Console shows:
Found cached session on mount - ✅ You can refresh while offline and stay logged in
- ✅ Dropdowns show subjects/stages immediately
- ✅ Lectures list shows immediately
- ✅ Cached lectures open instantly offline
- ✅ Favorites/completed persist offline
If all these work → Offline mode is working perfectly! 🎉