-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-email-system.js
More file actions
99 lines (88 loc) · 3.84 KB
/
test-email-system.js
File metadata and controls
99 lines (88 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env node
/**
* Quick test script to verify the email system functionality
* This tests the email service without requiring full app startup
*/
const http = require('http');
async function testEmailSystem() {
console.log('🧪 Testing NextSaaS Email System...\n');
// Test 1: Check if email service can be imported
try {
console.log('1. Testing email service import...');
const emailPackage = require('./packages/email/dist/index.js');
console.log('✅ Email package imported successfully');
console.log('📦 Available exports:', Object.keys(emailPackage));
} catch (error) {
console.log('❌ Email package import failed:', error.message);
return;
}
// Test 2: Test provider factory
try {
console.log('\n2. Testing provider factory...');
const { EmailProviderFactory } = require('./packages/email/dist/providers.js');
console.log('✅ Provider factory imported successfully');
console.log('📋 EmailProviderFactory available');
} catch (error) {
console.log('❌ Provider factory test failed:', error.message);
}
// Test 3: Test template system
try {
console.log('\n3. Testing template system...');
const templates = require('./packages/email/dist/templates.js');
console.log('✅ Template system imported successfully');
console.log('📧 Available templates:', Object.keys(templates));
} catch (error) {
console.log('❌ Template system test failed:', error.message);
}
// Test 4: Test API endpoint (if server is running)
try {
console.log('\n4. Testing email API endpoint...');
const response = await new Promise((resolve, reject) => {
const req = http.get('http://localhost:3010/api/email/test', (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve({ status: res.statusCode, data }));
});
req.on('error', reject);
req.setTimeout(5000, () => {
req.destroy();
reject(new Error('Timeout'));
});
});
if (response.status === 200) {
console.log('✅ Email API endpoint responded:', response.data);
} else {
console.log('⚠️ Email API endpoint returned status:', response.status);
}
} catch (error) {
console.log('⚠️ Email API endpoint test skipped (server may not be ready):', error.message);
}
// Test 5: Test new webhook and testing features
try {
console.log('\n5. Testing webhook and testing features...');
const { WebhookManager, EmailTester } = require('./packages/email/dist/index.js');
console.log('✅ Webhook and testing features imported successfully');
console.log('📧 WebhookManager and EmailTester available');
} catch (error) {
console.log('❌ Webhook/testing features test failed:', error.message);
}
console.log('\n🎉 Complete Email system test finished!');
console.log('\n📋 Available Features:');
console.log('✅ Dual-provider email system (Resend + SendGrid)');
console.log('✅ React Email templates (Transactional, Marketing, Industry-specific)');
console.log('✅ Campaign management with A/B testing');
console.log('✅ Real-time analytics and tracking');
console.log('✅ GDPR & CAN-SPAM compliance management');
console.log('✅ Webhook handling for all providers');
console.log('✅ Email testing and preview tools');
console.log('✅ Admin UI components');
console.log('\n📋 Next Steps:');
console.log('1. Configure your email provider API keys in environment variables');
console.log('2. Test sending actual emails through the API endpoints');
console.log('3. Verify database migrations are applied');
console.log('4. Test the email management UI in the dashboard');
console.log('5. Set up webhook endpoints for provider events');
console.log('6. Test email campaigns with real audiences');
}
// Run the test
testEmailSystem().catch(console.error);