Files
daily-notification-plugin/test-apps/daily-notification-test/capacitor.config.ts
Matthew Raymer 1bf39fd1f7 feat(test): add localhost testing support for prefetch
- Add serverMode configuration to test-user-zero config
  - Supports: localhost, staging, production, mock, custom
  - Auto-detects platform (Android/iOS/Web) for localhost URLs
  - Android emulator uses 10.0.2.2 for host machine localhost

- Add getApiServerUrl() helper function
  - Returns correct URL based on serverMode and platform
  - Handles Android emulator special case (10.0.2.2)

- Update TestUserZeroAPI to respect serverMode
  - Checks mock mode before making network calls
  - Uses getApiServerUrl() for base URL resolution
  - Allows runtime URL switching via setBaseUrl()

- Add localhost testing configuration
  - Configurable port and HTTPS settings
  - Development mode headers support

- Create localhost testing guide
  - Step-by-step setup instructions
  - Platform-specific localhost addresses explained
  - Quick test API server example
  - Troubleshooting common issues
  - Monitoring prefetch execution commands

- Update Capacitor config to use getApiServerUrl()
  - Fixes breaking change from api.server removal

This enables testing prefetch functionality with a local development
API server running on localhost, perfect for development and debugging
of the 5-minute prefetch scheduling feature.
2025-10-29 12:01:05 +00:00

57 lines
1.9 KiB
TypeScript

import type { CapacitorConfig } from '@capacitor/cli';
import { TEST_USER_ZERO_CONFIG } from './src/config/test-user-zero';
const config: CapacitorConfig = {
appId: 'com.timesafari.dailynotification.test',
appName: 'Daily Notification Test',
webDir: 'dist',
plugins: {
Clipboard: {
// Enable clipboard functionality
},
DailyNotification: {
// Basic plugin configuration
debugMode: true,
enableNotifications: true,
// TimeSafari integration for User Zero
timesafariConfig: {
activeDid: TEST_USER_ZERO_CONFIG.identity.did,
endpoints: {
// Use getApiServerUrl() to get correct URL based on serverMode
projectsLastUpdated: `${TEST_USER_ZERO_CONFIG.getApiServerUrl()}${TEST_USER_ZERO_CONFIG.api.starsEndpoint}`
},
starredProjectsConfig: {
enabled: true,
starredPlanHandleIds: TEST_USER_ZERO_CONFIG.starredProjects.planIds,
fetchInterval: '0 8 * * *' // Daily at 8 AM
},
credentialConfig: {
jwtSecret: 'test-jwt-secret-for-user-zero-development-only',
tokenExpirationMinutes: TEST_USER_ZERO_CONFIG.api.jwtExpirationMinutes
}
},
// Network configuration
networkConfig: {
timeout: TEST_USER_ZERO_CONFIG.testing.timeoutMs,
retryAttempts: TEST_USER_ZERO_CONFIG.testing.retryAttempts,
retryDelay: TEST_USER_ZERO_CONFIG.testing.retryDelayMs
},
// Content fetch configuration (5 minutes before notification)
contentFetch: {
enabled: true,
schedule: `0 ${TEST_USER_ZERO_CONFIG.notifications.scheduleTime.split(':')[1]} * * *`,
fetchLeadTimeMinutes: TEST_USER_ZERO_CONFIG.notifications.fetchLeadTimeMinutes,
callbacks: {
onSuccess: 'handleStarsQuerySuccess',
onError: 'handleStarsQueryError'
}
}
}
}
};
export default config;