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

Add Mailosaur to tests #16

Open
5 tasks
peterjaap opened this issue Jan 18, 2022 · 6 comments · May be fixed by #36
Open
5 tasks

Add Mailosaur to tests #16

peterjaap opened this issue Jan 18, 2022 · 6 comments · May be fixed by #36
Assignees
Labels
enhancement New feature or request

Comments

@peterjaap
Copy link
Contributor

peterjaap commented Jan 18, 2022

For some tests like reset password nieuws, newsletter subscription, order confirmation etc mails need te be received and read. For this purpose Mailosaur can be used. A mailosaur API-key and account will be needed, the API-key needs to be added to the cypress.json "env" object or to a cypress.env.json file. And the serverId needs to be added to the tests where mailosaur is used.

// cypress.json
"env": {
    "MAILOSAUR_API_KEY": "some-hash"
}
// sometest.spec.js
const serverId = 'SERVER_ID';
const testMail = `something@${serverId}.mailosaur.net`;

cy.mailodaurGetMessage(serverId, {
    sentTo: testEmail
}).then(email => {
    // Do stuff
})
  • Install mailosaur
  • Make sure cypress can read sent mails
  • Make sure it is optional since it requires an extra dependency

Tests

  • A confirmation email will be sent after placing the order
  • If payment is made an invoice will be sent

Example:

it('can receive a confirmation mail that an order has been placed', () => {
    // TODO: implement mailosaur
})

it('can receive an invoice through the mail when a payment is completed', () => {
    // TODO: implement mailosaur
})
@peterjaap peterjaap added the enhancement New feature or request label Jan 18, 2022
@AndrewRMillar AndrewRMillar self-assigned this Feb 15, 2022
@AndrewRMillar
Copy link
Contributor

Will not work when testing locally and also not on our testing site, because of the k8s setup. Needs to use a different solution than our current testing setup.

@AndrewRMillar AndrewRMillar linked a pull request Feb 16, 2022 that will close this issue
@kolaente
Copy link
Collaborator

Another interesting solution might be mailhog - it has an api and you can host it locally in a docker container.

@peterjaap
Copy link
Contributor Author

peterjaap commented Mar 29, 2022

@kolaente yes we use that locally and that works fine, but when running the tests in a CI/CD situation it's limited. Using Mailosaur will enable us to inspect the emails later when something went wrong.

@norgeindian
Copy link
Contributor

@peterjaap , I currently try to set up our CI/CD integration for the tests.
And like you wrote, for the customer test, where the password is changed, an email is sent.
Unfortunately, I always get the error Unable to send mail: Unknown error in /opt/atlassian/pipelines/agent/build/vendor/laminas/laminas-mail/src/Transport/Sendmail.php:313
I assume, that is related to the fact, that in my pipeline docker container there is no way of sending out any mails.
How do you solve that currently in your CI/CD setup?

@peterjaap
Copy link
Contributor Author

peterjaap commented Oct 19, 2023

@norgeindian I haven't run in that yet, maybe because we generally use mageplaza/module-smtp to send mails with and we configure that to use some SMTP. Magento core now supports SMTP as well since a recent version. It won't rely on sendmail in that case.

@norgeindian
Copy link
Contributor

@peterjaap , thanks for this amazingly fast reply.
Good idea, that is surely the best way. I included mailhog now and set up a similar extension to use the mailhog SMTP port. That seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants