import { tap } from '@push.rocks/tapbundle'; import * as plugins from '../ts/plugins.js'; import * as paths from '../ts/paths.js'; import { SenderReputationMonitor } from '../ts/deliverability/classes.senderreputationmonitor.js'; import { IPWarmupManager } from '../ts/deliverability/classes.ipwarmupmanager.js'; /** * Basic test to check if our integrated classes work correctly */ tap.test('verify that SenderReputationMonitor and IPWarmupManager are functioning', async (tools) => { // Create instances of both classes const reputationMonitor = SenderReputationMonitor.getInstance({ enabled: true, domains: ['example.com'] }); const ipWarmupManager = IPWarmupManager.getInstance({ enabled: true, ipAddresses: ['192.168.1.1', '192.168.1.2'], targetDomains: ['example.com'] }); // Test SenderReputationMonitor reputationMonitor.recordSendEvent('example.com', { type: 'sent', count: 100 }); reputationMonitor.recordSendEvent('example.com', { type: 'delivered', count: 95 }); const reputationData = reputationMonitor.getReputationData('example.com'); const summary = reputationMonitor.getReputationSummary(); // Basic checks tools.ok(reputationData, 'Got reputation data'); tools.ok(summary.length > 0, 'Got reputation summary'); // Add and remove domains reputationMonitor.addDomain('test.com'); reputationMonitor.removeDomain('test.com'); // Test IPWarmupManager ipWarmupManager.setActiveAllocationPolicy('balanced'); const bestIP = ipWarmupManager.getBestIPForSending({ from: 'test@example.com', to: ['recipient@test.com'], domain: 'example.com' }); if (bestIP) { ipWarmupManager.recordSend(bestIP); const canSendMore = ipWarmupManager.canSendMoreToday(bestIP); tools.ok(canSendMore !== undefined, 'Can check if sending more is allowed'); } const stageCount = ipWarmupManager.getStageCount(); tools.ok(stageCount > 0, 'Got stage count'); }); // Final clean-up test tap.test('clean up after tests', async () => { // No-op - just to make sure everything is cleaned up properly }); export default tap.start();