From 9673ad68b2dd2d18ad384b2bd9ac9a3883b65384 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Mon, 21 Oct 2024 00:43:59 -0500 Subject: [PATCH] fix: e2e consent test --- .../e2e/email-sign-in/login-email.cy.ts | 45 ------------- apps/consent/cypress/e2e/login-email.cy.ts | 50 ++++++++++++++ apps/consent/cypress/e2e/login-phone.cy.ts | 47 +++++++++++++ .../e2e/phone-sign-in/login-phone.cy.ts | 67 ------------------- apps/consent/cypress/e2e/spec.cy.ts | 0 5 files changed, 97 insertions(+), 112 deletions(-) delete mode 100644 apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts create mode 100644 apps/consent/cypress/e2e/login-email.cy.ts create mode 100644 apps/consent/cypress/e2e/login-phone.cy.ts delete mode 100644 apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts delete mode 100644 apps/consent/cypress/e2e/spec.cy.ts diff --git a/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts b/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts deleted file mode 100644 index 751e14d36e..0000000000 --- a/apps/consent/cypress/e2e/email-sign-in/login-email.cy.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { testData } from "../../support/test-config" - -describe("Account ID Test", () => { - let login_challenge: string | null - - before(() => { - cy.flushRedis() - cy.visit(testData.AUTHORIZATION_URL) - cy.url().then((currentUrl) => { - const urlObj = new URL(currentUrl) - login_challenge = urlObj.searchParams.get("login_challenge") - if (!login_challenge) { - throw new Error("login_challenge is null") - } - }) - }) - - it("Login email Test", () => { - cy.log("login challenge : ", login_challenge) - const email = testData.EMAIL - - cy.get("[data-testid=email_id_input]").should("exist") - cy.get("[data-testid=email_id_input]").should("be.visible") - cy.get("[data-testid=email_id_input]").should("not.be.disabled") - cy.get("[data-testid=email_id_input]").type(email) - - cy.get("[data-testid=email_login_next_btn]").should("exist") - cy.get("[data-testid=email_login_next_btn]").should("be.visible") - cy.get("[data-testid=email_login_next_btn]").click() - - cy.getOTP(email).then((otp) => { - const code = otp - - cy.get("[data-testid=verification_code_input]").should("exist") - cy.get("[data-testid=verification_code_input]").should("be.visible") - cy.get("[data-testid=verification_code_input]").should("not.be.disabled") - cy.get("[data-testid=verification_code_input]").type(code) - - cy.get("[data-testid=submit_consent_btn]").should("exist") - cy.get("[data-testid=submit_consent_btn]").should("be.visible") - cy.get("[data-testid=submit_consent_btn]").should("not.be.disabled") - cy.get("[data-testid=submit_consent_btn]").click() - }) - }) -}) diff --git a/apps/consent/cypress/e2e/login-email.cy.ts b/apps/consent/cypress/e2e/login-email.cy.ts new file mode 100644 index 0000000000..4fbd0cff14 --- /dev/null +++ b/apps/consent/cypress/e2e/login-email.cy.ts @@ -0,0 +1,50 @@ +import { testData } from "../support/test-config" + +describe("Account ID Test", () => { + before(() => { + cy.flushRedis() + cy.visit(testData.AUTHORIZATION_URL) + cy.location("search").should((search) => { + const params = new URLSearchParams(search) + expect(params.has("login_challenge")).to.be.true + }) + }) + + it("Login email Test", () => { + const email = testData.EMAIL + + cy.get("[data-testid=sign_in_with_phone_btn]") + .should("exist") + .should("be.visible") + .click() + + cy.get("[data-testid=sign_in_with_email_btn]") + .should("exist") + .should("be.visible") + .click() + + cy.get("[data-testid=email_id_input]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .type(email) + + cy.get("[data-testid=email_login_next_btn]") + .should("exist") + .should("be.visible") + .click() + + cy.getOTP(email).then((code) => { + cy.get("[data-testid=verification_code_input]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .type(code) + + cy.get("[data-testid=submit_consent_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + }) + }) +}) diff --git a/apps/consent/cypress/e2e/login-phone.cy.ts b/apps/consent/cypress/e2e/login-phone.cy.ts new file mode 100644 index 0000000000..3a0f6240ef --- /dev/null +++ b/apps/consent/cypress/e2e/login-phone.cy.ts @@ -0,0 +1,47 @@ +import { testData } from "../support/test-config" + +describe("Account ID Test", () => { + before(() => { + cy.flushRedis() + cy.visit(testData.AUTHORIZATION_URL) + cy.location("search").should((search) => { + const params = new URLSearchParams(search) + expect(params.has("login_challenge")).to.be.true + }) + }) + + it("Login Phone Test", () => { + cy.get("[data-testid=sign_in_with_email_btn]") + .should("exist") + .should("be.visible") + .click() + + cy.get("[data-testid=sign_in_with_phone_btn]") + .should("exist") + .should("be.visible") + .click() + + cy.get("[data-testid=phone_number_input]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .type(testData.PHONE_NUMBER) + + cy.get("[data-testid=phone_login_next_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() + + cy.get("[data-testid=verification_code_input]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .type(testData.VERIFICATION_CODE) + + cy.get("[data-testid=submit_consent_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + }) +}) diff --git a/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts b/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts deleted file mode 100644 index fa5f6bca6d..0000000000 --- a/apps/consent/cypress/e2e/phone-sign-in/login-phone.cy.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { createHash } from "crypto" - -import { testData } from "../../support/test-config" -describe("Account ID Test", () => { - let login_challenge: string | null - - before(() => { - cy.flushRedis() - cy.visit(testData.AUTHORIZATION_URL) - cy.url().then((currentUrl) => { - const urlObj = new URL(currentUrl) - login_challenge = urlObj.searchParams.get("login_challenge") - if (!login_challenge) { - throw new Error("login_challenge is null") - } - }) - }) - - it("Verification Test", () => { - cy.log("login challenge : ", login_challenge) - - cy.get("[data-testid=sign_in_with_email_btn]") - .should("exist") - .should("be.visible") - .click() - - cy.get("[data-testid=sign_in_with_phone_btn]") - .should("exist") - .should("be.visible") - .click() - - cy.get("[data-testid=phone_number_input]") - .should("exist") - .should("be.visible") - .should("not.be.disabled") - .type(testData.PHONE_NUMBER) - - cy.get("[data-testid=phone_login_next_btn]") - .should("exist") - .should("be.visible") - .should("not.be.disabled") - .click() - - if (!login_challenge) { - throw new Error("login_challenge does not found") - } - - const cookieValue = JSON.stringify({ - loginType: "Phone", - value: testData.PHONE_NUMBER, - remember: false, - }) - const cookieName = createHash("md5").update(login_challenge).digest("hex") - cy.setCookie(cookieName, cookieValue, { secure: true }) - cy.visit(`/login/verification?login_challenge=${login_challenge}`) - - cy.get("[data-testid=verification_code_input]").should("exist") - cy.get("[data-testid=verification_code_input]").should("be.visible") - cy.get("[data-testid=verification_code_input]").should("not.be.disabled") - cy.get("[data-testid=verification_code_input]").type(testData.VERIFICATION_CODE) - - cy.get("[data-testid=submit_consent_btn]").should("exist") - cy.get("[data-testid=submit_consent_btn]").should("be.visible") - cy.get("[data-testid=submit_consent_btn]").should("not.be.disabled") - cy.get("[data-testid=submit_consent_btn]").click() - }) -}) diff --git a/apps/consent/cypress/e2e/spec.cy.ts b/apps/consent/cypress/e2e/spec.cy.ts deleted file mode 100644 index e69de29bb2..0000000000