From 4bd0665887ceb699dbb50ba8414ca0fd9630d905 Mon Sep 17 00:00:00 2001 From: david emioma Date: Fri, 15 Mar 2024 18:41:29 +0000 Subject: [PATCH] Updated Ci.yml file --- .github/workflows/ci.yml | 4 ++++ cypress.config.ts | 5 +++++ cypress/e2e/login.cy.ts | 2 ++ cypress/e2e/payment.cy.ts | 2 ++ cypress/e2e/product.cy.ts | 2 ++ cypress/e2e/register.cy.ts | 2 ++ cypress/e2e/store.cy.ts | 2 ++ cypress/e2e/update-product.cy.ts | 2 ++ cypress/e2e/user.cy.ts | 2 ++ cypress/support/commands.ts | 11 +++++++++++ 10 files changed, 34 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9266be..fbbf2e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,10 @@ jobs: TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }} TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }} TEST_USER_PRODUCT_ID: ${{ secrets.TEST_USER_PRODUCT_ID }} + VERCEL_PREVIEW_SESSION_ID: ${{ secrets.VERCEL_PREVIEW_SESSION_ID }} + VERCEL_PREVIEW_VC_SESSION_ID: ${{ secrets.VERCEL_PREVIEW_VC_SESSION_ID }} + VERCEL_PREVIEW_AUTHORISATION_ID: ${{ secrets.VERCEL_PREVIEW_AUTHORISATION_ID }} + VERCEL_PREVIEW_JWT: ${{ secrets.VERCEL_PREVIEW_JWT }} deploy: needs: test diff --git a/cypress.config.ts b/cypress.config.ts index 7715ded..d6d8347 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -17,6 +17,11 @@ export default defineConfig({ user_email: process.env.TEST_USER_EMAIL, user_password: process.env.TEST_USER_PASSWORD, public_url: process.env.CYPRESS_BASE_URL, + + vercel_session_id: process.env.VERCEL_PREVIEW_SESSION_ID, + vercel_vc_session_id: process.env.VERCEL_PREVIEW_VC_SESSION_ID, + vercel_authorisaion_id: process.env.VERCEL_PREVIEW_AUTHORISATION_ID, + vercel_jwt: process.env.VERCEL_PREVIEW_JWT, }, }, }); diff --git a/cypress/e2e/login.cy.ts b/cypress/e2e/login.cy.ts index aa245ba..13c03b2 100644 --- a/cypress/e2e/login.cy.ts +++ b/cypress/e2e/login.cy.ts @@ -1,5 +1,7 @@ describe("Login Form", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.visit(`${Cypress.env("public_url")}/auth/sign-in`); }); diff --git a/cypress/e2e/payment.cy.ts b/cypress/e2e/payment.cy.ts index 8bb046f..f1074a2 100644 --- a/cypress/e2e/payment.cy.ts +++ b/cypress/e2e/payment.cy.ts @@ -1,5 +1,7 @@ describe("Cart and payment", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.login(Cypress.env("user_email"), Cypress.env("user_password")); cy.url({ timeout: 10000 }).should("include", "/"); diff --git a/cypress/e2e/product.cy.ts b/cypress/e2e/product.cy.ts index 39e620e..800e384 100644 --- a/cypress/e2e/product.cy.ts +++ b/cypress/e2e/product.cy.ts @@ -2,6 +2,8 @@ import "cypress-file-upload"; describe("Product Form", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.login(Cypress.env("auth_email"), Cypress.env("auth_password")); cy.get('[data-cy="go-to-store"]', { timeout: 15000 }).should("be.visible"); diff --git a/cypress/e2e/register.cy.ts b/cypress/e2e/register.cy.ts index 2289880..3006575 100644 --- a/cypress/e2e/register.cy.ts +++ b/cypress/e2e/register.cy.ts @@ -1,5 +1,7 @@ describe("Register Form", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.visit(`${Cypress.env("public_url")}/auth/sign-up`); }); diff --git a/cypress/e2e/store.cy.ts b/cypress/e2e/store.cy.ts index f6c213a..51e9acb 100644 --- a/cypress/e2e/store.cy.ts +++ b/cypress/e2e/store.cy.ts @@ -2,6 +2,8 @@ import "cypress-file-upload"; describe("Store Form", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.login(Cypress.env("auth_email"), Cypress.env("auth_password")); cy.get('[data-cy="go-to-store"]', { timeout: 10000 }).should("be.visible"); diff --git a/cypress/e2e/update-product.cy.ts b/cypress/e2e/update-product.cy.ts index 9931c81..8b6bd36 100644 --- a/cypress/e2e/update-product.cy.ts +++ b/cypress/e2e/update-product.cy.ts @@ -4,6 +4,8 @@ const formNum = 1; describe("Update a product", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.login(Cypress.env("auth_email"), Cypress.env("auth_password")); cy.get('[data-cy="go-to-store"]', { timeout: 15000 }).should("be.visible"); diff --git a/cypress/e2e/user.cy.ts b/cypress/e2e/user.cy.ts index 069609e..63abc98 100644 --- a/cypress/e2e/user.cy.ts +++ b/cypress/e2e/user.cy.ts @@ -1,5 +1,7 @@ describe("Users Interactions", () => { beforeEach(() => { + cy.bypassVercelAuth(); + cy.login(Cypress.env("user_email"), Cypress.env("user_password")); cy.url({ timeout: 10000 }).should("include", "/"); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 24c454b..fd02acc 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -13,10 +13,21 @@ declare global { login(email: string, password: string): Chainable; addToCart(): Chainable; removeFromCart(): Chainable; + bypassVercelAuth(): Chainable; } } } +Cypress.Commands.add("bypassVercelAuth", () => { + cy.setCookie("vercel_session_id", `${Cypress.env("vercel_session_id")}`); + + cy.setCookie("authorization", `${Cypress.env("vercel_authorisaion_id")}`); + + cy.setCookie("vc-session-id", `${Cypress.env("vercel_authorisaion_id")}`); + + cy.setCookie("_vercel_jwt", `${Cypress.env("vercel_jwt")}`); +}); + Cypress.Commands.add("login", (email: string, password: string) => { cy.visit(`${Cypress.env("public_url")}/auth/sign-in`);