Skip to content

Commit

Permalink
Added in tests to validate that the Harvester dashboard can be reache…
Browse files Browse the repository at this point in the history
…d from Rancher, and fixed some missing semicolons.

changed timeouts to use constants instead of hard coded timeouts

changed back dashboard pageobject to be the way it was and added in a different virtualizationDashboard pageobject

Added in a log for outputting the product and clustername
  • Loading branch information
noahgildersleeve authored and khushboo-rancher committed Apr 10, 2024
1 parent 0738efb commit 0cf7b78
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 16 deletions.
8 changes: 3 additions & 5 deletions cypress/cypress.env.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
"mockPassword": "mockPassword",
"baseUrl": "https://online-server",
"rancherUrl": "https://rancher-server",
"rancher_user": "admin",
"rancher_password": "admin",
"rancher_vm_user": "vagrant",
"rancher_vm_password": "vagrant",
"vagrant_pxe_path": "../ipxe-examples/vagrant-pxe-harvester",
"rancherUser": "admin",
"rancherPassword": "admin",
"rancherBootstrapPassword": "admin",
"host":
{
"name": "",
Expand Down
16 changes: 8 additions & 8 deletions cypress/pageobjects/login.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class LoginPage {
private checkboxTelemetry = '[for="checkbox-telemetry"]';
private allRadios = '.radio-container';
private checkbox = '.checkbox-custom';
private mainPageHeader = 'main .outlet header h1 span'
private mainPageHeader = 'main .outlet header h1 span';

public username: string;
public password: string;
Expand Down Expand Up @@ -69,9 +69,9 @@ export class LoginPage {
public login(username:string = this.username, password:string = this.password) {
cy.visit(constants.loginUrl);
cy.get(this.usernameInput).type(username);
cy.get(this.passwordInput).type(password)
cy.get(this.loginButton).click()
this.validateLogin()
cy.get(this.passwordInput).type(password);
cy.get(this.loginButton).click();
this.validateLogin();
}
/**
* Parameters may be declared in a variety of syntactic forms
Expand Down Expand Up @@ -99,9 +99,9 @@ export class LoginPage {
public checkEula(checked:boolean = true) {
cy.get(`${this.checkboxEula} ${this.checkbox}`).then($el => {
if(!!$el.attr("aria-checked") === checked) {
cy.get(this.checkboxEula)
cy.get(this.checkboxEula);
} else {
cy.get(this.checkboxEula).click("left")
cy.get(this.checkboxEula).click("left");
}
})
return this
Expand All @@ -110,9 +110,9 @@ export class LoginPage {
public checkTelemetry(checked:boolean = true) {
cy.get(`${this.checkboxTelemetry} ${this.checkbox}`).then($el => {
if (!!$el.attr("aria-checked") === checked) {
cy.get(this.checkboxTelemetry)
cy.get(this.checkboxTelemetry);
} else {
cy.get(this.checkboxTelemetry).click("left")
cy.get(this.checkboxTelemetry).click("left");
}
})
return this
Expand Down
12 changes: 11 additions & 1 deletion cypress/pageobjects/rancher.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class rancherPage {

private clusterManagement_page_create = '[href="/dashboard/c/local/manager/provisioning.cattle.io.cluster/create"]';
private clusterManagement_rke_selector = '.slider';
private clusterLink = '.cluster-link a';

private clusterCreation_page_harvester = ':nth-child(4) > .name';

Expand Down Expand Up @@ -178,6 +179,15 @@ export class rancherPage {
cy.visit(constants.rancher_virtualizationManagement);
}

public open_virtualizationDashboard() {
cy.visit(constants.rancher_virtualizationManagement).then(() => {
cy.log('visit virtualizationManagement');
});
cy.get(this.clusterLink).click().then(() => {
cy.log('Open virtualization dashboard');
});
}

public visit_clusterManagement() {
cy.visit(constants.rancher_clusterManagmentPage);
}
Expand All @@ -200,7 +210,7 @@ export class rancherPage {
cy.get(this.virtual_page_createCluster).should('contain', 'Create').click();
cy.visit(constants.virtualManagePage + '/create#memberRoles');

cy.contains(constants.rancherUrl, { timeout: 5000 });
cy.contains(constants.rancherUrl, { timeout: constants.timeout.timeout });

return cy.get('.copy');

Expand Down
25 changes: 25 additions & 0 deletions cypress/pageobjects/virtualizationDashboard.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default class VirtualizationDashboard {

private clusterName = '.cluster-name';
private productName = '.product-name';

public validateClusterName() {
cy.get(this.clusterName).should('exist').then(() => {
cy.log('Cluster Name Exists');
cy.get(this.clusterName).then((elem) => {
const textValue = elem.text();
cy.log('Cluster Name is ' + textValue)
});
});
}

public validateProductName() {
cy.get(this.productName).should('exist').then(() => {
cy.log('Product Name Exists');
cy.get(this.productName).then((elem) => {
const textValue = elem.text();
cy.log('Product Name is ' + textValue)
});
});
}
}
23 changes: 21 additions & 2 deletions cypress/testcases/rancher/rancher_integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { Constants } from '../../constants/constants'
import cypress from 'cypress';
import { LoginPage } from "@/pageobjects/login.po";
import { onlyOn } from "@cypress/skip-test";
import VirtualizationDashboard from "~/pageobjects/virtualizationDashboard.po";

const constants = new Constants();
const rancher = new rancherPage();
const rke_guest_cluster = new rke_guest_clusterPage();
const image = new ImagePage();
const settings = new SettingsPagePo();
const network = new NetworkPage();

const virtualizationDashboard = new VirtualizationDashboard();
let rData = {
name: '',
harvester_cluster_name: '',
Expand Down Expand Up @@ -138,12 +139,30 @@ describe('Harvester import Rancher', function () {
it('Check Harvester Cluster Status', { baseUrl: constants.rancherUrl }, () => {
// cy.login();
cy.visit('/');
cy.wait(5000);
cy.wait(constants.timeout.timeout);

rancher.rancherLogin();

rancher.visit_virtualizationManagement();

rancher.checkState(rData.harvester_cluster_name);
});

it('Check Rancher Harvester dashboard', { baseUrl: constants.rancherUrl }, () => {
// cy.login();
cy.visit('/');
cy.wait(constants.timeout.timeout);

rancher.rancherLogin();

rancher.visit_virtualizationManagement();

rancher.checkState(rData.harvester_cluster_name);

rancher.open_virtualizationDashboard();

virtualizationDashboard.validateClusterName();

});

})

0 comments on commit 0cf7b78

Please sign in to comment.