Move from mailhog to mailpit main (#3616)
* move from mailhog to mailpit * update packaje-lock
This commit is contained in:
parent
f79629129a
commit
2b87e8b141
9 changed files with 99 additions and 23 deletions
2
.github/workflows/cypress-repeat.yml
vendored
2
.github/workflows/cypress-repeat.yml
vendored
|
@ -55,7 +55,7 @@ jobs:
|
|||
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
|
||||
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
|
||||
COMMIT_INFO_MESSAGE: Cypress repeat with - ${{ github.event.inputs.spec }} ${{ github.event.inputs.grep }} ${{ github.event.inputs.dashboard_url}}
|
||||
CYPRESS_grep: ${{ github.event.inputs.grep }}
|
||||
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
|
||||
|
|
1
.github/workflows/e2e.yml
vendored
1
.github/workflows/e2e.yml
vendored
|
@ -126,6 +126,7 @@ jobs:
|
|||
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
|
||||
COMMIT_INFO_MESSAGE: ${{ needs.get-selected-tags-and-containers.outputs.tags }} tests triggered on PR - https://github.com/${{ github.repository }}/pull/${{ github.ref_name }}
|
||||
CYPRESS_grepTags: ${{ needs.get-selected-tags-and-containers.outputs.tags }}
|
||||
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
|
||||
with:
|
||||
parallel: true
|
||||
group: 'UI - Chrome'
|
||||
|
|
4
.github/workflows/tests-nightly.yml
vendored
4
.github/workflows/tests-nightly.yml
vendored
|
@ -148,7 +148,7 @@ jobs:
|
|||
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
|
||||
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
|
||||
COMMIT_INFO_MESSAGE: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
|
||||
CYPRESS_grepTags: ${{ env.GREP_TAGS }}
|
||||
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
|
||||
|
@ -256,7 +256,7 @@ jobs:
|
|||
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
|
||||
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
|
||||
COMMIT_INFO_MESSAGE: Triggered via release - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}, ${{github.event.client_payload.pullRequestUrl}}
|
||||
CYPRESS_grepTags: ${{steps.set-tag-for-tests.outputs.result}}
|
||||
with:
|
||||
|
|
|
@ -68,10 +68,16 @@ describe("As an admin I want to manage plugins", () => {
|
|||
customerRegistration({
|
||||
email: customerEmail,
|
||||
channel: defaultChannel.slug,
|
||||
});
|
||||
getMailsForUser(customerEmail)
|
||||
.its("0.Content.Headers.Subject.0")
|
||||
.should("eq", randomName);
|
||||
})
|
||||
.then(() => {
|
||||
getMailsForUser(customerEmail)
|
||||
.mpLatest()
|
||||
.mpGetMailDetails()
|
||||
.its("Subject");
|
||||
})
|
||||
.then(subject => {
|
||||
expect(subject).to.eq(randomName);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ module.exports = async (on, config) => {
|
|||
config.env.SECOND_USER_NAME = process.env.CYPRESS_SECOND_USER_NAME;
|
||||
config.env.PERMISSIONS_USERS_PASSWORD =
|
||||
process.env.CYPRESS_PERMISSIONS_USERS_PASSWORD;
|
||||
config.env.mailHogUrl = process.env.CYPRESS_mailHogUrl;
|
||||
config.env.MAILPITURL = process.env.CYPRESS_MAILPITURL;
|
||||
config.env.grepTags = process.env.CYPRESS_grepTags;
|
||||
config.baseUrl = baseUrl(process.env.CYPRESS_demoTests);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export function inviteStaffMemberWithFirstPermission({
|
|||
}
|
||||
|
||||
/**
|
||||
* Function mhGetMailsByRecipient first get all emails from mailhog with a timeout, and after that it finds email from recipient.
|
||||
* Function mpGetMailsByRecipient first get all emails from mailpit with a timeout, and after that it finds email from recipient.
|
||||
* It cloud happened that invite email from saleor has not been received yet, so in this case the action should be retried.
|
||||
*/
|
||||
export function getMailActivationLinkForUser(email, regex, i = 0) {
|
||||
|
@ -31,15 +31,16 @@ export function getMailActivationLinkForUser(email, regex, i = 0) {
|
|||
`There is no email invitation for user ${serverStoredEmail}`,
|
||||
);
|
||||
}
|
||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
if (!mails.length) {
|
||||
cy.wait(10000);
|
||||
getMailActivationLinkForUser(serverStoredEmail, regex, i + 1);
|
||||
} else {
|
||||
cy.wrap(mails)
|
||||
.mhFirst()
|
||||
.mpLatest()
|
||||
.should("not.eq", undefined)
|
||||
.mhGetBody()
|
||||
.mpGetMailDetails()
|
||||
.its("Text")
|
||||
.then(body => {
|
||||
const bodyWithoutWhiteSpaces = body.replace(/(\r\n|\n|\r|\s)/gm, "");
|
||||
return urlRegex.exec(bodyWithoutWhiteSpaces)[1];
|
||||
|
@ -56,13 +57,13 @@ export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) {
|
|||
`There is no email invitation for user ${serverStoredEmail}`,
|
||||
);
|
||||
}
|
||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
if (!mails.length) {
|
||||
cy.wait(10000);
|
||||
getMailActivationLinkForUserAndSubject(serverStoredEmail, subject, i + 1);
|
||||
} else {
|
||||
cy.wrap(mails)
|
||||
.mhGetMailsBySubject(subject)
|
||||
.mpGetMailsBySubject(subject)
|
||||
.then(mailsWithSubject => {
|
||||
if (!mailsWithSubject.length) {
|
||||
cy.wait(10000);
|
||||
|
@ -73,9 +74,10 @@ export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) {
|
|||
);
|
||||
} else {
|
||||
cy.wrap(mailsWithSubject)
|
||||
.mhFirst()
|
||||
.mpLatest()
|
||||
.should("not.eq", undefined)
|
||||
.mhGetBody()
|
||||
.mpGetMailDetails()
|
||||
.its("Text")
|
||||
.then(body => {
|
||||
const urlRegex = /\[\w*password\w*\]\(([^\)]*)/;
|
||||
const bodyWithoutWhiteSpaces = body.replace(
|
||||
|
@ -98,12 +100,12 @@ export function getMailWithResetPasswordLink(email, subject, i = 0) {
|
|||
`There is no email with reset password for user ${serverStoredEmail}`,
|
||||
);
|
||||
}
|
||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
if (!mails.length) {
|
||||
cy.wait(3000);
|
||||
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
|
||||
} else {
|
||||
cy.mhGetMailsBySubject(subject).then(resetPasswordMails => {
|
||||
cy.mpGetMailsBySubject(subject).then(resetPasswordMails => {
|
||||
if (!resetPasswordMails.length) {
|
||||
cy.wait(3000);
|
||||
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
|
||||
|
@ -123,7 +125,7 @@ export function getMailsForUser(email, i = 0) {
|
|||
`There is no email invitation for user ${serverStoredEmail}`,
|
||||
);
|
||||
}
|
||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||
if (!mails.length) {
|
||||
cy.wait(3000);
|
||||
getMailsForUser(serverStoredEmail, i + 1);
|
||||
|
|
64
cypress/support/customCommands/basicOperations/mailpit.js
Normal file
64
cypress/support/customCommands/basicOperations/mailpit.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
const mhApiUrl = path => {
|
||||
const envValue = Cypress.env("MAILPITURL");
|
||||
const basePath = envValue ? envValue : Cypress.config("MAILPITURL");
|
||||
return `${basePath}/api${path}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mail Collection
|
||||
*/
|
||||
|
||||
Cypress.Commands.add("mpGetAllMails", (fromLast = 60000) =>
|
||||
cy
|
||||
.request({
|
||||
method: "GET",
|
||||
url: mhApiUrl("/v1/messages?limit=9999"),
|
||||
})
|
||||
.then(response => {
|
||||
// by default get mails received in last 60000ms
|
||||
response.body.messages = response.body.messages.filter(message => {
|
||||
const fiveMinutesAgo = Date.now() - fromLast;
|
||||
const mailCreated = new Date(message.Created);
|
||||
return mailCreated.getTime() > fiveMinutesAgo;
|
||||
});
|
||||
if (typeof response.body === "string") {
|
||||
return JSON.parse(response.body);
|
||||
} else {
|
||||
return response.body;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
Cypress.Commands.add("mpLatest", { prevSubject: true }, mails =>
|
||||
Array.isArray(mails) && mails.length > 0 ? mails[0] : mails,
|
||||
);
|
||||
|
||||
Cypress.Commands.add("mpGetMailsBySubject", subject => {
|
||||
cy.mpGetAllMails()
|
||||
.its("messages")
|
||||
.then(mails => mails.filter(mail => mail.Subject === subject));
|
||||
});
|
||||
|
||||
Cypress.Commands.add("mpGetMailsByRecipient", recipient => {
|
||||
cy.mpGetAllMails()
|
||||
.its("messages")
|
||||
.then(mails =>
|
||||
mails.filter(mail =>
|
||||
mail.To.map(recipientObj => `${recipientObj.Address}`).includes(
|
||||
recipient,
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("mpGetMailDetails", { prevSubject: true }, mail =>
|
||||
cy
|
||||
.wrap(mail)
|
||||
.then(mail => {
|
||||
cy.request({
|
||||
method: "GET",
|
||||
url: mhApiUrl(`/v1/message/${mail.ID}`),
|
||||
});
|
||||
})
|
||||
.its("body"),
|
||||
);
|
|
@ -1,7 +1,7 @@
|
|||
// / <reference types="cypress" />
|
||||
|
||||
import "cypress-file-upload";
|
||||
import "cypress-mailhog";
|
||||
import "./customCommands/basicOperations/mailpit";
|
||||
import "cypress-mochawesome-reporter/register";
|
||||
import "./customCommands/basicOperations";
|
||||
import "./customCommands/deleteElementsViaApi";
|
||||
|
|
9
package-lock.json
generated
9
package-lock.json
generated
|
@ -15413,8 +15413,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/cypress-mailhog": {
|
||||
"version": "1.3.0",
|
||||
"license": "GPL-2.0",
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress-mailhog/-/cypress-mailhog-1.7.0.tgz",
|
||||
"integrity": "sha512-OBk27OYm4slL5lCtphlHTlFPnrDEmuMeqSTch4/uk92iPzh8+gS4Y1KAmMiZsSDGjQzXi/7Ab5QWo6xmq8evXg==",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/cypress-mochawesome-reporter": {
|
||||
|
@ -48879,7 +48880,9 @@
|
|||
"optional": true
|
||||
},
|
||||
"cypress-mailhog": {
|
||||
"version": "1.3.0",
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress-mailhog/-/cypress-mailhog-1.7.0.tgz",
|
||||
"integrity": "sha512-OBk27OYm4slL5lCtphlHTlFPnrDEmuMeqSTch4/uk92iPzh8+gS4Y1KAmMiZsSDGjQzXi/7Ab5QWo6xmq8evXg==",
|
||||
"optional": true
|
||||
},
|
||||
"cypress-mochawesome-reporter": {
|
||||
|
|
Loading…
Reference in a new issue