update
This commit is contained in:
61
test/test.base.ts
Normal file
61
test/test.base.ts
Normal file
@ -0,0 +1,61 @@
|
||||
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 () => {
|
||||
// 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');
|
||||
expect(reputationData).to.not.be.null;
|
||||
|
||||
const summary = reputationMonitor.getReputationSummary();
|
||||
expect(summary.length).to.be.at.least(1);
|
||||
|
||||
// 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(typeof canSendMore).to.equal('boolean');
|
||||
}
|
||||
|
||||
const stageCount = ipWarmupManager.getStageCount();
|
||||
expect(stageCount).to.be.greaterThan(0);
|
||||
});
|
||||
|
||||
// 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();
|
Reference in New Issue
Block a user