-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0bb164
commit 14b40d1
Showing
2 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import ms from "ms"; | ||
|
||
import { Account } from "../../../types/accouts"; | ||
|
||
import { fillOutForm } from "../../utils"; | ||
|
||
const CLUSTER_NAME = Cypress.env("CLUSTER_NAME"); | ||
const isAzure = Cypress.env("CLOUD_PROVIDER") === "azure"; | ||
const MAX_TIME_TO_WAIT = Cypress.env("MAX_TIME_TO_WAIT"); | ||
|
||
describe("Test to validate physical cluster creation on Azure", () => { | ||
beforeEach(function () { | ||
if (!isAzure) { | ||
cy.log("This test is only for Azure"); | ||
|
||
this.skip(); | ||
} | ||
}); | ||
|
||
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({ | ||
name: CLUSTER_NAME, | ||
region: /uksouth/i, | ||
intanceSize: /Standard_D2s_v4/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("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(/provisioned/i, { | ||
timeout: Number(ms(MAX_TIME_TO_WAIT)), | ||
}).should("exist"); | ||
}); | ||
}); | ||
}); |