Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CC property to message option models #79

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 `[email protected]`.
*/
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
Loading