diff --git a/packages/polling-contracts/src/telemetry.ts b/packages/polling-contracts/src/telemetry.ts index e25224f..b24b43e 100644 --- a/packages/polling-contracts/src/telemetry.ts +++ b/packages/polling-contracts/src/telemetry.ts @@ -64,7 +64,10 @@ export class TelemetryManager { help, type: 'counter', value: 0, - inc: (): void => { this.metrics.get(name)!.value++; } + inc: (): void => { + const metric = this.metrics.get(name); + if (metric) metric.value++; + } }; } @@ -77,7 +80,8 @@ export class TelemetryManager { buckets, values: new Array(buckets.length + 1).fill(0), observe: (value: number): void => { - const metric = this.metrics.get(name)!; + const metric = this.metrics.get(name); + if (!metric) return; // Find bucket and increment for (let i = 0; i < buckets.length; i++) { if (value <= buckets[i]) { @@ -97,7 +101,10 @@ export class TelemetryManager { help, type: 'gauge', value: 0, - set: (value: number): void => { this.metrics.get(name)!.value = value; } + set: (value: number): void => { + const metric = this.metrics.get(name); + if (metric) metric.value = value; + } }; } diff --git a/test-apps/android-test/src/index.ts b/test-apps/android-test/src/index.ts index 2c3e069..de798db 100644 --- a/test-apps/android-test/src/index.ts +++ b/test-apps/android-test/src/index.ts @@ -433,8 +433,13 @@ class TimeSafariAndroidTestApp { private errorDisplay: ErrorDisplay; constructor() { - this.statusElement = document.getElementById('status')!; - this.logElement = document.getElementById('log')!; + const statusElement = document.getElementById('status'); + const logElement = document.getElementById('log'); + if (!statusElement || !logElement) { + throw new Error('Required DOM elements not found'); + } + this.statusElement = statusElement; + this.logElement = logElement; this.configLoader = ConfigLoader.getInstance(); this.logger = new TestLogger('debug'); this.notificationService = new MockDailyNotificationService(this.configLoader.getConfig()); @@ -445,13 +450,23 @@ class TimeSafariAndroidTestApp { this.timeSafariNotificationManager = new TimeSafariNotificationManager(); // Initialize UI components + const permissionStatusContainer = document.getElementById('permission-status-container'); + const permissionDialogContainer = document.getElementById('permission-dialog-container'); + const settingsContainer = document.getElementById('settings-container'); + const statusContainer = document.getElementById('status-container'); + const errorContainer = document.getElementById('error-container'); + + if (!permissionStatusContainer || !permissionDialogContainer || !settingsContainer || !statusContainer || !errorContainer) { + throw new Error('Required UI containers not found'); + } + this.permissionManager = new PermissionManager( - document.getElementById('permission-status-container')!, - document.getElementById('permission-dialog-container')! + permissionStatusContainer, + permissionDialogContainer ); - this.settingsPanel = new SettingsPanel(document.getElementById('settings-container')!); - this.statusDashboard = new StatusDashboard(document.getElementById('status-container')!); - this.errorDisplay = new ErrorDisplay(document.getElementById('error-container')!); + this.settingsPanel = new SettingsPanel(settingsContainer); + this.statusDashboard = new StatusDashboard(statusContainer); + this.errorDisplay = new ErrorDisplay(errorContainer); this.setupEventListeners(); this.initializeUI(); @@ -929,7 +944,7 @@ class TimeSafariAndroidTestApp { // Implementation would process items data and update local state } - private log(message: string, data?: Record) { + private log(message: string, data?: Record): void { const timestamp = new Date().toLocaleTimeString(); const logEntry = document.createElement('div'); logEntry.innerHTML = `[${timestamp}] ${message}`; @@ -940,12 +955,12 @@ class TimeSafariAndroidTestApp { this.logElement.scrollTop = this.logElement.scrollHeight; } - private clearLog() { + private clearLog(): void { this.logElement.innerHTML = ''; this.log('Log cleared'); } - private updateStatus(status: string) { + private updateStatus(status: string): void { this.statusElement.textContent = status; } diff --git a/test-apps/electron-test/src/index.ts b/test-apps/electron-test/src/index.ts index 2cb4c6b..0f7d219 100644 --- a/test-apps/electron-test/src/index.ts +++ b/test-apps/electron-test/src/index.ts @@ -267,8 +267,13 @@ class TimeSafariElectronTestApp { private errorDisplay: ErrorDisplay; constructor() { - this.statusElement = document.getElementById('status')!; - this.logElement = document.getElementById('log')!; + const statusElement = document.getElementById('status'); + const logElement = document.getElementById('log'); + if (!statusElement || !logElement) { + throw new Error('Required DOM elements not found'); + } + this.statusElement = statusElement; + this.logElement = logElement; this.configLoader = ConfigLoader.getInstance(); this.logger = new TestLogger('debug'); this.notificationService = new MockDailyNotificationService(this.configLoader.getConfig()); diff --git a/test-apps/ios-test/src/index.ts b/test-apps/ios-test/src/index.ts index ef83139..d965edc 100644 --- a/test-apps/ios-test/src/index.ts +++ b/test-apps/ios-test/src/index.ts @@ -278,25 +278,45 @@ class TimeSafariIOSTestApp { private errorDisplay: ErrorDisplay; constructor() { - this.statusElement = document.getElementById('status')!; - this.logElement = document.getElementById('log')!; + const statusElement = document.getElementById('status'); + const logElement = document.getElementById('log'); + if (!statusElement || !logElement) { + throw new Error('Required DOM elements not found'); + } + this.statusElement = statusElement; + this.logElement = logElement; this.configLoader = ConfigLoader.getInstance(); this.logger = new TestLogger('debug'); this.notificationService = new MockDailyNotificationService(this.configLoader.getConfig()); // Phase 4: Initialize TimeSafari components - this.endorserAPIClient = new EndorserAPIClient(this.configLoader.getEndorserAPIConfig()); - this.securityManager = new SecurityManager(this.configLoader.getSecurityConfig()); + const endorserAPIConfig = this.configLoader.getEndorserAPIConfig(); + const securityConfig = this.configLoader.getSecurityConfig(); + if (!endorserAPIConfig || !securityConfig) { + throw new Error('Required configurations not found'); + } + this.endorserAPIClient = new EndorserAPIClient(endorserAPIConfig); + this.securityManager = new SecurityManager(securityConfig); this.timeSafariNotificationManager = new TimeSafariNotificationManager(); // Initialize UI components + const permissionStatusContainer = document.getElementById('permission-status-container'); + const permissionDialogContainer = document.getElementById('permission-dialog-container'); + const settingsContainer = document.getElementById('settings-container'); + const statusContainer = document.getElementById('status-container'); + const errorContainer = document.getElementById('error-container'); + + if (!permissionStatusContainer || !permissionDialogContainer || !settingsContainer || !statusContainer || !errorContainer) { + throw new Error('Required UI containers not found'); + } + this.permissionManager = new PermissionManager( - document.getElementById('permission-status-container')!, - document.getElementById('permission-dialog-container')! + permissionStatusContainer, + permissionDialogContainer ); - this.settingsPanel = new SettingsPanel(document.getElementById('settings-container')!); - this.statusDashboard = new StatusDashboard(document.getElementById('status-container')!); - this.errorDisplay = new ErrorDisplay(document.getElementById('error-container')!); + this.settingsPanel = new SettingsPanel(settingsContainer); + this.statusDashboard = new StatusDashboard(statusContainer); + this.errorDisplay = new ErrorDisplay(errorContainer); this.setupEventListeners(); this.initializeUI(); @@ -654,7 +674,7 @@ class TimeSafariIOSTestApp { } } - private async testPerformance() { + private async testPerformance(): Promise { try { this.log('Testing iOS performance metrics...'); const metrics = {