From 2437111739c459899688d78d8bad6cb7c78de3ec Mon Sep 17 00:00:00 2001 From: yonasberhe23 Date: Thu, 2 Nov 2023 11:37:43 -0700 Subject: [PATCH] cluster tools tests (#9749) * cluster tools tests * skip edit & delete tests until resolution of https://github.com/rancher/dashboard/issues/9940 --- .../po/pages/explorer/cluster-dashboard.po.ts | 4 + .../e2e/po/pages/explorer/cluster-tools.po.ts | 39 ++++++++++ .../po/pages/explorer/install-charts.po.ts | 24 ++++++ .../pages/explorer/cluster-tools.spec.ts | 78 +++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 cypress/e2e/po/pages/explorer/cluster-tools.po.ts create mode 100644 cypress/e2e/po/pages/explorer/install-charts.po.ts create mode 100644 cypress/e2e/tests/pages/explorer/cluster-tools.spec.ts diff --git a/cypress/e2e/po/pages/explorer/cluster-dashboard.po.ts b/cypress/e2e/po/pages/explorer/cluster-dashboard.po.ts index 1fde1eb3671..8590564d6e2 100644 --- a/cypress/e2e/po/pages/explorer/cluster-dashboard.po.ts +++ b/cypress/e2e/po/pages/explorer/cluster-dashboard.po.ts @@ -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'); + } } diff --git a/cypress/e2e/po/pages/explorer/cluster-tools.po.ts b/cypress/e2e/po/pages/explorer/cluster-tools.po.ts new file mode 100644 index 00000000000..968c03c9fb1 --- /dev/null +++ b/cypress/e2e/po/pages/explorer/cluster-tools.po.ts @@ -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 { + 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'); + } +} diff --git a/cypress/e2e/po/pages/explorer/install-charts.po.ts b/cypress/e2e/po/pages/explorer/install-charts.po.ts new file mode 100644 index 00000000000..c14be76f0d5 --- /dev/null +++ b/cypress/e2e/po/pages/explorer/install-charts.po.ts @@ -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 { + 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()); + } +} diff --git a/cypress/e2e/tests/pages/explorer/cluster-tools.spec.ts b/cypress/e2e/tests/pages/explorer/cluster-tools.spec.ts new file mode 100644 index 00000000000..a210c37df72 --- /dev/null +++ b/cypress/e2e/tests/pages/explorer/cluster-tools.spec.ts @@ -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'); + }); +});