Fix tests for customer registration and reset password (#2560)
This commit is contained in:
parent
a64ea3609d
commit
2bbb458f56
4 changed files with 8 additions and 5 deletions
|
@ -31,7 +31,8 @@ describe("Tests for customer registration", () => {
|
|||
it("should register customer", { tags: ["@customer", "@stagedOnly"] }, () => {
|
||||
const email = `${startsWith}${faker.datatype.number()}@example.com`;
|
||||
customerRegistration({ email, channel: defaultChannel.slug });
|
||||
getMailActivationLinkForUser(email)
|
||||
const registrationLinkRegex = /\[(\s*http[^\]]*)\]/;
|
||||
getMailActivationLinkForUser(email, registrationLinkRegex)
|
||||
.then(urlLink => {
|
||||
const tokenRegex = /token=(.*)/;
|
||||
const token = urlLink.match(tokenRegex)[1];
|
||||
|
|
|
@ -9,7 +9,7 @@ import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
|||
import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails";
|
||||
import { STAFF_MEMBERS_LIST } from "../elements/staffMembers/staffMembersList";
|
||||
import { urlList, userDetailsUrl } from "../fixtures/urlList";
|
||||
import { updatePlugin } from "../support/api/requests/Plugins";
|
||||
import { activatePlugin, updatePlugin } from "../support/api/requests/Plugins";
|
||||
import {
|
||||
deleteStaffMembersStartsWith,
|
||||
updateStaffMember,
|
||||
|
@ -37,6 +37,7 @@ describe("Staff members", () => {
|
|||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteStaffMembersStartsWith(startsWith);
|
||||
activatePlugin({ id: "mirumee.notifications.admin_email" });
|
||||
|
||||
inviteStaffMemberWithFirstPermission({ email })
|
||||
.then(({ user: userResp }) => {
|
||||
|
|
|
@ -35,6 +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.grepTags = process.env.CYPRESS_grepTags;
|
||||
|
||||
on("before:browser:launch", ({}, launchOptions) => {
|
||||
|
|
|
@ -22,21 +22,21 @@ export function inviteStaffMemberWithFirstPermission({
|
|||
* Function mhGetMailsByRecipient first get all emails from mailhog 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, i = 0) {
|
||||
export function getMailActivationLinkForUser(email, regex, i = 0) {
|
||||
const urlRegex = regex ? regex : /\[\w*password\w*\]\(([^\)]*)/;
|
||||
if (i > 3) {
|
||||
throw new Error(`There is no email invitation for user ${email}`);
|
||||
}
|
||||
return cy.mhGetMailsByRecipient(email).should(mails => {
|
||||
if (!mails.length) {
|
||||
cy.wait(10000);
|
||||
getMailActivationLinkForUser(email, i + 1);
|
||||
getMailActivationLinkForUser(email, regex, i + 1);
|
||||
} else {
|
||||
cy.wrap(mails)
|
||||
.mhFirst()
|
||||
.should("not.eq", undefined)
|
||||
.mhGetBody()
|
||||
.then(body => {
|
||||
const urlRegex = /\[\w*password\w*\]\(([^\)]*)/;
|
||||
const bodyWithoutWhiteSpaces = body.replace(/(\r\n|\n|\r|\s)/gm, "");
|
||||
return urlRegex.exec(bodyWithoutWhiteSpaces)[1];
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue