|
@ -1,5 +1,107 @@ |
|
|
import { Capacitor } from '@capacitor/core'; |
|
|
import { Capacitor } from '@capacitor/core'; |
|
|
import { ConfigLoader, MockDailyNotificationService, TestLogger } from '../shared/config-loader'; |
|
|
|
|
|
|
|
|
// Mock classes for testing when shared utilities aren't available
|
|
|
|
|
|
class ConfigLoader { |
|
|
|
|
|
private static instance: ConfigLoader; |
|
|
|
|
|
private config: any; |
|
|
|
|
|
|
|
|
|
|
|
static getInstance(): ConfigLoader { |
|
|
|
|
|
if (!this.instance) { |
|
|
|
|
|
this.instance = new ConfigLoader(); |
|
|
|
|
|
} |
|
|
|
|
|
return this.instance; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async loadConfig(): Promise<void> { |
|
|
|
|
|
this.config = { |
|
|
|
|
|
timesafari: { |
|
|
|
|
|
appId: 'timesafari-android-test', |
|
|
|
|
|
appName: 'TimeSafari Android Test', |
|
|
|
|
|
version: '1.0.0' |
|
|
|
|
|
}, |
|
|
|
|
|
scheduling: { |
|
|
|
|
|
contentFetch: { schedule: '0 8 * * *' }, |
|
|
|
|
|
userNotification: { schedule: '0 9 * * *' } |
|
|
|
|
|
}, |
|
|
|
|
|
endorser: { |
|
|
|
|
|
baseUrl: 'http://10.0.2.2:3001/api/v2/report', |
|
|
|
|
|
apiKey: 'test-api-key' |
|
|
|
|
|
}, |
|
|
|
|
|
testData: { |
|
|
|
|
|
userDid: 'user:test', |
|
|
|
|
|
lastKnownOfferId: '0', |
|
|
|
|
|
lastKnownPlanId: '0', |
|
|
|
|
|
starredPlanIds: ['plan:test'] |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getConfig(): any { |
|
|
|
|
|
return this.config; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getEndorserUrl(endpoint: string): string { |
|
|
|
|
|
const endpoints: { [key: string]: string } = { |
|
|
|
|
|
notificationsBundle: '/notifications/bundle', |
|
|
|
|
|
offers: '/offersToPerson', |
|
|
|
|
|
offersToPlans: '/offersToPlansOwnedByMe', |
|
|
|
|
|
plansLastUpdated: '/plansLastUpdatedBetween' |
|
|
|
|
|
}; |
|
|
|
|
|
return `${this.config.endorser.baseUrl}${endpoints[endpoint] || endpoint}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getAuthHeaders(): any { |
|
|
|
|
|
return { |
|
|
|
|
|
'Authorization': `Bearer ${this.config.endorser.apiKey}`, |
|
|
|
|
|
'Content-Type': 'application/json' |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class MockDailyNotificationService { |
|
|
|
|
|
constructor(config: any) { |
|
|
|
|
|
this.config = config; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private config: any; |
|
|
|
|
|
|
|
|
|
|
|
async initialize(): Promise<void> { |
|
|
|
|
|
console.log('Mock notification service initialized'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async scheduleDualNotification(config: any): Promise<void> { |
|
|
|
|
|
console.log('Mock dual notification scheduled:', config); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async registerCallback(name: string, callback: Function): Promise<void> { |
|
|
|
|
|
console.log(`Mock callback registered: ${name}`); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async getDualScheduleStatus(): Promise<any> { |
|
|
|
|
|
return { |
|
|
|
|
|
contentFetch: { enabled: true }, |
|
|
|
|
|
userNotification: { enabled: true } |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TestLogger { |
|
|
|
|
|
constructor(level: string) { |
|
|
|
|
|
console.log('Mock logger initialized with level:', level); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
info(message: string, data?: any) { |
|
|
|
|
|
console.log(`[INFO] ${message}`, data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
error(message: string, data?: any) { |
|
|
|
|
|
console.error(`[ERROR] ${message}`, data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
debug(message: string, data?: any) { |
|
|
|
|
|
console.log(`[DEBUG] ${message}`, data); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Enhanced UI components for comprehensive testing
|
|
|
// Enhanced UI components for comprehensive testing
|
|
|
class PermissionManager { |
|
|
class PermissionManager { |
|
|