mirror of https://github.com/rancher/dashboard.git
Adding CIS chart UI tests
This commit is contained in:
parent
85c31a4073
commit
c0dfe0e8eb
|
|
@ -0,0 +1,72 @@
|
||||||
|
import PagePo from '@/cypress/e2e/po/pages/page.po';
|
||||||
|
import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po';
|
||||||
|
import ResourceListMastheadPo from '@/cypress/e2e/po/components/ResourceList/resource-list-masthead.po';
|
||||||
|
import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po';
|
||||||
|
import NameNsDescription from '@/cypress/e2e/po/components/name-ns-description.po';
|
||||||
|
import CruResourcePo from '@/cypress/e2e/po/components/cru-resource.po';
|
||||||
|
|
||||||
|
export class CisBenchmarkListPo extends PagePo {
|
||||||
|
private static createPath(clusterId: string) {
|
||||||
|
return `/c/${ clusterId }/cis/cis.cattle.io.clusterscan`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> {
|
||||||
|
return super.goTo(CisBenchmarkListPo.createPath(clusterId));
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(clusterId = 'local') {
|
||||||
|
super(CisBenchmarkListPo.createPath(clusterId));
|
||||||
|
}
|
||||||
|
|
||||||
|
masthead() {
|
||||||
|
return new ResourceListMastheadPo(this.self());
|
||||||
|
}
|
||||||
|
|
||||||
|
createScan() {
|
||||||
|
return this.masthead().create();
|
||||||
|
}
|
||||||
|
|
||||||
|
listElementWithName(name:string) {
|
||||||
|
const baseResourceList = new BaseResourceList(this.self());
|
||||||
|
|
||||||
|
return baseResourceList.resourceTable().sortableTable().rowElementWithName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
firstRow() {
|
||||||
|
const baseResourceList = new BaseResourceList(this.self());
|
||||||
|
|
||||||
|
return baseResourceList.resourceTable().sortableTable().row(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CisBenchmarkPo extends PagePo {
|
||||||
|
static url: string;
|
||||||
|
|
||||||
|
private static createPath( clusterId: string, name: string ) {
|
||||||
|
const urlStr = `/c/${ clusterId }/cis/cis.cattle.io.clusterscan/${ name }`;
|
||||||
|
|
||||||
|
return urlStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
|
||||||
|
return super.goTo(this.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(clusterId = 'local', name = 'create') {
|
||||||
|
super(CisBenchmarkPo.createPath(clusterId, name));
|
||||||
|
|
||||||
|
CisBenchmarkPo.url = CisBenchmarkPo.createPath(clusterId, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
cruResource() {
|
||||||
|
return new CruResourcePo(this.self());
|
||||||
|
}
|
||||||
|
|
||||||
|
nameNsDescription() {
|
||||||
|
return new NameNsDescription(this.self());
|
||||||
|
}
|
||||||
|
|
||||||
|
yamlEditor(): CodeMirrorPo {
|
||||||
|
return CodeMirrorPo.bySelector(this.self(), '[data-testid="yaml-editor-code-mirror"]');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
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 { MEDIUM_TIMEOUT_OPT, LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';
|
||||||
|
import Kubectl from '@/cypress/e2e/po/components/kubectl.po';
|
||||||
|
import { CisBenchmarkPo, CisBenchmarkListPo } from '@/cypress/e2e/po/other-products/cis-benchmark.po';
|
||||||
|
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
|
||||||
|
|
||||||
|
describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, () => {
|
||||||
|
before(() => {
|
||||||
|
cy.login();
|
||||||
|
HomePagePo.goTo();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('CIS Benchmark install', () => {
|
||||||
|
const installChartPage = new InstallChartPage();
|
||||||
|
const chartPage = new ChartPage();
|
||||||
|
|
||||||
|
describe('YAML view', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
ChartPage.navTo(null, 'CIS Benchmark');
|
||||||
|
chartPage.waitForChartHeader('CIS Benchmark', MEDIUM_TIMEOUT_OPT);
|
||||||
|
chartPage.goToInstall();
|
||||||
|
installChartPage.nextPage().editYaml();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('UI Elements', () => {
|
||||||
|
it('Footer controls should sticky to bottom', () => {
|
||||||
|
cy.get('#wizard-footer-controls').should('be.visible');
|
||||||
|
|
||||||
|
cy.get('#wizard-footer-controls').then(($el) => {
|
||||||
|
const elementRect = $el[0].getBoundingClientRect();
|
||||||
|
const viewportHeight = Cypress.config('viewportHeight');
|
||||||
|
const pageHeight = Cypress.$(cy.state('window')).height();
|
||||||
|
|
||||||
|
expect(elementRect.bottom).to.eq(pageHeight);
|
||||||
|
expect(elementRect.bottom).to.eq(viewportHeight);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('CIS Chart setup', () => {
|
||||||
|
it('Complete install and a Scan is created', () => {
|
||||||
|
cy.updateNamespaceFilter('local', 'none', '{"local":[]}');
|
||||||
|
const kubectl = new Kubectl();
|
||||||
|
const cisBenchmark = new CisBenchmarkPo();
|
||||||
|
const cisBenchmarkList = new CisBenchmarkListPo();
|
||||||
|
const sideNav = new ProductNavPo();
|
||||||
|
|
||||||
|
ChartPage.navTo(null, 'CIS Benchmark');
|
||||||
|
chartPage.waitForChartHeader('CIS Benchmark', MEDIUM_TIMEOUT_OPT);
|
||||||
|
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('CIS Benchmark');
|
||||||
|
cisBenchmarkList.waitForPage();
|
||||||
|
cisBenchmarkList.createScan();
|
||||||
|
cisBenchmark.waitForPage();
|
||||||
|
cisBenchmark.cruResource().saveAndWaitForRequests('POST', 'v1/cis.cattle.io.clusterscans')
|
||||||
|
.then(({ response }) => {
|
||||||
|
expect(response?.statusCode).to.eq(201);
|
||||||
|
expect(response?.body).to.have.property('type', 'cis.cattle.io.clusterscan');
|
||||||
|
expect(response?.body.metadata).to.have.property('name');
|
||||||
|
expect(response?.body.metadata).to.have.property('generateName', 'scan-');
|
||||||
|
});
|
||||||
|
cisBenchmarkList.waitForPage();
|
||||||
|
cisBenchmarkList.checkVisible();
|
||||||
|
const column = cisBenchmarkList.firstRow().column(1);
|
||||||
|
|
||||||
|
column.get('.bg-success', LONG_TIMEOUT_OPT).should('exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
after('clean up', () => {
|
||||||
|
const chartNamespace = 'cis-operator-system';
|
||||||
|
const chartApp = 'rancher-cis-benchmark';
|
||||||
|
const chartCrd = 'rancher-cis-benchmark-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"]}');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue