-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automation: fleet cluster groups tests
- Loading branch information
Yonas Berhe
authored and
Yonas Berhe
committed
Jan 14, 2025
1 parent
37bb471
commit 52a56e7
Showing
5 changed files
with
161 additions
and
60 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
30 changes: 19 additions & 11 deletions
30
cypress/e2e/po/edit/fleet/fleet.cattle.io.clustergroup.po.ts
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 |
---|---|---|
@@ -1,27 +1,35 @@ | ||
import PagePo from '@/cypress/e2e/po/pages/page.po'; | ||
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po'; | ||
import CodeMirrorPo from '@/cypress/e2e/po/components/code-mirror.po'; | ||
|
||
import ResourceDetailPo from '@/cypress/e2e/po/edit/resource-detail.po'; | ||
import NameNsDescription from '@/cypress/e2e/po/components/name-ns-description.po'; | ||
export default class FleetClusterGroupsCreateEditPo extends PagePo { | ||
private static createPath(clusterId: string, id?: string ) { | ||
const root = `/c/${ clusterId }/explorer/storage.k8s.io.storageclass/create`; | ||
private static createPath(clusterId: string, workspace?: string, id?: string ) { | ||
const root = `/c/${ clusterId }/fleet/fleet.cattle.io.clustergroup`; | ||
|
||
return id ? `${ root }/${ id }` : `${ root }/create`; | ||
return id ? `${ root }/${ workspace }/${ id }` : `${ root }/create`; | ||
} | ||
|
||
static goTo(path: string): Cypress.Chainable<Cypress.AUTWindow> { | ||
throw new Error('invalid'); | ||
} | ||
|
||
constructor(clusterId = '_', id?: string) { | ||
super(FleetClusterGroupsCreateEditPo.createPath(clusterId, id)); | ||
constructor(clusterId = '_', workspace?: string, id?: string) { | ||
super(FleetClusterGroupsCreateEditPo.createPath(clusterId, workspace, id)); | ||
} | ||
|
||
title() { | ||
return this.self().get('.title .primaryheader h1'); | ||
} | ||
|
||
nameNsDescription() { | ||
return new NameNsDescription(this.self()); | ||
} | ||
|
||
editAsYaml() { | ||
return new AsyncButtonPo('[data-testid="form-yaml"]', this.self()); | ||
saveCreateForm(): ResourceDetailPo { | ||
return new ResourceDetailPo(this.self()); | ||
} | ||
|
||
yamlEditor(): CodeMirrorPo { | ||
return CodeMirrorPo.bySelector(this.self(), '[data-testid="yaml-editor-code-mirror"]'); | ||
saveButton() { | ||
return new AsyncButtonPo('[data-testid="form-save"]', this.self()); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,63 +1,147 @@ | ||
import { FleetClusterGroupsListPagePo } from '@/cypress/e2e/po/pages/fleet/fleet.cattle.io.clustergroup.po'; | ||
import FleetClusterGroupDetailsPo from '@/cypress/e2e/po/detail/fleet/fleet.cattle.io.clustergroup.po'; | ||
import { HeaderPo } from '@/cypress/e2e/po/components/header.po'; | ||
import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po'; | ||
|
||
describe('Cluster Groups', { testIsolation: 'off', tags: ['@fleet', '@adminUser'] }, () => { | ||
const fleetClusterGroups = new FleetClusterGroupsListPagePo(); | ||
const headerPo = new HeaderPo(); | ||
const localWorkspace = 'fleet-local'; | ||
let clusterGroupName; | ||
let removeClusterGroups = false; | ||
const clusterGroupsToDelete = []; | ||
|
||
describe('List', { tags: ['@vai', '@adminUser'] }, () => { | ||
before(() => { | ||
cy.login(); | ||
before(() => { | ||
cy.login(); | ||
cy.createE2EResourceName('cluster-group').then((name) => { | ||
clusterGroupName = name; | ||
}); | ||
}); | ||
|
||
it('check table headers are available in list and details view', () => { | ||
const groupName = 'default'; | ||
const workspace = 'fleet-local'; | ||
it('can create cluster group', () => { | ||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
headerPo.selectWorkspace(localWorkspace); | ||
fleetClusterGroups.clickCreate(); | ||
fleetClusterGroups.createFleetClusterGroupsForm().waitForPage(); | ||
|
||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
headerPo.selectWorkspace(workspace); | ||
fleetClusterGroups.clusterGroupsList().rowWithName(groupName).checkVisible(); | ||
fleetClusterGroups.createFleetClusterGroupsForm().nameNsDescription().name().set(clusterGroupName); | ||
fleetClusterGroups.createFleetClusterGroupsForm().saveCreateForm().cruResource().saveOrCreate() | ||
.click() | ||
.then(() => { | ||
removeClusterGroups = true; | ||
clusterGroupsToDelete.push(`${ localWorkspace }/${ clusterGroupName }`); | ||
}); | ||
|
||
// check table headers | ||
const expectedHeaders = ['State', 'Name', 'Clusters Ready', 'Resources', 'Age']; | ||
fleetClusterGroups.waitForPage(); | ||
fleetClusterGroups.clusterGroupsList().details(clusterGroupName, 1).should('be.visible'); | ||
}); | ||
|
||
fleetClusterGroups.clusterGroupsList().resourceTable().sortableTable().tableHeaderRow() | ||
.within('.table-header-container .content') | ||
.each((el, i) => { | ||
expect(el.text().trim()).to.eq(expectedHeaders[i]); | ||
}); | ||
it('can edit a cluster group', () => { | ||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
headerPo.selectWorkspace(localWorkspace); | ||
fleetClusterGroups.clusterGroupsList().actionMenu(clusterGroupName).getMenuItem('Edit Config').click(); | ||
fleetClusterGroups.createFleetClusterGroupsForm(localWorkspace, clusterGroupName).waitForPage('mode=edit'); | ||
fleetClusterGroups.createFleetClusterGroupsForm().nameNsDescription().description().set(`${ clusterGroupName }-fleet-desc`); | ||
fleetClusterGroups.createFleetClusterGroupsForm().saveCreateForm().cruResource().saveAndWaitForRequests('PUT', `v1/fleet.cattle.io.clustergroups/${ localWorkspace }/${ clusterGroupName }`) | ||
.then(({ response }) => { | ||
expect(response?.statusCode).to.eq(200); | ||
expect(response?.body.metadata).to.have.property('name', clusterGroupName); | ||
expect(response?.body.metadata.annotations).to.have.property('field.cattle.io/description', `${ clusterGroupName }-fleet-desc`); | ||
}); | ||
fleetClusterGroups.waitForPage(); | ||
}); | ||
|
||
// go to fleet cluster details | ||
fleetClusterGroups.goToDetailsPage(groupName); | ||
it('can clone a cluster group', () => { | ||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
headerPo.selectWorkspace(localWorkspace); | ||
fleetClusterGroups.clusterGroupsList().actionMenu(clusterGroupName).getMenuItem('Clone').click(); | ||
fleetClusterGroups.createFleetClusterGroupsForm(localWorkspace, clusterGroupName).waitForPage('mode=clone'); | ||
fleetClusterGroups.createFleetClusterGroupsForm().nameNsDescription().name().set(`clone-${ clusterGroupName }`); | ||
fleetClusterGroups.createFleetClusterGroupsForm().nameNsDescription().description().set(`${ clusterGroupName }-fleet-desc`); | ||
fleetClusterGroups.createFleetClusterGroupsForm().saveCreateForm().cruResource().saveAndWaitForRequests('POST', 'v1/fleet.cattle.io.clustergroups') | ||
.then(({ response }) => { | ||
expect(response?.statusCode).to.eq(201); | ||
removeClusterGroups = true; | ||
clusterGroupsToDelete.push(`${ localWorkspace }/clone-${ clusterGroupName }`); | ||
expect(response?.body.metadata).to.have.property('name', `clone-${ clusterGroupName }`); | ||
expect(response?.body.metadata.annotations).to.have.property('field.cattle.io/description', `${ clusterGroupName }-fleet-desc`); | ||
}); | ||
fleetClusterGroups.waitForPage(); | ||
fleetClusterGroups.clusterGroupsList().details(`clone-${ clusterGroupName }`, 1).should('be.visible'); | ||
}); | ||
|
||
const fleetClusterGroupDetailsPage = new FleetClusterGroupDetailsPo(workspace, groupName); | ||
it('can delete cluster group', () => { | ||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
headerPo.selectWorkspace(localWorkspace); | ||
fleetClusterGroups.clusterGroupsList().actionMenu(clusterGroupName).getMenuItem('Delete').click(); | ||
fleetClusterGroups.clusterGroupsList().resourceTable().sortableTable().rowNames('.col-link-detail') | ||
.then((rows: any) => { | ||
const promptRemove = new PromptRemove(); | ||
|
||
fleetClusterGroupDetailsPage.waitForPage(null, 'clusters'); | ||
cy.intercept('DELETE', `v1/fleet.cattle.io.clustergroups/${ localWorkspace }/clone-${ clusterGroupName }`).as('deleteClusterGroup'); | ||
|
||
// check table headers | ||
const expectedHeadersDetailsView = ['State', 'Name', 'Bundles Ready', 'Repos Ready', 'Resources', 'Last Seen', 'Age']; | ||
promptRemove.remove(); | ||
cy.wait('@deleteClusterGroup'); | ||
fleetClusterGroups.waitForPage(); | ||
fleetClusterGroups.clusterGroupsList().resourceTable().sortableTable().checkRowCount(false, rows.length - 1); | ||
fleetClusterGroups.clusterGroupsList().resourceTable().sortableTable().rowNames('.col-link-detail') | ||
.should('not.contain', `clone-${ clusterGroupName }`); | ||
}); | ||
}); | ||
|
||
fleetClusterGroupDetailsPage.clusterList().resourceTable().sortableTable() | ||
.tableHeaderRow() | ||
.within('.table-header-container .content') | ||
.each((el, i) => { | ||
expect(el.text().trim()).to.eq(expectedHeadersDetailsView[i]); | ||
}); | ||
}); | ||
// testing https://github.com/rancher/dashboard/issues/11687 | ||
it('can open "Edit as YAML"', () => { | ||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
fleetClusterGroups.clickCreate(); | ||
fleetClusterGroups.createFleetClusterGroupsForm().saveCreateForm().createEditView().editAsYaml(); | ||
fleetClusterGroups.createFleetClusterGroupsForm().saveCreateForm().resourceYaml().codeMirror() | ||
.checkExists(); | ||
}); | ||
describe('Edit', { tags: ['@vai', '@adminUser'] }, () => { | ||
before(() => { | ||
cy.login(); | ||
}); | ||
|
||
it('can open "Edit as YAML"', () => { | ||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
fleetClusterGroups.clickCreate(); | ||
fleetClusterGroups.createFleetClusterGroupsForm().editAsYaml().click(); | ||
fleetClusterGroups.createFleetClusterGroupsForm().yamlEditor().checkExists(); | ||
}); | ||
it('check table headers are available in list and details view', { tags: ['@vai', '@adminUser'] }, () => { | ||
const groupName = 'default'; | ||
|
||
FleetClusterGroupsListPagePo.navTo(); | ||
fleetClusterGroups.waitForPage(); | ||
headerPo.selectWorkspace(localWorkspace); | ||
fleetClusterGroups.clusterGroupsList().rowWithName(groupName).checkVisible(); | ||
|
||
// check table headers | ||
const expectedHeaders = ['State', 'Name', 'Clusters Ready', 'Resources', 'Age']; | ||
|
||
fleetClusterGroups.clusterGroupsList().resourceTable().sortableTable().tableHeaderRow() | ||
.within('.table-header-container .content') | ||
.each((el, i) => { | ||
expect(el.text().trim()).to.eq(expectedHeaders[i]); | ||
}); | ||
|
||
// go to fleet cluster details | ||
fleetClusterGroups.goToDetailsPage(groupName); | ||
|
||
const fleetClusterGroupDetailsPage = new FleetClusterGroupDetailsPo(localWorkspace, groupName); | ||
|
||
fleetClusterGroupDetailsPage.waitForPage(null, 'clusters'); | ||
|
||
// check table headers | ||
const expectedHeadersDetailsView = ['State', 'Name', 'Bundles Ready', 'Repos Ready', 'Resources', 'Last Seen', 'Age']; | ||
|
||
fleetClusterGroupDetailsPage.clusterList().resourceTable().sortableTable() | ||
.tableHeaderRow() | ||
.within('.table-header-container .content') | ||
.each((el, i) => { | ||
expect(el.text().trim()).to.eq(expectedHeadersDetailsView[i]); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
if (removeClusterGroups) { | ||
// delete gitrepo | ||
clusterGroupsToDelete.forEach((r) => cy.deleteRancherResource('v1', 'fleet.cattle.io.clustergroups', r, false)); | ||
} | ||
}); | ||
}); |
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