Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cypress] Fix failed rancher integration tests #1281

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions cypress/pageobjects/rancher.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export class rancherPage {
private boostrap_page_newPWRepeat = '[style=""] > .labeled-input > input';
// private boostrap_page_checkAgreeEULA = '#checkbox-eula > .checkbox-container > .checkbox-custom';
private boostrap_page_checkAgreeEULA = '[data-testid="setup-agreement"] > .checkbox-container > .checkbox-custom';
private boostrap_page_confirmLogin = '.btn > span';
// private boostrap_page_confirmLogin = '.btn > span';
private boostrap_page_confirmLogin = 'button[data-testid="setup-submit"]';
private home_page_mainMenu = '.menu';
private home_page_virtualManagement = ':nth-child(7) > .option > div';

Expand Down Expand Up @@ -111,9 +112,9 @@ export class rancherPage {
cy.intercept('GET', '/v1/management.cattle.io.setting?exclude=metadata.managedFields').as('getFirstLogin')
.visit("/")
.wait('@getFirstLogin').then(login => {
const data: any[] = login.response?.body.data;
const firstLogin = data.find(v => v?.id === "first-login");
resolve(firstLogin.value === 'true');
const data: any[] = login.response?.body.data;
const firstLogin = data.find(v => v?.id === "first-login");
resolve(firstLogin.value === 'true');
})
.end();
});
Expand All @@ -123,23 +124,23 @@ export class rancherPage {
* First time login using ssh
*/
public firstTimeLogin() {
cy.get(this.boostrap_page_boostrapPWInput).type(Cypress.env('rancherBootstrapPassword')).log('Input bootstrap secret');
cy.get(this.boostrap_page_boostrapPWSubmit).click();
cy.get(this.boostrap_page_boostrapPWInput).type(Cypress.env('rancherBootstrapPassword')).log('Input bootstrap secret');
cy.get(this.boostrap_page_boostrapPWSubmit).click();

// cy.log('Select a specific password to use')
cy.get(this.boostrap_page_radioSelectPW).click().log('Select a specific password to use');
// // cy.log('Select a specific password to use')
// cy.get(this.boostrap_page_radioSelectPW).click().log('Select a specific password to use');

// cy.log('Input new password')
cy.get(this.boostrap_page_newPWInput).type(constants.rancher_password).log('Input new password');
// cy.log('Confirm password again')
cy.get(this.boostrap_page_newPWRepeat).type(constants.rancher_password).log('Confirm password again');
// // cy.log('Input new password')
// cy.get(this.boostrap_page_newPWInput).type(constants.rancher_password).log('Input new password');
// // cy.log('Confirm password again')
// cy.get(this.boostrap_page_newPWRepeat).type(constants.rancher_password).log('Confirm password again');

// cy.log('Agree EULA')
cy.get(this.boostrap_page_checkAgreeEULA).click().log('Agree EULA');
// cy.log('Agree EULA')
cy.get(this.boostrap_page_checkAgreeEULA).click().log('Agree EULA');

cy.get(this.boostrap_page_confirmLogin).click().log('Continue to access rancher');
cy.get(this.boostrap_page_confirmLogin).click().log('Continue to access rancher');

cy.url().should('include', 'dashboard/home').log('Login Success');
cy.url().should('include', 'dashboard/home').log('Login Success');
}

/**
Expand Down Expand Up @@ -186,7 +187,7 @@ export class rancherPage {
cy.get(this.clusterLink).click().then(() => {
cy.log('Open virtualization dashboard');
});
}
}

public visit_clusterManagement() {
cy.visit(constants.rancher_clusterManagmentPage);
Expand All @@ -202,8 +203,8 @@ export class rancherPage {

public importHarvester() {
cy.visit('/home')
cy.get(this.home_page_mainMenu).click();
cy.get(this.home_page_virtualManagement).should('contain', 'Virtualization Management').click();
// cy.get(this.home_page_mainMenu).click();
// cy.get(this.home_page_virtualManagement).should('contain', 'Virtualization Management').click();
cy.visit(constants.virtualManagePage)
cy.get(this.virtual_page_importButton).should('contain', 'Import Existing').click();
cy.get(this.virtual_page_clusterName).type('harvester')
Expand Down
36 changes: 33 additions & 3 deletions cypress/testcases/rancher/rancher_integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,40 @@ describe('Harvester import Rancher', function () {
});
})

let isHarvFirstTimeLogin: boolean = false;
before(async () => {
isHarvFirstTimeLogin = await LoginPage.isFirstTimeLogin();

})

it('Harvester import Rancher', () => {
cy.login();
// cy.login();
if (isHarvFirstTimeLogin) {
const page = new LoginPage();
page.visit()
.selectSpecificPassword()
.checkTelemetry(false)
.checkEula(true)
.inputPassword()
.submitBtn.click();

page.validateLogin();
} else {
cy.login();
}
rancher.registerRancher();
});

})

describe('Rancher integration', function () {
beforeEach(() => {
cy.fixture('rancher').then((data) => {
rData = data;
});
})


it('Check Harvester Cluster Status', { baseUrl: constants.rancherUrl }, () => {
// cy.login();
cy.visit('/');
Expand All @@ -162,7 +191,8 @@ describe('Harvester import Rancher', function () {
rancher.open_virtualizationDashboard();

virtualizationDashboard.validateClusterName();

});

})
})