Skip to content

Commit

Permalink
✅ chore: new steps for civo cluster creatiopn were added
Browse files Browse the repository at this point in the history
  • Loading branch information
futjesus committed Dec 16, 2024
1 parent 1279f1a commit bc4d3e6
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ms from "ms";

import { Account } from "../../types/accouts";
import { Account } from "../../../types/accouts";

import { fillOutForm } from "./utils";
import { fillOutForm } from "../../utils";

const CLUSTER_NAME = "test-cluster";
const isAWS = Cypress.env("CLOUD_PROVIDER") === "aws";
Expand Down Expand Up @@ -51,7 +51,11 @@ describe("Test to validate physical cluster creation on AWS", () => {

cy.get("@button").click();

fillOutForm(CLUSTER_NAME);
fillOutForm({
name: CLUSTER_NAME,
region: /us-east-1/i,
intanceSize: /t2.nano/i,
});

cy.findByRole("button", {
name: /create cluster/i,
Expand All @@ -68,7 +72,7 @@ describe("Test to validate physical cluster creation on AWS", () => {
it("should validate the cluster is provisioning", () => {
cy.visit("/");

cy.goClusterManagement();
cy.goClusters();

cy.findAllByRole("button", { name: new RegExp(CLUSTER_NAME, "i") })
.eq(0)
Expand All @@ -84,7 +88,7 @@ describe("Test to validate physical cluster creation on AWS", () => {
it("should validate the cluster is provisioned", { retries: 3 }, () => {
cy.visit("/");

cy.goClusterManagement();
cy.goClusters();

cy.findAllByRole("button", { name: new RegExp(CLUSTER_NAME, "i") })
.eq(0)
Expand Down
118 changes: 118 additions & 0 deletions cypress/e2e/create/physical-cluster.civo.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import ms from "ms";

import { Account } from "../../../types/accouts";

import { fillOutForm } from "../../utils";

const CLUSTER_NAME = "test-cluster";
const isCivo = Cypress.env("CLOUD_PROVIDER") === "civo";
const MAX_TIME_TO_WAIT = Cypress.env("MAX_TIME_TO_WAIT");

describe("Test to validate physical cluster creation", () => {
beforeEach(function () {
if (!isCivo) {
cy.log("This test is only for Civo");

this.skip();
}
});

beforeEach(() => {
const username = Cypress.env("USERNAME");
const password = Cypress.env("PASSWORD");

cy.login(username, password);
});

it.skip("should create a physical cluster", () => {
cy.visit("/");

cy.goClusters();

cy.findByRole("button", { name: /add workload cluster/i }).as("button");

cy.request("GET", "/api/proxy?url=%2Fcloud-account").then(
({ status, body }) => {
expect(status).to.eq(200);

const { cloud_accounts: cloudAccounts } = body;
cy.wrap(cloudAccounts as Account[]).as("accounts");
}
);

cy.get("@accounts").then((accounts) => {
const cloudAccounts = accounts as unknown as Account[];
expect(cloudAccounts).to.be.an("array");
expect(cloudAccounts).to.have.length.greaterThan(0);

const defaultAccount = cloudAccounts.find(
(account) => account.name === "default"
);

expect(defaultAccount).to.exist;
});

cy.get(".management-cluster").invoke("text").as("mainCluster");

cy.get("@mainCluster").then((mainClusterText: unknown) => {
const region = (mainClusterText as string).match(/civo:(.*?)(?=nodes:)/i);
cy.wrap(region.at(1)).as("region");
});

cy.get("@region").then((region: unknown) => {
cy.get("@button").click();

fillOutForm({
name: CLUSTER_NAME,
region: new RegExp(region as string, "i"),
intanceSize: new RegExp("g4s.kube.small", "i"),
});
});

cy.findByRole("button", {
name: /create cluster/i,
}).click();

cy.wait(2000);

cy.findByRole("heading", { name: new RegExp(CLUSTER_NAME, "i") }).should(
"exist"
);

cy.contains("Provisioning").should("exist");
});

it.skip("should validate the cluster is provisioning", () => {
cy.visit("/");

cy.goClusters();

cy.findAllByRole("button", { name: new RegExp(CLUSTER_NAME, "i") })
.eq(0)
.as("clusterProvisioningButton");

cy.get("@clusterProvisioningButton").should("exist");

cy.get("@clusterProvisioningButton").within(() => {
cy.findByText(/provisioning/i).should("exist");
});
});

it("should validate the cluster is provisioned", { retries: 3 }, () => {
cy.visit("/");

cy.goClusters();

cy.findAllByRole("button", { name: new RegExp(CLUSTER_NAME, "i") })
.eq(0)
.as("clusterProvisionedButton");

cy.get("@clusterProvisionedButton").should("exist");

cy.get("@clusterProvisionedButton").within(() => {
cy.findByText(/available/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
});
});
64 changes: 0 additions & 64 deletions cypress/e2e/physical-cluster.civo.cy.ts

This file was deleted.

6 changes: 3 additions & 3 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare global {
interface Chainable<Subject = any> {
login(username: string, password: string): Chainable<void>;
goApplications(): Chainable<void>;
goClusterManagement(): Chainable<void>;
goClusters(): Chainable<void>;
}
}
}
Expand Down Expand Up @@ -38,7 +38,7 @@ Cypress.Commands.add("goApplications", () => {
cy.findByRole("link", { name: /applications/i }).click();
});

Cypress.Commands.add("goClusterManagement", () => {
Cypress.Commands.add("goClusters", () => {
cy.visit("/");
cy.findByRole("link", { name: /cluster management/i }).click();
cy.findByRole("link", { name: /clusters/i }).click();
});
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
export const fillOutForm = (clusterName: string) => {
type ClusterOptions = {
name: string;
region: RegExp;
intanceSize: RegExp;
};

export const fillOutForm = ({ name, region, intanceSize }: ClusterOptions) => {
cy.get("form").as("form");
cy.get("@form").should("exist");

cy.findByRole("textbox").type(clusterName, {
cy.findByRole("textbox").type(name, {
delay: 10,
});

Expand All @@ -21,14 +27,14 @@ export const fillOutForm = (clusterName: string) => {
cy.get("@clusterRegion").click();

cy.findByRole("listbox").within(() => {
cy.findByRole("option", { name: /us-east-1/i }).click();
cy.findByRole("option", { name: new RegExp(region, "i") }).click();
});

cy.findAllByRole("combobox").eq(3).as("instanceSize");

cy.get("@instanceSize").click();

cy.findByRole("listbox").within(() => {
cy.findByRole("option", { name: /t2.nano/i }).click();
cy.findByRole("option", { name: intanceSize }).click();
});
};
File renamed without changes.

0 comments on commit bc4d3e6

Please sign in to comment.