Skip to content

Commit

Permalink
cluster tools tests (rancher#9749)
Browse files Browse the repository at this point in the history
* cluster tools tests

* skip edit & delete tests until resolution of rancher#9940
  • Loading branch information
yonasberhe23 authored Nov 2, 2023
1 parent 5bdb58c commit 2437111
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/po/pages/explorer/cluster-dashboard.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export default class ClusterDashboardPagePo extends PagePo {
constructor(clusterId: string) {
super(ClusterDashboardPagePo.createPath(clusterId));
}

clusterToolsButton(): Cypress.Chainable {
return cy.get('.tools-button').contains('Cluster Tools');
}
}
39 changes: 39 additions & 0 deletions cypress/e2e/po/pages/explorer/cluster-tools.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';

export default class ClusterToolsPagePo extends PagePo {
private static createPath(clusterId: string) {
return `/c/${ clusterId }/explorer/tools`;
}

static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(ClusterToolsPagePo.createPath(clusterId));
}

constructor(clusterId: string) {
super(ClusterToolsPagePo.createPath(clusterId));
}

featureChartCards(): Cypress.Chainable {
return cy.get('.grid > .item');
}

getCardByIndex(index: number): Cypress.Chainable {
return this.featureChartCards().eq(index);
}

goToInstall(index: number) {
return this.getCardByIndex(index).find('.btn').contains('Install').click();
}

deleteChart(index: number) {
return this.getCardByIndex(index).find('.action .btn').eq(0).click();
}

editChart(index: number) {
return this.getCardByIndex(index).find('.action .btn').eq(1).click();
}

getChartVersion(index: number) {
return this.getCardByIndex(index).find('.version');
}
}
24 changes: 24 additions & 0 deletions cypress/e2e/po/pages/explorer/install-charts.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po';

export class InstallChartsPage extends PagePo {
private static createPath(clusterId: string) {
return `/c/${ clusterId }/apps/charts/install`;
}

static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(InstallChartsPage.createPath(clusterId));
}

constructor(clusterId: string) {
super(InstallChartsPage.createPath(clusterId));
}

nextPage() {
return cy.get('.controls-steps').contains('Next').click();
}

installChart(): AsyncButtonPo {
return new AsyncButtonPo('[data-testid="action-button-async-button"]', this.self());
}
}
78 changes: 78 additions & 0 deletions cypress/e2e/tests/pages/explorer/cluster-tools.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import ClusterToolsPagePo from '@/cypress/e2e/po/pages/explorer/cluster-tools.po';
import ClusterDashboardPagePo from '@/cypress/e2e/po/pages/explorer/cluster-dashboard.po';
import { InstallChartsPage } from '@/cypress/e2e/po/pages/explorer/install-charts.po';
import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po';

const clusterTools = new ClusterToolsPagePo('local');

describe('Cluster Tools', { tags: '@adminUser' }, () => {
beforeEach(() => {
cy.login();
});

it('can navigate to cluster tools and see all feature charts', () => {
const clusterDashboard = new ClusterDashboardPagePo('local');

clusterDashboard.goTo();
clusterDashboard.waitForPage();
clusterDashboard.clusterToolsButton().click();

clusterTools.waitForPage();
clusterTools.featureChartCards().should('have.length.gte', 10);
});

it('can deploy chart successfully', () => {
clusterTools.goTo();
clusterTools.waitForPage();
clusterTools.getChartVersion(0).invoke('text').then((el) => {
const chartVersion = el.trim().slice(1);

const chartType = 'rancher-alerting-drivers';
const installAlertingDriversPage = `repo-type=cluster&repo=rancher-charts&chart=${ chartType }&version=${ chartVersion }&tools`;
const installCharts = new InstallChartsPage('local');

clusterTools.goToInstall(0);
installCharts.waitForPage(installAlertingDriversPage);
installCharts.nextPage();

cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as('chartInstall');
installCharts.installChart().click();
cy.wait('@chartInstall').its('response.statusCode').should('eq', 201);
clusterTools.waitForPage();
cy.contains('Connected');
});
});

it.skip('can edit chart successfully', () => {
// Note: this test fails due to https://github.com/rancher/dashboard/issues/9940
// skipping this test until issue is resolved
clusterTools.goTo();
clusterTools.waitForPage();
clusterTools.editChart(0);

const installCharts = new InstallChartsPage('local');

installCharts.nextPage();

cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=upgrade').as('chartUpdate');
installCharts.installChart().click();
cy.wait('@chartUpdate').its('response.statusCode').should('eq', 201);
clusterTools.waitForPage();
cy.contains('Connected');
});

it.skip('can uninstall chart successfully', () => {
// Note: this test fails due to https://github.com/rancher/dashboard/issues/9940
// skipping this test until issue is resolved
clusterTools.goTo();
clusterTools.waitForPage();
clusterTools.deleteChart(0);

const promptRemove = new PromptRemove();

cy.intercept('POST', '/v1/catalog.cattle.io.apps/default/rancher-alerting-drivers?action=uninstall').as('chartUninstall');
promptRemove.remove();
cy.wait('@chartUninstall').its('response.statusCode').should('eq', 201);
cy.contains('Disconnected');
});
});

0 comments on commit 2437111

Please sign in to comment.