Skip to content

Commit

Permalink
✅ feat: add Digital Ocean form handling and validation tests for phys…
Browse files Browse the repository at this point in the history
…ical cluster creation
  • Loading branch information
futjesus committed Jan 8, 2025
1 parent 91fd7a5 commit 4c898b8
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
84 changes: 84 additions & 0 deletions cypress/e2e/create/physical-cluster.do.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import ms from "ms";

import { PhysicalCluster } from "../../utils/create-cluster/physical";

const CLUSTER_NAME = Cypress.env("CLUSTER_NAME");
const cloudProvider = Cypress.env("CLOUD_PROVIDER");
const MAX_TIME_TO_WAIT = Cypress.env("MAX_TIME_TO_WAIT");
const isDigitalOcean = cloudProvider === "do";

describe("Test to validate physical cluster creation on Digital Ocean", () => {
const physicalCluster = new PhysicalCluster();

beforeEach(function () {
if (!isDigitalOcean) {
cy.log("This test is only for Digital Ocean");

this.skip();
}
});

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

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

it.skip("should create a physical cluster", async () => {
physicalCluster.visitClusterPage();

physicalCluster.clickOnWorkloadClusterButton();

const region = physicalCluster.getRegion("digitalocean");

region.then((region) => {
physicalCluster.filloutDigitalOceanForm({
name: CLUSTER_NAME,
region: new RegExp(region, "i"),
intanceSize: new RegExp("s-1vcpu-1gb", "i"),
});

physicalCluster.clickOnCreateCluster();

cy.wait(2000);

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

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

it("should validate the cluster is provisioning", () => {
physicalCluster.visitClusterPage();

const provisioningButton =
physicalCluster.getClusterProvisioningStatusButton(CLUSTER_NAME);

provisioningButton.should("exist");

provisioningButton.within(() => {
cy.findByText(/provisioning/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
});

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

const provisioningButton =
physicalCluster.getClusterProvisioningStatusButton(CLUSTER_NAME);

provisioningButton.should("exist");

provisioningButton.within(() => {
cy.findByText(/available/i, {
timeout: Number(ms(MAX_TIME_TO_WAIT)),
}).should("exist");
});
});
});
32 changes: 32 additions & 0 deletions cypress/utils/create-cluster/physical/Physical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class PhysicalCluster extends PhysicalClusterClass {
new RegExp(`${clusterName}:(.*?)(?=nodes:)`, "i")
);

cy.log(`Region gotten: ${region}`);

cy.wrap(region.at(1)).as("region");
});

Expand Down Expand Up @@ -174,6 +176,36 @@ export class PhysicalCluster extends PhysicalClusterClass {
cy.log("Filled out Akamai form");
}

filloutDigitalOceanForm({ name, region, intanceSize }) {
cy.log("Filling out Digital Ocean form");

cy.get("form").should("exist");

cy.findByRole("radio", { name: /physical/i }).click();

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

cy.findAllByRole("combobox").eq(1).as("clusterRegion");

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

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

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

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

cy.findByRole("listbox").within(() => {
cy.findAllByRole("option", { name: intanceSize }).eq(0).click();
});

cy.log("Filled out Digital Ocean form");
}

getClusterProvisioningStatusButton(
clusterName: string
): Cypress.Chainable<JQuery<HTMLElement>> {
Expand Down
5 changes: 5 additions & 0 deletions cypress/utils/create-cluster/physical/Physical.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export abstract class PhysicalClusterClass {
region,
intanceSize,
}: ClusterOptions): void;
abstract filloutDigitalOceanForm({
name,
region,
intanceSize,
}: ClusterOptions): void;
abstract filloutCivoForm({ name, region, intanceSize }: ClusterOptions): void;
abstract filloutAWSForm({ name, region, intanceSize }: ClusterOptions): void;
abstract getClusterProvisioningStatusButton(
Expand Down

0 comments on commit 4c898b8

Please sign in to comment.