# Test Apps Setup Guide ## Overview This guide creates minimal Capacitor test apps for validating the Daily Notification Plugin across all target platforms. ## Directory Structure ``` test-apps/ ├── android-test/ # Android test app ├── ios-test/ # iOS test app ├── electron-test/ # Electron test app ├── test-api/ # Test API server ├── setup-android.sh # Android setup script ├── setup-ios.sh # iOS setup script ├── setup-electron.sh # Electron setup script ├── check-environment.sh # Environment verification ├── SETUP_GUIDE.md # Enhanced setup guide └── README.md # This guide ``` ## Prerequisites - Node.js 18+ - Capacitor CLI: `npm install -g @capacitor/cli` - Android Studio (for Android) - Xcode (for iOS) - Platform-specific SDKs ## Quick Start ### Option 1: Automated Setup (Recommended) ```bash # Navigate to test-apps directory first cd test-apps # Setup all platforms (run from test-apps directory) ./setup-android.sh ./setup-ios.sh ./setup-electron.sh ``` **⚠️ Important**: Run setup scripts from the `test-apps` directory, not from individual platform directories. ### Option 2: Manual Setup See [Enhanced Setup Guide](SETUP_GUIDE.md) for detailed manual setup instructions and troubleshooting. ### Prerequisites Check ```bash # Check your environment before setup ./check-environment.sh ``` **Required Software**: - **Node.js 18+**: Required for all platforms - **Android Studio**: Required for Android testing - **Xcode**: Required for iOS testing (macOS only) - **No additional requirements**: For Electron testing ## Test App Features Each test app includes: - **Plugin Configuration**: Test shared SQLite, TTL, prefetch settings - **Notification Scheduling**: Basic daily notification setup - **Platform-Specific Features**: - Android: Exact alarm permissions, reboot recovery - iOS: Rolling window management, BGTaskScheduler - Electron: Mock implementations, IPC communication - **Performance Monitoring**: Metrics collection and display - **Error Handling**: Comprehensive error testing - **Debug Information**: Platform-specific debug data ## Test API Server A mock REST API server (`test-api/`) provides endpoints for testing the plugin's network functionality: ### Quick Start ```bash # Start the test API server cd test-apps/test-api npm install npm start # Test the API npm run demo ``` ### Key Features - **Content Endpoints**: Generate mock notification content - **ETag Support**: Full HTTP caching with conditional requests - **Error Simulation**: Test various error scenarios - **Metrics**: Monitor API usage and performance - **CORS Enabled**: Cross-origin requests supported ### API Endpoints - `GET /health` - Health check - `GET /api/content/:slotId` - Get notification content - `GET /api/error/:type` - Simulate errors - `GET /api/metrics` - API metrics - `PUT /api/content/:slotId` - Update content - `DELETE /api/content` - Clear all content ### Platform-Specific URLs - **Web/Electron**: `http://localhost:3001` - **Android Emulator**: `http://10.0.2.2:3001` - **iOS Simulator**: `http://localhost:3001` - **Physical Devices**: `http://[YOUR_IP]:3001` ## Platform-Specific Testing ### Android Test App - **Exact Alarm Status**: Check permission and capability - **Permission Requests**: Test exact alarm permission flow - **Performance Metrics**: Monitor Android-specific optimizations - **Reboot Recovery**: Validate system restart handling ### iOS Test App - **Rolling Window**: Test notification limit management - **Background Tasks**: Validate BGTaskScheduler integration - **Performance Metrics**: Monitor iOS-specific optimizations - **Memory Management**: Test object pooling and cleanup ### Electron Test App - **Mock Implementations**: Test web platform compatibility - **IPC Communication**: Validate Electron-specific APIs - **Development Workflow**: Test plugin integration - **Debug Information**: Platform-specific status display ## Running the Test Apps ### Android ```bash cd android-test npm run dev # Web development server npx cap open android # Open in Android Studio npx cap run android # Run on device/emulator ``` ### iOS ```bash cd ios-test npm run dev # Web development server npx cap open ios # Open in Xcode npx cap run ios # Run on device/simulator ``` ### Electron ```bash cd electron-test npm start # Run Electron app npm run dev # Run in development mode ``` ## Testing Checklist ### Core Functionality - [ ] Plugin configuration works - [ ] Notification scheduling succeeds - [ ] Error handling functions properly - [ ] Performance metrics are accurate ### Platform-Specific - [ ] Android exact alarm permissions - [ ] iOS rolling window management - [ ] Electron mock implementations - [ ] Cross-platform API consistency ### Integration - [ ] Plugin loads without errors - [ ] Configuration persists across sessions - [ ] Performance optimizations active - [ ] Debug information accessible ## Troubleshooting ### Common Issues 1. **"Unknown command: cap"** → Install Capacitor CLI: `npm install -g @capacitor/cli` 2. **"android platform has not been added yet"** → Run `npx cap add android` first 3. **Build failures** → Check Node.js version (18+) and clear cache: `npm cache clean --force` 4. **Platform errors** → Verify platform-specific SDKs are installed ### Quick Fixes ```bash # Check environment ./check-environment.sh # Reinstall dependencies rm -rf node_modules && npm install # Clear Capacitor cache npx cap clean # Re-sync platforms npx cap sync ``` ### Detailed Help See [Enhanced Setup Guide](SETUP_GUIDE.md) for comprehensive troubleshooting and platform-specific solutions. ## Next Steps 1. **Run Setup Scripts**: Execute platform-specific setup 2. **Test Core Features**: Validate basic functionality 3. **Test Platform Features**: Verify platform-specific capabilities 4. **Integration Testing**: Test with actual plugin implementation 5. **Performance Validation**: Monitor metrics and optimizations