66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import { tap, expect } 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
|
|
expect(reputationData).toBeTruthy();
|
|
expect(summary.length).toBeGreaterThan(0);
|
|
|
|
// 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);
|
|
expect(canSendMore !== undefined).toBeTrue();
|
|
}
|
|
|
|
const stageCount = ipWarmupManager.getStageCount();
|
|
expect(stageCount).toBeGreaterThan(0);
|
|
});
|
|
|
|
// Final clean-up test
|
|
tap.test('clean up after tests', async () => {
|
|
// No-op - just to make sure everything is cleaned up properly
|
|
});
|
|
|
|
tap.test('stop', async () => {
|
|
await tap.stopForcefully();
|
|
});
|
|
|
|
export default tap.start(); |