diff --git a/cypress/e2e/po/other-products/logging/logging-clusterflow-po.ts b/cypress/e2e/po/other-products/logging/logging-clusterflow-po.ts new file mode 100644 index 00000000000..c9f4a31183b --- /dev/null +++ b/cypress/e2e/po/other-products/logging/logging-clusterflow-po.ts @@ -0,0 +1,82 @@ +import PagePo from '@/cypress/e2e/po/pages/page.po'; +import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po'; +import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; +import TabbedPo from '@/cypress/e2e/po/components/tabbed.po'; +import ResourceListMastheadPo from '@/cypress/e2e/po/components/ResourceList/resource-list-masthead.po'; +import NameNsDescription from '@/cypress/e2e/po/components/name-ns-description.po'; +import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po'; +import ArrayListPo from '@/cypress/e2e/po/components/array-list.po'; + +export class LoggingClusterflowListPagePo extends PagePo { + private static createPath(clusterId: string) { + return `/c/${ clusterId }/logging/logging.banzaicloud.io.clusterflow`; + } + + static goTo(clusterId: string): Cypress.Chainable { + return super.goTo(LoggingClusterflowListPagePo.createPath(clusterId)); + } + + constructor(clusterId = 'local') { + super(LoggingClusterflowListPagePo.createPath(clusterId)); + } + + masthead() { + return new ResourceListMastheadPo(this.self()); + } + + createLoggingFlow() { + return this.masthead().create(); + } + + listElementWithName(name:string) { + const baseResourceList = new BaseResourceList(this.self()); + + return baseResourceList.resourceTable().sortableTable().rowElementWithName(name); + } + + rowLinkWithName(name: string) { + const baseResourceList = new BaseResourceList(this.self()); + + return baseResourceList.resourceTable().sortableTable().detailsPageLinkWithName(name); + } +} + +export class LoggingClusterflowEditPagePo extends PagePo { + static url: string; + + private static createPath( clusterId: string, name: string ) { + const urlStr = `/c/${ clusterId }/logging/logging.banzaicloud.io.clusterflow/${ name }#`; + + return urlStr; + } + + static goTo(): Cypress.Chainable { + return super.goTo(this.url); + } + + constructor(clusterId = 'local', name = 'create') { + super(LoggingClusterflowEditPagePo.createPath(clusterId, name)); + + LoggingClusterflowEditPagePo.url = LoggingClusterflowEditPagePo.createPath(clusterId, name); + } + + nameNsDescription() { + return new NameNsDescription(this.self()); + } + + outputsTab() { + return new TabbedPo().clickTabWithSelector('[data-testid="btn-outputs"]'); + } + + outputSelector() { + return new LabeledSelectPo('section#outputs .labeled-select'); + } + + saveCreateForm(): AsyncButtonPo { + return new AsyncButtonPo('[data-testid="form-save"]', this.self()); + } + + ruleItem(index: number) { + return new ArrayListPo(this.self()).arrayListItem(index); + } +} diff --git a/cypress/e2e/po/other-products/logging/logging-clusteroutput.po.ts b/cypress/e2e/po/other-products/logging/logging-clusteroutput.po.ts new file mode 100644 index 00000000000..6d96dcea72b --- /dev/null +++ b/cypress/e2e/po/other-products/logging/logging-clusteroutput.po.ts @@ -0,0 +1,76 @@ +import PagePo from '@/cypress/e2e/po/pages/page.po'; +import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po'; +import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; +import TabbedPo from '@/cypress/e2e/po/components/tabbed.po'; +import ResourceListMastheadPo from '@/cypress/e2e/po/components/ResourceList/resource-list-masthead.po'; +import NameNsDescription from '@/cypress/e2e/po/components/name-ns-description.po'; +import SelectPo from '@/cypress/e2e/po/components/select.po'; +import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po'; + +export class LoggingClusteroutputListPagePo extends PagePo { + private static createPath(clusterId: string) { + return `/c/${ clusterId }/logging/logging.banzaicloud.io.clusteroutput`; + } + + static goTo(clusterId: string): Cypress.Chainable { + return super.goTo(LoggingClusteroutputListPagePo.createPath(clusterId)); + } + + constructor(clusterId = 'local') { + super(LoggingClusteroutputListPagePo.createPath(clusterId)); + } + + masthead() { + return new ResourceListMastheadPo(this.self()); + } + + createLoggingOutput() { + return this.masthead().create(); + } + + listElementWithName(name:string) { + const baseResourceList = new BaseResourceList(this.self()); + + return baseResourceList.resourceTable().sortableTable().rowElementWithName(name); + } +} + +export class LoggingClusteroutputEditPagePo extends PagePo { + static url: string; + + private static createPath( clusterId: string, name: string ) { + const urlStr = `/c/${ clusterId }/logging/logging.banzaicloud.io.clusteroutput/${ name }#`; + + return urlStr; + } + + static goTo(): Cypress.Chainable { + return super.goTo(this.url); + } + + constructor(clusterId = 'local', name = 'create') { + super(LoggingClusteroutputEditPagePo.createPath(clusterId, name)); + + LoggingClusteroutputEditPagePo.url = LoggingClusteroutputEditPagePo.createPath(clusterId, name); + } + + nameNsDescription() { + return new NameNsDescription(this.self()); + } + + clickTab(selector: string) { + return new TabbedPo().clickTabWithSelector(selector); + } + + selectOutputProviderWithLabel(providerName: string) { + return new SelectPo(this.self()).clickOptionWithLabel(providerName); + } + + target(): LabeledInputPo { + return LabeledInputPo.byLabel(this.self(), 'URL'); + } + + saveCreateForm(): AsyncButtonPo { + return new AsyncButtonPo('[data-testid="form-save"]', this.self()); + } +} diff --git a/cypress/e2e/po/pages/explorer/charts/chart.po.ts b/cypress/e2e/po/pages/explorer/charts/chart.po.ts index cc31bb4f553..bd9dbe8b4a7 100644 --- a/cypress/e2e/po/pages/explorer/charts/chart.po.ts +++ b/cypress/e2e/po/pages/explorer/charts/chart.po.ts @@ -27,6 +27,14 @@ export class ChartPage extends PagePo { chartsPage.charts().select(chartName); } + chartHeader(options?: any) { + return this.self().find('.name-logo h1', options).invoke('text'); + } + + waitForChartHeader(title: string, options?: any) { + return this.chartHeader(options).should('contain', title); + } + goToInstall() { const btn = new AsyncButtonPo('.chart-header .btn.role-primary'); diff --git a/cypress/e2e/tests/pages/charts/logging.spec.ts b/cypress/e2e/tests/pages/charts/logging.spec.ts new file mode 100644 index 00000000000..1b408aa0607 --- /dev/null +++ b/cypress/e2e/tests/pages/charts/logging.spec.ts @@ -0,0 +1,75 @@ +import { ChartPage } from '@/cypress/e2e/po/pages/explorer/charts/chart.po'; +import HomePagePo from '@/cypress/e2e/po/pages/home.po'; +import { InstallChartPage } from '@/cypress/e2e/po/pages/explorer/charts/install-charts.po'; +import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po'; +import { LoggingClusteroutputEditPagePo, LoggingClusteroutputListPagePo } from '@/cypress/e2e/po/other-products/logging/logging-clusteroutput.po'; +import { LoggingClusterflowEditPagePo, LoggingClusterflowListPagePo } from '@/cypress/e2e/po/other-products/logging/logging-clusterflow-po'; +import Kubectl from '@/cypress/e2e/po/components/kubectl.po'; + +describe('Logging Chart', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, () => { + before(() => { + cy.login(); + HomePagePo.goTo(); + }); + + it('is installed and a rule created', () => { + cy.updateNamespaceFilter('local', 'none', '{"local":[]}'); + const installChartPage = new InstallChartPage(); + const chartPage = new ChartPage(); + const sideNav = new ProductNavPo(); + const kubectl = new Kubectl(); + const outputName = Cypress._.uniqueId(Date.now().toString()); + const flowName = Cypress._.uniqueId(Date.now().toString()); + const loggingOutputList = new LoggingClusteroutputListPagePo(); + const loggingOutputEdit = new LoggingClusteroutputEditPagePo(); + const loggingFlowList = new LoggingClusterflowListPagePo(); + const loggingFlowEdit = new LoggingClusterflowEditPagePo(); + + ChartPage.navTo(null, 'Logging'); + chartPage.waitForChartHeader('Logging', { timeout: 20000 }); + chartPage.goToInstall(); + installChartPage.nextPage(); + + cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as('chartInstall'); + installChartPage.installChart(); + cy.wait('@chartInstall').its('response.statusCode').should('eq', 201); + cy.contains('Disconnected'); + + kubectl.closeTerminal(); + + sideNav.navToSideMenuGroupByLabel('Logging'); + sideNav.navToSideMenuGroupByLabel('ClusterOutput'); + loggingOutputList.createLoggingOutput(); + loggingOutputEdit.waitForPage(); + loggingOutputEdit.nameNsDescription().name().set(outputName); + loggingOutputEdit.target().set('random.domain.site'); + loggingOutputEdit.saveCreateForm().click(); + loggingOutputList.waitForPage(); + loggingOutputList.listElementWithName(outputName).should('exist'); + + sideNav.navToSideMenuEntryByLabel('ClusterFlow'); + loggingFlowList.createLoggingFlow(); + loggingFlowEdit.waitForPage(); + loggingFlowEdit.nameNsDescription().name().set(flowName); + loggingFlowEdit.outputsTab(); + loggingFlowEdit.outputSelector().toggle(); + loggingFlowEdit.outputSelector().clickOptionWithLabel(outputName); + loggingFlowEdit.saveCreateForm().click(); + loggingFlowList.waitForPage(); + loggingFlowList.listElementWithName(flowName).should('exist'); + loggingFlowList.rowLinkWithName(flowName).click(); + const loggingFlowEditExisting = new LoggingClusterflowEditPagePo('local', flowName); + + loggingFlowEditExisting.ruleItem(0).should('be.visible'); + }); + + after('clean up', () => { + const chartNamespace = 'cattle-logging-system'; + const chartApp = 'rancher-logging'; + const chartCrd = 'rancher-logging-crd'; + + cy.createRancherResource('v1', `catalog.cattle.io.apps/${ chartNamespace }/${ chartApp }?action=uninstall`, '{}'); + cy.createRancherResource('v1', `catalog.cattle.io.apps/${ chartNamespace }/${ chartCrd }?action=uninstall`, '{}'); + cy.updateNamespaceFilter('local', 'none', '{"local":["all://user"]}'); + }); +});