Skip to content

Commit

Permalink
✅ chore: the first steps to the cluster creaion were added
Browse files Browse the repository at this point in the history
  • Loading branch information
futjesus committed Dec 11, 2024
1 parent 78483a2 commit d070b72
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 5 deletions.
85 changes: 85 additions & 0 deletions cypress/e2e/physical-cluster.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { Account } from "../../types/accouts";

// Utility function to fill out the form to create a physical cluster
const fillOutForm = () => {
cy.get("form").as("form");
cy.get("@form").should("exist");

cy.findByRole("textbox").type("test-cluster", {
delay: 10,
});

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

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

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

cy.findByRole("listbox").within(() => {
cy.findByRole("option", { name: /default/i }).click();
});

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

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

cy.findByRole("listbox").within(() => {
cy.findByRole("option", { name: /us-east-1/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();
});
};

describe("Test to validate physical cluster creation", () => {
beforeEach(() => {
const username = Cypress.env("USERNAME");
const password = Cypress.env("PASSWORD");

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

it("should create a physical cluster", () => {
cy.visit("/");
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("@button").click();

fillOutForm();

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

cy.wait(2000);

cy.findByRole("heading", { name: /test-cluster/i }).should("exist");
cy.contains("Provisioning").should("exist");
});
});
9 changes: 4 additions & 5 deletions cypress/support/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
afterEach(function () {
if (this.currentTest.state === "failed") {
const retryDelay = Cypress.env("RETRY_DELAY");

cy.wait(+retryDelay);
}
// if (this.currentTest.isFailed()) {
// const retryDelay = Cypress.env("RETRY_DELAY");
// cy.wait(+retryDelay);
// }
});
34 changes: 34 additions & 0 deletions types/accouts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export type Account = {
id: string;
name: string;
creation_timestamp: string;
is_enabled: boolean;
type: string;
is_default: boolean;
auth: Auth;
};

export type Auth = {
akamai_auth: AkamaiAuthClass;
aws_auth: AwsAuth;
civo_auth: AkamaiAuthClass;
do_auth: DoAuth;
vultr_auth: AkamaiAuthClass;
google_auth: GoogleAuth;
};

export type AkamaiAuthClass = {
token: string;
};

export type AwsAuth = {
role_arn: string;
};

export type DoAuth = {
token: string;
spaces_key: string;
spaces_secret: string;
};

export type GoogleAuth = {};

0 comments on commit d070b72

Please sign in to comment.