Files
daily-notification-plugin/docs/testing/QUICK_REFERENCE_V2.md
Matthew Raymer eb1fc9f220 feat(docs): complete P2.6 type safety cleanup and P2.7 system invariants
P2.6: Type Safety Cleanup
- Replaced 'any' return types in vite-plugin.ts with concrete types (UserConfig, transform return type)
- Documented TypeScript mixin 'any[]' exception in PlatformServiceMixin.ts
- Audit confirmed: zero 'any' in codebase except documented TS mixin limitation
- All external boundaries use 'unknown', all data payloads use 'Record<string, unknown>'

P2.7: System Invariants Documentation
- Created SYSTEM_INVARIANTS.md documenting all 6 enforced invariants
- Added to docs/00-INDEX.md under Policy & Contracts section
- Each invariant includes: What, Why, How, Where

Progress Docs Updates:
- Updated 00-STATUS.md: marked P2.6/P2.7 complete, added type safety invariant note
- Updated 01-CHANGELOG-WORK.md: added 2025-12-22 entries for P2.6/P2.7
- Updated 03-TEST-RUNS.md: added P2.6 type safety audit test run
- Updated P2-DESIGN.md: marked P2.6 acceptance criteria complete
- Updated SYSTEM_INVARIANTS.md: added Type Safety Notes section

Baseline Tag:
- Created v1.0.11-p0-p1.4-p1.5-p2.6-p2.7-complete

TypeScript compilation:  PASSES
Build:  PASSES
CI:  All checks pass
2025-12-22 10:56:00 +00:00

7.6 KiB

Testing Quick Reference - P0 Production-Grade Features

Note: For general testing commands, see QUICK_REFERENCE.md

Current Version Features

P0 Priority 1: Channel Management (ChannelManager)
P0 Priority 2: PendingIntent & Exact Alarms (PendingIntentManager)
P0 Priority 3: JIT Freshness Re-check (Soft TTL)
P0 Priority 4: Recovery Coexistence (RecoveryManager)

Quick Test Commands

1. Basic Functionality Test

# Launch app
adb shell am start -n com.timesafari.dailynotification/.MainActivity

# Check channel status
adb shell "dumpsys notification | grep -A5 daily_default"

# Check alarms
adb shell "dumpsys alarm | grep timesafari"

# Check exact alarm permission
adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM"

2. Channel Management Test

# Check channel exists and is enabled
adb shell "dumpsys notification | grep daily_default"

# Check channel importance (should be 3 = IMPORTANCE_HIGH)
adb shell "dumpsys notification | grep -A5 daily_default | grep importance"

# Open channel settings
adb shell "am start -a android.settings.CHANNEL_NOTIFICATION_SETTINGS -e android.provider.extra.APP_PACKAGE com.timesafari.dailynotification -e android.provider.extra.CHANNEL_ID daily_default"

3. PendingIntent & Exact Alarms Test

# Check PendingIntent flags in alarms
adb shell "dumpsys alarm | grep -A10 -B5 timesafari"

# Check exact alarm permission
adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM"

# Open exact alarm settings
adb shell "am start -a android.settings.REQUEST_SCHEDULE_EXACT_ALARM -d package:com.timesafari.dailynotification"

4. JIT Freshness Re-check Test

# Clear logs
adb logcat -c

# Schedule notification in app UI, then monitor logs
adb logcat | grep -i "jit\|freshness\|stale"

# Look for:
# - "Content is fresh (age: X minutes), skipping JIT refresh"
# - "Content is stale (age: X minutes), attempting JIT refresh"
# - "JIT refresh succeeded" or "JIT refresh failed, using original content"

5. Recovery Coexistence Test

# Clear logs
adb logcat -c

# Launch app multiple times to test cooldown
adb shell am start -n com.timesafari.dailynotification/.MainActivity
sleep 2
adb shell am start -n com.timesafari.dailynotification/.MainActivity
sleep 2
adb shell am start -n com.timesafari.dailynotification/.MainActivity

# Check recovery logs
adb logcat -d | grep -i "recovery.*requested.*app_startup"
adb logcat -d | grep -i "recovery.*performed.*recently.*skipping"

6. Reboot Recovery Test

# Schedule notification in app UI first
# Then reboot
adb reboot

# Wait for boot
adb wait-for-device
sleep 30

# Check recovery logs
adb logcat -d | grep -i "recovery.*requested.*boot_completed"

# Check alarms restored
adb shell "dumpsys alarm | grep timesafari"

Automated Test Scripts

Comprehensive Test Suite

# Run comprehensive test suite
./scripts/comprehensive-test-v2.sh

Reboot Test Suite

