expect email to lowercase in test assertions (#2796)
This commit is contained in:
parent
20d79dce71
commit
443a94834e
5 changed files with 52 additions and 22 deletions
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue