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_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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}}
|
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 }}
|
CYPRESS_grep: ${{ github.event.inputs.grep }}
|
||||||
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
|
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 }}
|
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 }}
|
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_grepTags: ${{ needs.get-selected-tags-and-containers.outputs.tags }}
|
||||||
|
CYPRESS_MAILPITURL: ${{ secrets.CYPRESS_MAILPITURL }}
|
||||||
with:
|
with:
|
||||||
parallel: true
|
parallel: true
|
||||||
group: 'UI - Chrome'
|
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_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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 }}
|
COMMIT_INFO_MESSAGE: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
|
||||||
CYPRESS_grepTags: ${{ env.GREP_TAGS }}
|
CYPRESS_grepTags: ${{ env.GREP_TAGS }}
|
||||||
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
|
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
|
||||||
|
@ -256,7 +256,7 @@ jobs:
|
||||||
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
|
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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}}
|
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}}
|
CYPRESS_grepTags: ${{steps.set-tag-for-tests.outputs.result}}
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -68,10 +68,16 @@ describe("As an admin I want to manage plugins", () => {
|
||||||
customerRegistration({
|
customerRegistration({
|
||||||
email: customerEmail,
|
email: customerEmail,
|
||||||
channel: defaultChannel.slug,
|
channel: defaultChannel.slug,
|
||||||
});
|
})
|
||||||
|
.then(() => {
|
||||||
getMailsForUser(customerEmail)
|
getMailsForUser(customerEmail)
|
||||||
.its("0.Content.Headers.Subject.0")
|
.mpLatest()
|
||||||
.should("eq", randomName);
|
.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.SECOND_USER_NAME = process.env.CYPRESS_SECOND_USER_NAME;
|
||||||
config.env.PERMISSIONS_USERS_PASSWORD =
|
config.env.PERMISSIONS_USERS_PASSWORD =
|
||||||
process.env.CYPRESS_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.env.grepTags = process.env.CYPRESS_grepTags;
|
||||||
config.baseUrl = baseUrl(process.env.CYPRESS_demoTests);
|
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.
|
* 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) {
|
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}`,
|
`There is no email invitation for user ${serverStoredEmail}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||||
if (!mails.length) {
|
if (!mails.length) {
|
||||||
cy.wait(10000);
|
cy.wait(10000);
|
||||||
getMailActivationLinkForUser(serverStoredEmail, regex, i + 1);
|
getMailActivationLinkForUser(serverStoredEmail, regex, i + 1);
|
||||||
} else {
|
} else {
|
||||||
cy.wrap(mails)
|
cy.wrap(mails)
|
||||||
.mhFirst()
|
.mpLatest()
|
||||||
.should("not.eq", undefined)
|
.should("not.eq", undefined)
|
||||||
.mhGetBody()
|
.mpGetMailDetails()
|
||||||
|
.its("Text")
|
||||||
.then(body => {
|
.then(body => {
|
||||||
const bodyWithoutWhiteSpaces = body.replace(/(\r\n|\n|\r|\s)/gm, "");
|
const bodyWithoutWhiteSpaces = body.replace(/(\r\n|\n|\r|\s)/gm, "");
|
||||||
return urlRegex.exec(bodyWithoutWhiteSpaces)[1];
|
return urlRegex.exec(bodyWithoutWhiteSpaces)[1];
|
||||||
|
@ -56,13 +57,13 @@ export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) {
|
||||||
`There is no email invitation for user ${serverStoredEmail}`,
|
`There is no email invitation for user ${serverStoredEmail}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||||
if (!mails.length) {
|
if (!mails.length) {
|
||||||
cy.wait(10000);
|
cy.wait(10000);
|
||||||
getMailActivationLinkForUserAndSubject(serverStoredEmail, subject, i + 1);
|
getMailActivationLinkForUserAndSubject(serverStoredEmail, subject, i + 1);
|
||||||
} else {
|
} else {
|
||||||
cy.wrap(mails)
|
cy.wrap(mails)
|
||||||
.mhGetMailsBySubject(subject)
|
.mpGetMailsBySubject(subject)
|
||||||
.then(mailsWithSubject => {
|
.then(mailsWithSubject => {
|
||||||
if (!mailsWithSubject.length) {
|
if (!mailsWithSubject.length) {
|
||||||
cy.wait(10000);
|
cy.wait(10000);
|
||||||
|
@ -73,9 +74,10 @@ export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
cy.wrap(mailsWithSubject)
|
cy.wrap(mailsWithSubject)
|
||||||
.mhFirst()
|
.mpLatest()
|
||||||
.should("not.eq", undefined)
|
.should("not.eq", undefined)
|
||||||
.mhGetBody()
|
.mpGetMailDetails()
|
||||||
|
.its("Text")
|
||||||
.then(body => {
|
.then(body => {
|
||||||
const urlRegex = /\[\w*password\w*\]\(([^\)]*)/;
|
const urlRegex = /\[\w*password\w*\]\(([^\)]*)/;
|
||||||
const bodyWithoutWhiteSpaces = body.replace(
|
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}`,
|
`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) {
|
if (!mails.length) {
|
||||||
cy.wait(3000);
|
cy.wait(3000);
|
||||||
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
|
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
|
||||||
} else {
|
} else {
|
||||||
cy.mhGetMailsBySubject(subject).then(resetPasswordMails => {
|
cy.mpGetMailsBySubject(subject).then(resetPasswordMails => {
|
||||||
if (!resetPasswordMails.length) {
|
if (!resetPasswordMails.length) {
|
||||||
cy.wait(3000);
|
cy.wait(3000);
|
||||||
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
|
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
|
||||||
|
@ -123,7 +125,7 @@ export function getMailsForUser(email, i = 0) {
|
||||||
`There is no email invitation for user ${serverStoredEmail}`,
|
`There is no email invitation for user ${serverStoredEmail}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
|
return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => {
|
||||||
if (!mails.length) {
|
if (!mails.length) {
|
||||||
cy.wait(3000);
|
cy.wait(3000);
|
||||||
getMailsForUser(serverStoredEmail, i + 1);
|
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" />
|
// / <reference types="cypress" />
|
||||||
|
|
||||||
import "cypress-file-upload";
|
import "cypress-file-upload";
|
||||||
import "cypress-mailhog";
|
import "./customCommands/basicOperations/mailpit";
|
||||||
import "cypress-mochawesome-reporter/register";
|
import "cypress-mochawesome-reporter/register";
|
||||||
import "./customCommands/basicOperations";
|
import "./customCommands/basicOperations";
|
||||||
import "./customCommands/deleteElementsViaApi";
|
import "./customCommands/deleteElementsViaApi";
|
||||||
|
|
9
package-lock.json
generated
9
package-lock.json
generated
|
@ -15413,8 +15413,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cypress-mailhog": {
|
"node_modules/cypress-mailhog": {
|
||||||
"version": "1.3.0",
|
"version": "1.7.0",
|
||||||
"license": "GPL-2.0",
|
"resolved": "https://registry.npmjs.org/cypress-mailhog/-/cypress-mailhog-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-OBk27OYm4slL5lCtphlHTlFPnrDEmuMeqSTch4/uk92iPzh8+gS4Y1KAmMiZsSDGjQzXi/7Ab5QWo6xmq8evXg==",
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"node_modules/cypress-mochawesome-reporter": {
|
"node_modules/cypress-mochawesome-reporter": {
|
||||||
|
@ -48879,7 +48880,9 @@
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"cypress-mailhog": {
|
"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
|
"optional": true
|
||||||
},
|
},
|
||||||
"cypress-mochawesome-reporter": {
|
"cypress-mochawesome-reporter": {
|
||||||
|
|
Loading…
Reference in a new issue