Skip to content

Commit

Permalink
Added CC property to message option models
Browse files Browse the repository at this point in the history
Including Create, Forward and Reply
  • Loading branch information
ey-mailosaur authored and jm-mailosaur committed Jan 2, 2025
1 parent 6bd6f15 commit 13988d5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/mailosaurCommands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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.
*/
Expand Down
52 changes: 51 additions & 1 deletion test/react-app/cypress/e2e/messages.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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>';
Expand Down

0 comments on commit 13988d5

Please sign in to comment.