diff --git a/cypress/e2e/configuration/customer.js b/cypress/e2e/configuration/customer.js index 6949e8f36..9d78a3240 100644 --- a/cypress/e2e/configuration/customer.js +++ b/cypress/e2e/configuration/customer.js @@ -71,7 +71,9 @@ describe("Tests for customer", () => { expect(customer.lastName, "Expect correct last name").to.eq( randomName, ); - expect(customer.email, "Expect correct email").to.eq(email); + expect(customer.email, "Expect correct email").to.eq( + email.toLowerCase(), + ); expect(customer.note, "Expect correct note").to.eq(note); cy.expectCorrectFullAddress(customer.addresses[0], address); }); @@ -277,7 +279,7 @@ describe("Tests for customer", () => { ); expect(user.lastName, "Expect correct last name").to.eq(updatedName); expect(user.email, "Expect correct email").to.eq( - `${updatedName}@example.com`, + `${updatedName}@example.com`.toLowerCase(), ); expect(user.note, "Expect correct note").to.eq(updatedName); }); diff --git a/cypress/e2e/staffMembers.js b/cypress/e2e/staffMembers.js index caec8b870..947bf4c77 100644 --- a/cypress/e2e/staffMembers.js +++ b/cypress/e2e/staffMembers.js @@ -91,18 +91,22 @@ describe("Staff members", () => { ); it("should activate user", { tags: ["@staffMembers", "@stagedOnly"] }, () => { + const serverStoredEmail = email.toLowerCase(); + updateStaffMember({ userId: user.id, isActive: false }); updateUserActiveFlag(user.id); cy.clearSessionData() .loginUserViaRequest("auth", { email, password }) .visit(urlList.homePage); - expectWelcomeMessageIncludes(email); + expectWelcomeMessageIncludes(serverStoredEmail); }); it( "should remove user permissions", { tags: ["@staffMembers", "@stagedOnly"] }, () => { + const serverStoredEmail = email.toLowerCase(); + cy.visit(userDetailsUrl(user.id)) .get(STAFF_MEMBER_DETAILS.removePermissionButton) .click() @@ -114,7 +118,7 @@ describe("Staff members", () => { .clearSessionData() .loginUserViaRequest("auth", { email, password }) .visit(urlList.homePage); - expectWelcomeMessageIncludes(email); + expectWelcomeMessageIncludes(serverStoredEmail); getDisplayedSelectors().then(displayedSelectors => { expect(Object.values(displayedSelectors)).to.have.length(1); expect(Object.values(displayedSelectors)[0]).to.eq( diff --git a/cypress/support/api/requests/Customer.js b/cypress/support/api/requests/Customer.js index 40e12d7ef..310137467 100644 --- a/cypress/support/api/requests/Customer.js +++ b/cypress/support/api/requests/Customer.js @@ -1,14 +1,14 @@ import { getDefaultAddress, getDefaultAddressWithoutType, - getValueWithDefault + getValueWithDefault, } from "./utils/Utils"; export function createCustomer(email, customerName, address, isActive = false) { const addressesLines = getValueWithDefault( address, `${getDefaultAddress(address, "defaultBillingAddress")} - ${getDefaultAddress(address, "defaultShippingAddress")}` + ${getDefaultAddress(address, "defaultShippingAddress")}`, ); const mutation = ` mutation{ @@ -76,7 +76,7 @@ export function getCustomers(startsWith) { export function customerRegistration({ email, password = Cypress.env("USER_PASSWORD"), - channel + channel, }) { const mutation = `mutation{ accountRegister(input:{ @@ -113,8 +113,10 @@ export function requestPasswordReset(email, channel) { } export function confirmAccount(email, token) { + const serverStoredEmail = email.toLowerCase(); + const mutation = `mutation{ - confirmAccount(email:"${email}", token:"${token}"){ + confirmAccount(email:"${serverStoredEmail}", token:"${token}"){ user{ email } diff --git a/cypress/support/api/utils/users.js b/cypress/support/api/utils/users.js index 709fc950b..7422a32c6 100644 --- a/cypress/support/api/utils/users.js +++ b/cypress/support/api/utils/users.js @@ -23,14 +23,18 @@ export function inviteStaffMemberWithFirstPermission({ * 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) { + const serverStoredEmail = email.toLowerCase(); + const urlRegex = regex ? regex : /\[\w*password\w*\]\(([^\)]*)/; if (i > 3) { - throw new Error(`There is no email invitation for user ${email}`); + throw new Error( + `There is no email invitation for user ${serverStoredEmail}`, + ); } - return cy.mhGetMailsByRecipient(email).should(mails => { + return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { if (!mails.length) { cy.wait(10000); - getMailActivationLinkForUser(email, regex, i + 1); + getMailActivationLinkForUser(serverStoredEmail, regex, i + 1); } else { cy.wrap(mails) .mhFirst() @@ -45,20 +49,28 @@ export function getMailActivationLinkForUser(email, regex, i = 0) { } export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) { + const serverStoredEmail = email.toLowerCase(); + if (i > 3) { - throw new Error(`There is no email invitation for user ${email}`); + throw new Error( + `There is no email invitation for user ${serverStoredEmail}`, + ); } - return cy.mhGetMailsByRecipient(email).should(mails => { + return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { if (!mails.length) { cy.wait(10000); - getMailActivationLinkForUserAndSubject(email, subject, i + 1); + getMailActivationLinkForUserAndSubject(serverStoredEmail, subject, i + 1); } else { cy.wrap(mails) .mhGetMailsBySubject(subject) .should(mailsWithSubject => { if (!mailsWithSubject.length) { cy.wait(10000); - getMailActivationLinkForUserAndSubject(email, subject, i + 1); + getMailActivationLinkForUserAndSubject( + serverStoredEmail, + subject, + i + 1, + ); } else { cy.wrap(mailsWithSubject) .mhFirst() @@ -79,13 +91,17 @@ export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) { } export function getMailWithResetPasswordLink(email, subject, i = 0) { + const serverStoredEmail = email.toLowerCase(); + if (i > 5) { - throw new Error(`There is no email with reset password for user ${email}`); + throw new Error( + `There is no email with reset password for user ${serverStoredEmail}`, + ); } - return cy.mhGetMailsByRecipient(email).should(mails => { + return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { if (!mails.length) { cy.wait(3000); - getMailWithResetPasswordLink(email, subject, i + 1); + getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1); } else { cy.mhGetMailsBySubject(subject); return mails; @@ -94,13 +110,17 @@ export function getMailWithResetPasswordLink(email, subject, i = 0) { } export function getMailsForUser(email, i = 0) { + const serverStoredEmail = email.toLowerCase(); + if (i > 5) { - throw new Error(`There is no email invitation for user ${email}`); + throw new Error( + `There is no email invitation for user ${serverStoredEmail}`, + ); } - return cy.mhGetMailsByRecipient(email).should(mails => { + return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { if (!mails.length) { cy.wait(3000); - getMailsForUser(email, i + 1); + getMailsForUser(serverStoredEmail, i + 1); } else { return mails; } diff --git a/cypress/support/pages/draftOrderPage.js b/cypress/support/pages/draftOrderPage.js index 0abb13583..0392eddb2 100644 --- a/cypress/support/pages/draftOrderPage.js +++ b/cypress/support/pages/draftOrderPage.js @@ -12,7 +12,9 @@ export function finalizeDraftOrder(name) { .get(DRAFT_ORDER_SELECTORS.selectCustomer) .type(name); return cy - .contains(DRAFT_ORDER_SELECTORS.selectCustomerOption, name) + .contains(DRAFT_ORDER_SELECTORS.selectCustomerOption, name, { + matchCase: false, + }) .click() .get(DRAFT_ORDER_SELECTORS.customerEmail) .should("be.visible")