Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
137 lines
4.0 KiB
JavaScript
137 lines
4.0 KiB
JavaScript
/**
|
|
* Email Processor - Handles email sending and validation for E2E tests
|
|
*/
|
|
|
|
import nodemailer from 'nodemailer';
|
|
import axios from 'axios';
|
|
|
|
export class EmailProcessor {
|
|
constructor() {
|
|
this.mailhogConfig = {
|
|
smtpPort: 1025,
|
|
webPort: 8025,
|
|
baseUrl: 'http://localhost:8025'
|
|
};
|
|
|
|
this.transporter = nodemailer.createTransport({
|
|
host: 'localhost',
|
|
port: this.mailhogConfig.smtpPort,
|
|
secure: false, // MailHog doesn't use TLS
|
|
auth: false // MailHog doesn't require auth
|
|
});
|
|
|
|
this.lastEmailId = null;
|
|
}
|
|
|
|
async sendTestEmail(emailData) {
|
|
console.log(`📧 Sending test email: ${emailData.subject}`);
|
|
|
|
const mailOptions = {
|
|
from: emailData.from,
|
|
to: emailData.to,
|
|
subject: emailData.subject,
|
|
text: emailData.body,
|
|
html: `<p>${emailData.body}</p>`,
|
|
headers: {
|
|
'Message-ID': `<test-${Date.now()}@e2e-tests.local>`,
|
|
'X-Test-ID': Date.now().toString()
|
|
}
|
|
};
|
|
|
|
try {
|
|
const result = await this.transporter.sendMail(mailOptions);
|
|
console.log(`✅ Email sent successfully: ${result.messageId}`);
|
|
|
|
// Store the test ID for later verification
|
|
this.lastTestId = mailOptions.headers['X-Test-ID'];
|
|
|
|
return result;
|
|
} catch (error) {
|
|
throw new Error(`Failed to send email: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
async verifyEmailCaptured() {
|
|
console.log('🔍 Verifying email was captured by MailHog...');
|
|
|
|
// Wait a moment for email to be processed
|
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
|
|
try {
|
|
const response = await axios.get(`${this.mailhogConfig.baseUrl}/api/v1/messages`);
|
|
const messages = response.data;
|
|
|
|
if (!messages || messages.length === 0) {
|
|
throw new Error('No messages found in MailHog');
|
|
}
|
|
|
|
// Find our test email by test ID
|
|
const testEmail = messages.find(msg =>
|
|
msg.Content &&
|
|
msg.Content.Headers &&
|
|
msg.Content.Headers['X-Test-ID'] &&
|
|
msg.Content.Headers['X-Test-ID'][0] === this.lastTestId
|
|
);
|
|
|
|
if (!testEmail) {
|
|
throw new Error(`Test email with ID ${this.lastTestId} not found in MailHog`);
|
|
}
|
|
|
|
console.log(`✅ Email captured by MailHog: ${testEmail.Content.Headers.Subject[0]}`);
|
|
this.lastEmailId = testEmail.ID;
|
|
|
|
return testEmail;
|
|
} catch (error) {
|
|
throw new Error(`Failed to verify email capture: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
async sendReplyEmail(originalEmail, replyData) {
|
|
console.log(`📧 Sending reply email: ${replyData.subject}`);
|
|
|
|
const originalHeaders = originalEmail.Content.Headers;
|
|
const originalMessageId = originalHeaders['Message-ID'][0];
|
|
|
|
const mailOptions = {
|
|
from: replyData.from,
|
|
to: replyData.to,
|
|
subject: replyData.subject,
|
|
text: replyData.body,
|
|
html: `<p>${replyData.body}</p>`,
|
|
headers: {
|
|
'Message-ID': `<reply-${Date.now()}@e2e-tests.local>`,
|
|
'In-Reply-To': originalMessageId,
|
|
'References': originalMessageId,
|
|
'X-Test-ID': Date.now().toString()
|
|
}
|
|
};
|
|
|
|
try {
|
|
const result = await this.transporter.sendMail(mailOptions);
|
|
console.log(`✅ Reply email sent successfully: ${result.messageId}`);
|
|
|
|
this.lastTestId = mailOptions.headers['X-Test-ID'];
|
|
return result;
|
|
} catch (error) {
|
|
throw new Error(`Failed to send reply email: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
async getMailHogMessages() {
|
|
try {
|
|
const response = await axios.get(`${this.mailhogConfig.baseUrl}/api/v1/messages`);
|
|
return response.data;
|
|
} catch (error) {
|
|
throw new Error(`Failed to get MailHog messages: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
async clearMailHogMessages() {
|
|
try {
|
|
await axios.delete(`${this.mailhogConfig.baseUrl}/api/v1/messages`);
|
|
console.log('🧹 MailHog messages cleared');
|
|
} catch (error) {
|
|
throw new Error(`Failed to clear MailHog messages: ${error.message}`);
|
|
}
|
|
}
|
|
} |