Skip to content

Commit

Permalink
add email confirmation to customer registration e2e test (#4261)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojteknowacki authored Sep 27, 2023
1 parent fdc49f5 commit 292c51d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-fishes-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

add email confirmation to customer registration e2e test
63 changes: 38 additions & 25 deletions cypress/e2e/customerRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

import faker from "faker";

import {
CUSTOMER_DETAILS_SELECTORS,
} from "../elements/customers/customer-details";
import { CUSTOMER_DETAILS_SELECTORS } from "../elements/customers/customer-details";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { customerDetailsUrl } from "../fixtures/urlList";
import {
Expand All @@ -29,28 +27,32 @@ describe("Tests for customer registration", () => {
});
});

it("should register customer TC: SALEOR_1212", { tags: ["@customer", "@allEnv"] }, () => {
const email = `${startsWith}${faker.datatype.number()}@example.com`;
customerRegistration({ email, channel: defaultChannel.slug });
const registrationLinkRegex = /\[(\s*http[^\]]*)\]/;
getMailActivationLinkForUser(email, registrationLinkRegex)
.then(urlLink => {
const tokenRegex = /token=(.*)/;
const token = urlLink.match(tokenRegex)[1];
cy.clearSessionData();
confirmAccount(email, token);
})
.then(() => {
cy.loginUserViaRequest("token", {
email,
password: Cypress.env("USER_PASSWORD"),
}).its("body.data.tokenCreate");
})
.then(({ errors, token }) => {
expect(errors.length).to.eq(0);
expect(token).to.be.ok;
});
});
it(
"should register customer TC: SALEOR_1212",
{ tags: ["@customer", "@allEnv"] },
() => {
const email = `${startsWith}${faker.datatype.number()}@example.com`;
customerRegistration({ email, channel: defaultChannel.slug });
const registrationLinkRegex = /\[(\s*http[^\]]*)\]/;
getMailActivationLinkForUser(email, registrationLinkRegex)
.then(urlLink => {
const tokenRegex = /token=(.*)/;
const token = urlLink.match(tokenRegex)[1];
cy.clearSessionData();
confirmAccount(email, token);
})
.then(() => {
cy.loginUserViaRequest("token", {
email,
password: Cypress.env("USER_PASSWORD"),
}).its("body.data.tokenCreate");
})
.then(({ errors, token }) => {
expect(errors.length).to.eq(0);
expect(token).to.be.ok;
});
},
);

it(
"shouldn't register customer with duplicated email TC: SALEOR_1213",
Expand Down Expand Up @@ -81,6 +83,17 @@ describe("Tests for customer registration", () => {
.get(BUTTON_SELECTORS.confirm)
.click()
.confirmationMessageShouldDisappear()
.then(() => {
const registrationLinkRegex = /\[(\s*http[^\]]*)\]/;
getMailActivationLinkForUser(email, registrationLinkRegex).then(
urlLink => {
const tokenRegex = /token=(.*)/;
const token = urlLink.match(tokenRegex)[1];
cy.clearSessionData();
confirmAccount(email, token);
},
);
})
.clearSessionData()
.loginUserViaRequest("token", {
email,
Expand Down

0 comments on commit 292c51d

Please sign in to comment.