From d0720d7b6b59b4b3b075e7c90d6de88120a7a534 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Sat, 19 Oct 2024 20:14:07 -0500 Subject: [PATCH] test(apps): fix dashboard/voucher auth test --- .../app/api/auth/[...nextauth]/route.ts | 2 +- apps/dashboard/cypress.config.ts | 2 +- .../cypress/e2e/consent-integration.cy.ts | 76 ++++++++++++------- .../cypress/e2e/consent-integration.cy.ts | 76 ++++++++++++------- 4 files changed, 96 insertions(+), 60 deletions(-) diff --git a/apps/dashboard/app/api/auth/[...nextauth]/route.ts b/apps/dashboard/app/api/auth/[...nextauth]/route.ts index e5d259ed8c..125234bdca 100644 --- a/apps/dashboard/app/api/auth/[...nextauth]/route.ts +++ b/apps/dashboard/app/api/auth/[...nextauth]/route.ts @@ -38,7 +38,7 @@ export const authOptions: AuthOptions = { }, }, ], - debug: true, + debug: process.env.NODE_ENV === "development", secret: env.NEXTAUTH_SECRET, callbacks: { async jwt({ token, account, profile }) { diff --git a/apps/dashboard/cypress.config.ts b/apps/dashboard/cypress.config.ts index 602109ba66..c833e2f877 100644 --- a/apps/dashboard/cypress.config.ts +++ b/apps/dashboard/cypress.config.ts @@ -21,6 +21,6 @@ export default defineConfig({ video: false, retries: { openMode: 1, - runMode: 2, + runMode: 3, }, }) diff --git a/apps/dashboard/cypress/e2e/consent-integration.cy.ts b/apps/dashboard/cypress/e2e/consent-integration.cy.ts index 1f16fb1b18..61f498df67 100644 --- a/apps/dashboard/cypress/e2e/consent-integration.cy.ts +++ b/apps/dashboard/cypress/e2e/consent-integration.cy.ts @@ -9,44 +9,62 @@ describe("Consent integration Test", () => { }) it("Consent integration", () => { - cy.contains("button", "Sign in with Blink").should("exist") - cy.contains("button", "Sign in with Blink").should("be.visible") - cy.contains("button", "Sign in with Blink").should("not.be.disabled") - cy.contains("button", "Sign in with Blink").click() + cy.contains("button", "Sign in with Blink") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() + + 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() const email = signInData.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_id_input]") + .should("exist") + .should("be.visible") + .should("be.enabled") + .type(email) + .should("have.value", 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]").should("not.be.disabled") - cy.get("[data-testid=email_login_next_btn]").click() + cy.get("[data-testid=email_login_next_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .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=verification_code_input]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .type(code) - cy.contains("label", "read").should("exist") - cy.contains("label", "read").should("be.visible") - cy.contains("label", "read").should("not.be.disabled") - cy.contains("label", "read").should("not.be.disabled") - cy.contains("label", "read").click() + cy.contains("label", "read") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .should("not.be.disabled") + .click() - cy.contains("label", "write").should("exist") - cy.contains("label", "write").should("be.visible") - cy.contains("label", "write").should("not.be.disabled") - cy.contains("label", "write").click() + cy.contains("label", "write") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() - 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() + cy.get("[data-testid=submit_consent_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() cy.url().should("eq", Cypress.config().baseUrl + "/") cy.getCookie("next-auth.session-token").then((cookie) => { diff --git a/apps/voucher/cypress/e2e/consent-integration.cy.ts b/apps/voucher/cypress/e2e/consent-integration.cy.ts index 1f16fb1b18..61f498df67 100644 --- a/apps/voucher/cypress/e2e/consent-integration.cy.ts +++ b/apps/voucher/cypress/e2e/consent-integration.cy.ts @@ -9,44 +9,62 @@ describe("Consent integration Test", () => { }) it("Consent integration", () => { - cy.contains("button", "Sign in with Blink").should("exist") - cy.contains("button", "Sign in with Blink").should("be.visible") - cy.contains("button", "Sign in with Blink").should("not.be.disabled") - cy.contains("button", "Sign in with Blink").click() + cy.contains("button", "Sign in with Blink") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() + + 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() const email = signInData.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_id_input]") + .should("exist") + .should("be.visible") + .should("be.enabled") + .type(email) + .should("have.value", 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]").should("not.be.disabled") - cy.get("[data-testid=email_login_next_btn]").click() + cy.get("[data-testid=email_login_next_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .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=verification_code_input]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .type(code) - cy.contains("label", "read").should("exist") - cy.contains("label", "read").should("be.visible") - cy.contains("label", "read").should("not.be.disabled") - cy.contains("label", "read").should("not.be.disabled") - cy.contains("label", "read").click() + cy.contains("label", "read") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .should("not.be.disabled") + .click() - cy.contains("label", "write").should("exist") - cy.contains("label", "write").should("be.visible") - cy.contains("label", "write").should("not.be.disabled") - cy.contains("label", "write").click() + cy.contains("label", "write") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() - 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() + cy.get("[data-testid=submit_consent_btn]") + .should("exist") + .should("be.visible") + .should("not.be.disabled") + .click() cy.url().should("eq", Cypress.config().baseUrl + "/") cy.getCookie("next-auth.session-token").then((cookie) => {