Skip to content

Commit

Permalink
fleet cluster list page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonas Berhe authored and Yonas Berhe committed Jun 4, 2024
1 parent 5efe60e commit 2ddcf4d
Show file tree
Hide file tree
Showing 15 changed files with 672 additions and 35 deletions.
4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require('dotenv').config();
* VARIABLES
*/
const hasCoverage = (process.env.TEST_INSTRUMENT === 'true') || false; // Add coverage if instrumented
const testDirs = ['components', 'setup', 'pages', 'navigation', 'global-ui'];
const testDirs = ['pages/fleet'];
const skipSetup = process.env.TEST_SKIP?.includes('setup');
const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, '');
const DEFAULT_USERNAME = 'admin';
Expand Down Expand Up @@ -59,7 +59,7 @@ export default defineConfig({
trashAssetsBeforeRuns: true,
chromeWebSecurity: false,
retries: {
runMode: 2,
runMode: 0,
openMode: 0
},
env: {
Expand Down
30 changes: 30 additions & 0 deletions cypress/e2e/blueprints/fleet/gitrepos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,33 @@ export const gitRepoCreateRequest = {
helmSecretName: 'auth-95j88'
}
};

export function gitRepoTargetAllClustersRequest(
namespace: string,
name: string,
repo: string,
branch: string,
path: string
):object {
return {
type: 'fleet.cattle.io.gitrepo',
metadata: {
namespace,
name
},
spec: {
repo,
branch,
paths: [path],
correctDrift: { enabled: false },
targets: [{
clusterSelector: {
matchExpressions: [{
key: 'provider.cattle.io', operator: 'NotIn', values: ['harvester']
}]
}
}],
insecureSkipTLSVerify: false
}
};
}
8 changes: 6 additions & 2 deletions cypress/e2e/po/components/sortable-table.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export default class SortableTablePo extends ComponentPo {
return this.self().contains('thead tr', name);
}

tableHeaderRow() {
return this.self().find('thead tr');
}

subRows() {
return this.self().find('tbody tr.sub-row');
}
Expand Down Expand Up @@ -140,7 +144,7 @@ export default class SortableTablePo extends ComponentPo {
}

noRowsText() {
return this.self().find('tbody').find('.no-rows');
return this.self().find('tbody', { timeout: 10000 }).find('.no-rows');
}

/**
Expand Down Expand Up @@ -211,6 +215,6 @@ export default class SortableTablePo extends ComponentPo {

// Check that the sortable table loading indicator does not exist (data loading complete)
checkLoadingIndicatorNotVisible() {
cy.get('.data-loading').should('not.exist');
cy.get('tbody', { timeout: 10000 }).find('.data-loading').should('not.exist');
}
}
13 changes: 13 additions & 0 deletions cypress/e2e/po/components/tabbed.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@ export default class TabbedPo extends ComponentPo {
allTabs() {
return this.self().get('[data-testid="tabbed-block"] > li');
}

/**
* Get tab labels
* @param tabLabelsSelector
* @returns
*/
tabNames(tabLabelsSelector = 'a > span') {
return this.allTabs().find(tabLabelsSelector).then(($els: any) => {
return (
Cypress.$.makeArray<string>($els).map((el: any) => el.innerText as string)
);
});
}
}
28 changes: 28 additions & 0 deletions cypress/e2e/po/detail/fleet/fleet.cattle.io.cluster.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import TabbedPo from '@/cypress/e2e/po/components/tabbed.po';
import FleetGitRepoList from '~/cypress/e2e/po/lists/fleet/fleet.cattle.io.gitrepo.po';

/**
* Details component for fleet.cattle.io.gitrepo resources
*/
export default class FleetClusterDetailsPo extends PagePo {
private static createPath(fleetWorkspace: string, clusterName: string) {
return `/c/_/fleet/fleet.cattle.io.cluster/${ fleetWorkspace }/${ clusterName }`;
}

static goTo(path: string): Cypress.Chainable<Cypress.AUTWindow> {
throw new Error('invalid');
}

constructor(fleetWorkspace: string, clusterName: string) {
super(FleetClusterDetailsPo.createPath(fleetWorkspace, clusterName));
}

clusterTabs(): TabbedPo {
return new TabbedPo();
}

gitReposList(): FleetGitRepoList {
return new FleetGitRepoList(this.self());
}
}
30 changes: 30 additions & 0 deletions cypress/e2e/po/edit/fleet/fleet.cattle.io.cluster.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import AsyncButtonPo from '~/cypress/e2e/po/components/async-button.po';
import NameNsDescription from '~/cypress/e2e/po/components/name-ns-description.po';
import ResourceDetailPo from '~/cypress/e2e/po/edit/resource-detail.po';

export default class FleetClusterEditPo extends PagePo {
private static createPath(fleetWorkspace: string, clusterName: string) {
return `/c/_/fleet/fleet.cattle.io.cluster/${ fleetWorkspace }/${ clusterName }`;
}

static goTo(path: string): Cypress.Chainable<Cypress.AUTWindow> {
throw new Error('invalid');
}

constructor(fleetWorkspace = 'fleet-default', clusterName: string) {
super(FleetClusterEditPo.createPath(fleetWorkspace, clusterName));
}

nameNsDescription() {
return new NameNsDescription(this.self());
}

saveCreateForm(): ResourceDetailPo {
return new ResourceDetailPo(this.self());
}

saveButton() {
return new AsyncButtonPo('[data-testid="form-save"]', this.self());
}
}
3 changes: 3 additions & 0 deletions cypress/e2e/po/lists/fleet/fleet.cattle.io.cluster.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po';
* List component for fleet.cattle.io.cluster resources
*/
export default class FleetClusterList extends BaseResourceList {
details(accessKey: string, index: number) {
return this.resourceTable().sortableTable().rowWithName(accessKey).column(index);
}
}
4 changes: 4 additions & 0 deletions cypress/e2e/po/lists/fleet/fleet.cattle.io.gitrepo.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ export default class FleetGitRepoList extends BaseResourceList {
create() {
return this.masthead().actions().eq(0).click();
}

details(name: string, index: number) {
return this.resourceTable().sortableTable().rowWithName(name).column(index);
}
}
4 changes: 4 additions & 0 deletions cypress/e2e/po/pages/explorer/workloads/workloads.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export class WorkloadsListPageBasePo extends PagePo {
return this.resourcesList().resourceTable().sortableTable();
}

details(name: string, index: number) {
return this.sortableTable().rowWithName(name).column(index);
}

deleteItemWithUI(name: string) {
this.sortableTable().rowActionMenuOpen(name).getMenuItem('Delete').click();

Expand Down
22 changes: 22 additions & 0 deletions cypress/e2e/po/pages/fleet/fleet.cattle.io.cluster.po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import FleetClusterList from '@/cypress/e2e/po/lists/fleet/fleet.cattle.io.cluster.po';
import { FleetDashboardPagePo } from '@/cypress/e2e/po/pages/fleet/fleet-dashboard.po';
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import FleetClusterEditPo from '@/cypress/e2e/po/edit/fleet/fleet.cattle.io.cluster.po';

export class FleetClusterListPagePo extends PagePo {
static url = `/c/_/fleet/fleet.cattle.io.cluster`
Expand All @@ -12,10 +15,25 @@ export class FleetClusterListPagePo extends PagePo {
return cy.visit(FleetClusterListPagePo.url);
}

navTo() {
const fleetDashboardPage = new FleetDashboardPagePo('_');

FleetDashboardPagePo.navTo();
fleetDashboardPage.waitForPage();

const sideNav = new ProductNavPo();

sideNav.navToSideMenuEntryByLabel('Clusters');
}

selectWorkspace(workspaceName = 'fleet-local') {
return this.header().selectWorkspace(workspaceName);
}

clusterList() {
return new FleetClusterList('[data-testid="sortable-table-list-container"]');
}

sortableTable() {
return new FleetClusterList(this.self()).resourceTable().sortableTable();
}
Expand All @@ -27,4 +45,8 @@ export class FleetClusterListPagePo extends PagePo {
checkRowCount(isEmpty: boolean, expected: number) {
this.sortableTable().checkRowCount(isEmpty, expected);
}

editFleetCluster(workspace: string, clusterName: string): FleetClusterEditPo {
return new FleetClusterEditPo(workspace, clusterName);
}
}
3 changes: 3 additions & 0 deletions cypress/e2e/po/pages/fleet/fleet.cattle.io.gitrepo.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class FleetGitRepoListPagePo extends PagePo {
}

navTo() {
const fleetDashboardPage = new FleetDashboardPagePo('_');

FleetDashboardPagePo.navTo();
fleetDashboardPage.waitForPage();

const sideNav = new ProductNavPo();

Expand Down
Loading

0 comments on commit 2ddcf4d

Please sign in to comment.