From d61dbedc1731e832143899cf557c125c40019517 Mon Sep 17 00:00:00 2001 From: ey-mailosaur <ethan.y@mailosaur.com> Date: Thu, 19 Dec 2024 10:54:59 +0000 Subject: [PATCH] Added CC property to message option models Including Create, Forward and Reply --- src/mailosaurCommands.d.ts | 12 ++++++ test/react-app/cypress/e2e/messages.cy.js | 52 ++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/mailosaurCommands.d.ts b/src/mailosaurCommands.d.ts index 7f93148..cadbb86 100644 --- a/src/mailosaurCommands.d.ts +++ b/src/mailosaurCommands.d.ts @@ -335,6 +335,10 @@ export interface MessageCreateOptions { * The email address to which the email will be sent. Must be a verified email address. */ to?: string; + /** + * The email address to which the email will be CC'd. Must be a verified email address. + */ + cc?: string; /** * Allows for the partial override of the message's 'from' address. This **must** be an address ending with `YOUR_SERVER.mailosaur.net`, such as `my-emails@a1bcdef2.mailosaur.net`. */ @@ -369,6 +373,10 @@ export interface MessageForwardOptions { * The email address to which the email will be sent. Must be a verified email address. */ to: string; + /** + * The email address to which the email will be CC'd. Must be a verified email address. + */ + cc?: string; /** * Any plain text to include when forwarding the message. Note that only text or html can be supplied, not both. */ @@ -383,6 +391,10 @@ export interface MessageForwardOptions { * Options to use when replying to a message. */ export interface MessageReplyOptions { + /** + * The email address to which the email will be CC'd. Must be a verified email address. + */ + cc?: string; /** * Any additional plain text content to include in the reply. Note that only text or html can be supplied, not both. */ diff --git a/test/react-app/cypress/e2e/messages.cy.js b/test/react-app/cypress/e2e/messages.cy.js index cc73b67..14a4568 100644 --- a/test/react-app/cypress/e2e/messages.cy.js +++ b/test/react-app/cypress/e2e/messages.cy.js @@ -90,7 +90,7 @@ const validateEmail = (email) => { // validateText(email); expect(email.metadata.ehlo).to.be.null; expect(email.metadata.mailFrom).to.be.null; - expect(email.metadata.rcptTo).to.have.lengthOf(1); + expect(email.to).to.have.lengthOf(1); }; const validateEmailSummary = (email) => { @@ -411,6 +411,24 @@ describe('Mailosaur message commands', () => { }); }); + it('should send with HTML content to a CC recipient', (done) => { + const subject = 'CC Message'; + const ccRecipient = `someoneelse@${verifiedDomain}`; + cy.mailosaurCreateMessage(server, { + to: `anything@${verifiedDomain}`, + cc: ccRecipient, + send: true, + subject, + html: '<p>This is a new email with a CC recipient.</p>', + }).then((message) => { + expect(message.id).to.be.ok; + expect(message.subject).to.equal(subject); + expect(message.cc.length).to.equal(1); + expect(message.cc[0].email).to.equal(ccRecipient); + done(); + }); + }); + it('should send with attachment', (done) => { const subject = 'New message with attachment'; @@ -467,6 +485,23 @@ describe('Mailosaur message commands', () => { done(); }); }); + + it('should forward with HTML content to a CC recipient', (done) => { + const targetEmailId = emails[0].id; + const body = '<p>Forwarded <strong>HTML</strong> message with CC a recipient.</p>'; + const ccRecipient = `someoneelse@${verifiedDomain}`; + cy.mailosaurForwardMessage(targetEmailId, { + to: `forwardcc@${verifiedDomain}`, + html: body, + cc: ccRecipient, + }).then((message) => { + expect(message.id).to.be.ok; + expect(message.html.body).to.contain(body); + expect(message.cc.length).to.equal(1); + expect(message.cc[0].email).to.equal(ccRecipient); + done(); + }); + }); }); // TODO - Tested in Node.js client for now due to way emails are created in Cypress plugin tests @@ -495,6 +530,21 @@ describe('Mailosaur message commands', () => { }); }); + xit('should reply with HTML content with a CC recipient', (done) => { + const targetEmailId = emails[0].id; + const body = '<p>Reply <strong>HTML</strong> message.</p>'; + const ccRecipient = `someoneelse@${verifiedDomain}`; + cy.mailosaurReplyToMessage(targetEmailId, { + html: body, + }).then((message) => { + expect(message.id).to.be.ok; + expect(message.html.body).to.contain(body); + expect(message.cc.length).to.equal(1); + expect(message.cc[0].email).to.equal(ccRecipient); + done(); + }); + }); + xit('should reply with attachment', (done) => { const targetEmailId = emails[0].id; const body = '<p>Reply <strong>HTML</strong> message.</p>';