Skip to content

Commit

Permalink
Adding logging chart test
Browse files Browse the repository at this point in the history
  • Loading branch information
izaac committed Dec 5, 2024
1 parent 4653a0f commit f39a308
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 0 deletions.
71 changes: 71 additions & 0 deletions cypress/e2e/po/other-products/logging/logging-clusterflow-po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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';

export class LoggingFlowListPagePo extends PagePo {
private static createPath(clusterId: string) {
return `/c/${ clusterId }/logging/logging.banzaicloud.io.flow`;
}

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

constructor(clusterId = 'local') {
super(LoggingFlowListPagePo.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);
}
}

export class LoggingFlowEditPagePo extends PagePo {
static url: string;

private static createPath( clusterId: string, type: string ) {
const urlStr = `/c/${ clusterId }/logging/logging.banzaicloud.io.clusterflow/create#${ type }`;

return urlStr;
}

static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(this.url);
}

constructor(clusterId = 'local', type = 'match') {
super(LoggingFlowEditPagePo.createPath(clusterId, type));

LoggingFlowEditPagePo.url = LoggingFlowEditPagePo.createPath(clusterId, type);
}

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());
}
}
76 changes: 76 additions & 0 deletions cypress/e2e/po/other-products/logging/logging-clusteroutput.po.ts
Original file line number Diff line number Diff line change
@@ -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 LoggingOutputListPagePo extends PagePo {
private static createPath(clusterId: string) {
return `/c/${ clusterId }/logging/logging.banzaicloud.io.output`;
}

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

constructor(clusterId = 'local') {
super(LoggingOutputListPagePo.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 LoggingOutputEditPagePo extends PagePo {
static url: string;

private static createPath( clusterId: string, type: string ) {
const urlStr = `/c/${ clusterId }/logging/logging.banzaicloud.io.clusteroutput/create#${ type }`;

return urlStr;
}

static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(this.url);
}

constructor(clusterId = 'local', type = 'Output') {
super(LoggingOutputEditPagePo.createPath(clusterId, type));

LoggingOutputEditPagePo.url = LoggingOutputEditPagePo.createPath(clusterId, type);
}

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());
}
}
8 changes: 8 additions & 0 deletions cypress/e2e/po/pages/explorer/charts/chart.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export class ChartPage extends PagePo {
chartsPage.charts().select(chartName);
}

chartHeader() {
return this.self().find('.name-logo h1', { timeout: 20000 }).invoke('text');
}

waitForChartHeader(title: string) {
return this.chartHeader().should('contain', title);
}

goToInstall() {
const btn = new AsyncButtonPo('.chart-header .btn.role-primary');

Expand Down
58 changes: 58 additions & 0 deletions cypress/e2e/tests/pages/charts/logging.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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 { LoggingOutputEditPagePo, LoggingOutputListPagePo } from '~/cypress/e2e/po/other-products/logging/logging-clusteroutput.po';
import Kubectl from '~/cypress/e2e/po/components/kubectl.po';
import { LoggingFlowEditPagePo, LoggingFlowListPagePo } from '~/cypress/e2e/po/other-products/logging/logging-clusterflow-po';

describe('Logging Chart', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, () => {
before(() => {
cy.login();
HomePagePo.goTo();
});

it.only('is installed and a rule created', () => {
const installChartPage = new InstallChartPage();
const chartPage = new ChartPage();
const sideNav = new ProductNavPo();
const kubectl = new Kubectl();
const loggingOutputList = new LoggingOutputListPagePo();
const loggingOutputEdit = new LoggingOutputEditPagePo();
const loggingFlowList = new LoggingFlowListPagePo();
const loggingFlowEdit = new LoggingFlowEditPagePo();
const outputName = Cypress._.uniqueId(Date.now().toString());
const flowName = Cypress._.uniqueId(Date.now().toString());

ChartPage.navTo(null, 'Logging');
chartPage.waitForChartHeader('Logging');
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.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.listElementWithName(flowName).should('exist');
});
});

0 comments on commit f39a308

Please sign in to comment.