diff --git a/.env.example b/.env.example index 438822c..7169c43 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ CLUSTER_DOMAIN= PASSWORD= USERNAME= -RETRY_DELAY=10000 +RETRY_DELAY=20s CLOUD_PROVIDER= aws| civo MAX_TIME_TO_WAIT=5m RETRIES_RUN_MODE=3 diff --git a/cypress.config.ts b/cypress.config.ts index f8f8e98..f33f028 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from "cypress"; +import ms from "ms"; import "dotenv/config"; import { @@ -30,5 +31,6 @@ export default defineConfig({ applyAtlantisPlan, }); }, + pageLoadTimeout: Number(ms("10m")), }, }); diff --git a/cypress/e2e/atlantis.cy.ts b/cypress/e2e/atlantis.cy.ts index 33f0e8f..5341d9d 100644 --- a/cypress/e2e/atlantis.cy.ts +++ b/cypress/e2e/atlantis.cy.ts @@ -4,7 +4,7 @@ import ms from "ms"; const MAX_TIME_TO_WAIT = Cypress.env("MAX_TIME_TO_WAIT"); describe("Test atlantis is working correctly", () => { - before(() => { + beforeEach(() => { const username = Cypress.env("USERNAME"); const password = Cypress.env("PASSWORD"); @@ -23,7 +23,7 @@ describe("Test atlantis is working correctly", () => { }, }).then((response) => { expect(response.status).to.eq(200); - expect(response.body.length).to.equal(2); + expect(response.body.length).to.greaterThan(0); const [cluster] = response.body; @@ -38,7 +38,7 @@ describe("Test atlantis is working correctly", () => { }); }); - it("should do a login and validate cluster data", async () => { + it("should verify the atlantis is up", async () => { cy.get("@clusterData").then((cluster: any) => { const { subdomain_name: subdomain, domain_name: domain } = cluster; @@ -50,7 +50,7 @@ describe("Test atlantis is working correctly", () => { }); }); - it.only("should create a PR inside the github page", () => { + it("should create a PR inside the github page", () => { cy.get("@clusterData").then(({ git_auth }: any) => { const { gitToken, gitOwner, gitUsername } = camelcaseKeys(git_auth); @@ -79,10 +79,13 @@ describe("Test atlantis is working correctly", () => { }).then(({ createPullRequest }: any) => { if (createPullRequest) { cy.get("@clusterData").then((cluster: any) => { - const { subdomain_name: subdomain, domain_name: domain } = - cluster; + const { + subdomain_name: subdomain, + domain_name: domain, + git_auth: git, + } = cluster; - cy.wait(10000); + cy.wait(20000); if (subdomain) { cy.visit(`https://atlantis.${subdomain}.${domain}`); @@ -90,7 +93,7 @@ describe("Test atlantis is working correctly", () => { cy.visit(`https://atlantis.${domain}`); } - cy.findAllByText(/k1-civo\/gitops/i, { + cy.findAllByText(new RegExp(`${git.git_owner}/gitops`, "i"), { timeout: Number(ms(MAX_TIME_TO_WAIT)), }).should("exist"); @@ -105,7 +108,9 @@ describe("Test atlantis is working correctly", () => { if (apply) { cy.wait(50000); cy.reload(); - cy.findAllByText(/k1-civo\/gitops/i).should("not.exist"); + cy.findAllByText( + new RegExp(`${git.git_owner}/gitops`, "i") + ).should("not.exist"); } }); }); diff --git a/cypress/e2e/create/physical-cluster.civo.cy.ts b/cypress/e2e/create/physical-cluster.civo.cy.ts index b1ab1a2..b36b8e3 100644 --- a/cypress/e2e/create/physical-cluster.civo.cy.ts +++ b/cypress/e2e/create/physical-cluster.civo.cy.ts @@ -82,7 +82,7 @@ describe("Test to validate physical cluster creation", () => { cy.contains("Provisioning").should("exist"); }); - it.skip("should validate the cluster is provisioning", () => { + it("should validate the cluster is provisioning", () => { cy.visit("/"); cy.goClusters(); diff --git a/cypress/support/hooks.ts b/cypress/support/hooks.ts index 247fab5..8a1b0d2 100644 --- a/cypress/support/hooks.ts +++ b/cypress/support/hooks.ts @@ -1,7 +1,9 @@ +import ms from "ms"; + afterEach(function () { if (this.currentTest.state === "failed") { - const retryDelay = Cypress.env("RETRY_DELAY"); + const retryDelay = Number(ms(Cypress.env("RETRY_DELAY"))); - cy.wait(+retryDelay); + cy.wait(retryDelay); } });