-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po'; | ||
|
||
export default class CisBenchmarkListPo extends BaseResourceList { | ||
openBulkActionDropdown() { | ||
return this.resourceTable().sortableTable().bulkActionDropDownOpen(); | ||
} | ||
|
||
bulkActionButton(name: string) { | ||
return this.resourceTable().sortableTable().bulkActionDropDownButton(name); | ||
} | ||
|
||
details(name: string, index: number) { | ||
return this.resourceTable().sortableTable().rowWithName(name).column(index); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import PagePo from '@/cypress/e2e/po/pages/page.po'; | ||
import ResourceTablePo from '@/cypress/e2e/po/components/resource-table.po'; | ||
import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po'; | ||
import CisBenchmarkListPo from '@/cypress/e2e/po/other-products/cis-benchmark-list.po'; | ||
import ResourceDetailPo from '@/cypress/e2e/po/edit/resource-detail.po'; | ||
|
||
export default class CisBenchmarkPo extends PagePo { | ||
static createPath(clusterId: string) { | ||
return `/c/${ clusterId }/cis/cis.cattle.io.clusterscan/create`; | ||
} | ||
|
||
static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> { | ||
return super.goTo(CisBenchmarkPo.createPath(clusterId)); | ||
} | ||
|
||
constructor(clusterId = 'local') { | ||
super(CisBenchmarkPo.createPath(clusterId)); | ||
} | ||
|
||
create(): Cypress.Chainable { | ||
return this.list().masthead().actions().contains('Create'); | ||
} | ||
|
||
createFromYaml(): Cypress.Chainable { | ||
return this.list().masthead().actions().contains('Create from YAML'); | ||
} | ||
|
||
goToDetailsPage(elemName: string) { | ||
const resourceTable = new ResourceTablePo(this.self()); | ||
|
||
return resourceTable.sortableTable().detailsPageLinkWithName(elemName).click(); | ||
} | ||
|
||
list(): CisBenchmarkListPo { | ||
return new CisBenchmarkListPo('[data-testid="sortable-table-list-container"]'); | ||
} | ||
|
||
resourceDetail() { | ||
return new ResourceDetailPo(this.self()) | ||
} | ||
|
||
yamlEditor(): CodeMirrorPo { | ||
return CodeMirrorPo.bySelector(this.self(), '[data-testid="yaml-editor-code-mirror"]'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po'; | ||
import { MEDIUM_TIMEOUT_OPT, LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts'; | ||
import Kubectl from '@/cypress/e2e/po/components/kubectl.po'; | ||
import CisBenchmarkPo from '@/cypress/e2e/po/other-products/cis-benchmark.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 sideNav = new ProductNavPo(); | ||
const cisBenchmark = new CisBenchmarkPo(); | ||
|
||
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'); | ||
sideNav.navToSideMenuEntryByLabel('Scan'); | ||
|
||
cisBenchmark.create().click(); | ||
cisBenchmark.waitForPage(); | ||
cisBenchmark.resourceDetail().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-'); | ||
}); | ||
cisBenchmark.list().checkVisible(); | ||
const column = cisBenchmark.list().resourceTable().sortableTable().row(0) | ||
.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"]}'); | ||
}); | ||
}); | ||
}); | ||
}); |