Theme Toggle Testing Guide
Quick Test Checklist
Use this checklist to verify the theme toggle is working correctly after deployment.
Basic Functionality
- Click theme toggle button - theme switches immediately
- Icons animate smoothly (sun ↔️ moon)
- Theme persists after page refresh
- No flash of wrong theme on page load
Cross-Page Testing
- Navigate from homepage to blog post - theme maintained
- Navigate from blog post to about page - theme maintained
- Use browser back button - theme maintained
- Use browser forward button - theme maintained
Mobile Testing
- Open mobile menu (burger icon)
- Theme toggle is visible in mobile menu
- Click theme toggle in mobile menu - works correctly
- Mobile menu closes smoothly after theme change
Keyboard Navigation
- Tab to theme toggle button (should show focus ring)
- Press Enter - theme switches
- Press Space - theme switches
- ARIA label reads correctly for screen readers
Edge Cases
- Rapid clicking (10+ times fast) - no glitches
- Switch themes during page transition - no conflicts
- Open in new tab - theme from original tab applied
- Private/Incognito mode - theme toggle works (doesn’t persist)
Different Page Types
- Homepage (blog layout) - works
- Individual post pages - works
- Static pages (about, professional) - works
- Category/tag pages - works
Browser Testing
- Chrome/Edge (Windows)
- Firefox (Windows)
- Safari (macOS)
- Safari (iOS)
- Chrome (Android)
Manual Testing Procedure
Test 1: Basic Toggle Function
- Open homepage in browser
- Observe current theme (should be dark by default for new visitors)
- Click theme toggle button in navbar
- Verify:
- Background color changes immediately
- Text color inverts
- Theme toggle icon changes (sun ↔️ moon)
- Icon animates smoothly with rotation
- No JavaScript errors in console
Test 2: Theme Persistence
- Set theme to light mode
- Navigate to a blog post
- Verify theme is still light
- Refresh page (Ctrl+R / Cmd+R)
- Verify theme is still light
- Close browser tab
- Reopen same URL
- Verify theme is still light
Test 3: Mobile Menu
- Resize browser to mobile width (<768px) or use device
- Click burger menu icon
- Verify mobile menu opens with smooth animation
- Verify theme toggle button is visible
- Click theme toggle
- Verify theme changes
- Click outside menu to close
- Verify theme change persisted
Test 4: Page Navigation
- Start on homepage
- Set theme to dark
- Click on a blog post
- Verify theme is dark
- Click back button
- Verify theme is still dark
- Click forward button
- Verify theme is still dark
Test 5: Keyboard Navigation
- Load any page
- Press Tab repeatedly until theme toggle has focus
- Verify focus indicator is visible
- Press Enter
- Verify theme switches
- Press Tab then Shift+Tab to return focus
- Press Space
- Verify theme switches again
Automated Testing (Browser DevTools)
Console Commands
// Check current theme
document.documentElement.getAttribute('data-theme')
// Check localStorage
localStorage.getItem('theme')
// Manually toggle theme
document.getElementById('theme-toggle').click()
// Verify button exists
document.getElementById('theme-toggle') !== null
// Check button ARIA label
document.getElementById('theme-toggle').getAttribute('aria-label')
// Check icon visibility
getComputedStyle(document.querySelector('.theme-icon-light')).opacity
getComputedStyle(document.querySelector('.theme-icon-dark')).opacity
Performance Testing
// Measure theme toggle performance
console.time('theme-toggle');
document.getElementById('theme-toggle').click();
console.timeEnd('theme-toggle');
// Should be < 50ms
Common Issues and Solutions
Issue: Theme doesn’t persist
Solution: Check if localStorage is enabled (not in private browsing)
try {
localStorage.setItem('test', 'test');
localStorage.removeItem('test');
console.log('localStorage works');
} catch(e) {
console.error('localStorage not available:', e);
}
Issue: Icons don’t show correctly
Solution: Verify Font Awesome is loaded
// Check if Font Awesome icons are loaded
document.querySelector('.fa-sun') !== null
document.querySelector('.fa-moon') !== null
Issue: Button doesn’t respond to clicks
Solution: Check for JavaScript errors
- Open DevTools Console (F12)
- Look for red error messages
- Check if
handleThemeToggle
function exists// Should show function definition console.log(typeof handleThemeToggle)
Issue: Theme flashes on page load
Solution: Verify head.html script runs before CSS
- View page source (Ctrl+U / Cmd+Option+U)
- Confirm theme initialization script is first in
<head>
- Should be before any CSS files
Regression Testing
After any changes to navbar, JavaScript, or CSS, re-run this checklist:
- All Basic Functionality tests pass
- All Cross-Page tests pass
- Mobile menu still shows toggle
- Keyboard navigation works
- No new console errors
- Performance is still fast (<50ms toggle time)
Accessibility Testing
Use these tools to verify accessibility:
- axe DevTools - Chrome/Firefox extension
- WAVE - Web accessibility evaluation tool
- Lighthouse - Chrome DevTools Accessibility audit
- Screen Reader - NVDA (Windows), JAWS, VoiceOver (macOS/iOS)
Screen Reader Test
- Enable screen reader
- Navigate to theme toggle with Tab
- Verify announcement: “Toggle dark/light theme, button”
- Activate button
- Verify new announcement reflects new theme state
Performance Benchmarks
Expected performance metrics:
- Theme toggle time: <50ms
- Icon animation: 300ms (CSS)
- Page transition with theme: <200ms
- Memory usage: No leaks after 100+ toggles
Sign-Off
After completing all tests:
✓ All basic functionality tests passed
✓ Cross-page navigation maintains theme
✓ Mobile menu works correctly
✓ Keyboard navigation works
✓ No JavaScript errors in console
✓ Performance is acceptable
✓ Accessibility requirements met
Tested by: _________________
Date: _________________
Browser(s): _________________
Last Updated: 2025-10-10 Related Files: THEME_TOGGLE_FIXES.md