# Run reboot test suite
./scripts/reboot-test-v2.sh

Python Test Suite

# Run Python test suite
python3 scripts/daily-notification-test.py

Expected Log Patterns

Channel Management

ChannelManager: Creating new notification channel: daily_default
ChannelManager: Notification channel created with IMPORTANCE_HIGH

PendingIntent & Exact Alarms

PendingIntentManager: Scheduled exact alarm with setExactAndAllowWhileIdle
PendingIntentManager: AlarmStatus{exactAlarmsSupported=true, exactAlarmsGranted=true}

JIT Freshness Re-check

DailyNotificationReceiver: Content is fresh (age: 5 minutes), skipping JIT refresh
DailyNotificationReceiver: Content is stale (age: 7 hours), attempting JIT refresh
DailyNotificationReceiver: JIT refresh succeeded, using fresh content

Recovery Coexistence

RecoveryManager: Recovery requested from: APP_STARTUP
RecoveryManager: Recovery performed recently (2s ago), skipping
RecoveryManager: Recovery requested from: BOOT_COMPLETED
RecoveryManager: Recovery completed from BOOT_COMPLETED: 3/5 recovered, 2 skipped

Success Criteria

All Tests Pass When:

  1. Channel Management:

    • Channel exists with ID daily_default
    • Channel importance is IMPORTANCE_HIGH (3)
    • Channel blocking detection works
    • Settings deep linking works
  2. PendingIntent & Exact Alarms:

    • PendingIntent uses FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE
    • Exact alarm permission detection works
    • Settings deep linking works
    • Alarms schedule correctly
  3. JIT Freshness Re-check:

    • Fresh content (< 6 hours) skips refresh
    • Stale content (> 6 hours) attempts refresh
    • Graceful fallback on refresh failure
    • Original content preserved on failure
  4. Recovery Coexistence:

    • App startup recovery works
    • Boot recovery works
    • 5-minute cooldown prevents duplicate recovery
    • Recovery statistics tracked correctly
    • State persisted in SharedPreferences

Tests Fail When:

  • Channel not created or blocked
  • PendingIntent flags incorrect
  • JIT refresh not working
  • Recovery operations conflict
  • Boot recovery not triggered
  • Alarms not restored after reboot

Troubleshooting Commands

Debug Channel Issues

# Check channel status
adb shell "dumpsys notification | grep -A10 daily_default"

# Check channel importance
adb shell "dumpsys notification | grep -A5 daily_default | grep importance"

Debug Alarm Issues

# Check scheduled alarms
adb shell "dumpsys alarm | grep timesafari"

# Check exact alarm permission
adb shell "dumpsys alarm | grep SCHEDULE_EXACT_ALARM"

# Check alarm manager state
adb shell "dumpsys alarm | head -20"

Debug Recovery Issues

# Check recovery logs
adb logcat -d | grep -i "recovery.*requested"

# Check recovery state
adb shell "run-as com.timesafari.dailynotification ls -la /data/data/com.timesafari.dailynotification/shared_prefs/"

# Check boot receiver registration
adb shell "dumpsys package com.timesafari.dailynotification | grep -A5 -B5 receiver"

Debug JIT Freshness Issues

# Check JIT refresh logs
adb logcat -d | grep -i "jit\|freshness\|stale"

# Check content age calculation
adb logcat -d | grep -i "age.*minutes"

Manual Testing Checklist

Pre-Test Setup

  • Device/emulator connected via ADB
  • App installed and permissions granted
  • Notification permissions enabled
  • Exact alarm permissions granted (Android 12+)

Basic Tests

  • App launches successfully
  • Plugin loads without errors
  • Channel created with correct settings
  • Notifications schedule correctly
  • Notifications appear at scheduled time

P0 Feature Tests

  • Channel management works
  • PendingIntent flags correct
  • Exact alarm permission detection
  • JIT freshness re-check works
  • Recovery coexistence works
  • Boot recovery works

Edge Case Tests

  • App background notification
  • App closed notification
  • Force stop (expected failure)
  • Reboot recovery
  • Multiple notifications
  • Network connectivity issues

Performance Tests

  • Memory usage stable
  • CPU usage reasonable
  • No memory leaks
  • Efficient recovery operations

Quick Status Check

# One-liner to check all systems
echo "=== Channel Status ===" && adb shell "dumpsys notification | grep -A3 daily_default" && echo "=== Alarm Status ===" && adb shell "dumpsys alarm | grep timesafari" && echo "=== Recovery Status ===" && adb logcat -d | grep -i "recovery.*requested" | tail -3

This quick reference covers all the essential testing procedures for the current P0 production-grade version of the DailyNotification plugin.