Skip to content

Commit

Permalink
More e2e fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Dec 9, 2024
1 parent 8130cca commit 7b89a85
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/po/components/namespace-filter.po.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ComponentPo from '@/cypress/e2e/po/components/component.po';

export class NamespaceFilterPo extends ComponentPo {
constructor() {
super('[data-testid="namespaces-filter"]');
Expand Down Expand Up @@ -52,6 +53,10 @@ export class NamespaceFilterPo extends ComponentPo {
return this.namespaceDropdown().find('[data-testid="namespaces-values"]');
}

allSelected() {
return this.self().find('[data-testid="namespaces-values-none"]').should('exist');
}

moreOptionsSelected() {
return this.namespaceDropdown().find('.ns-more');
}
Expand Down
36 changes: 35 additions & 1 deletion cypress/e2e/po/pages/explorer/cluster-dashboard.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import CustomBadgeDialogPo from '@/cypress/e2e/po/components/custom-badge-dialog
import EventsListPo from '@/cypress/e2e/po/lists/events-list.po';
import TabbedPo from '@/cypress/e2e/po/components/tabbed.po';
import CertificatesPo from '@/cypress/e2e/po/components/certificates.po';
import { HeaderPo } from '~/cypress/e2e/po/components/header.po';
import { HeaderPo } from '@/cypress/e2e/po/components/header.po';
import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po';

export default class ClusterDashboardPagePo extends PagePo {
private static createPath(clusterId: string) {
Expand Down Expand Up @@ -82,4 +83,37 @@ export default class ClusterDashboardPagePo extends PagePo {
controllerManagerStatus() {
return cy.get('[data-testid="k8s-service-controller-manager"]');
}

/**
* Confirm that the ns filter is set correctly before navigating to a page that will use it
* 1. nav to cluster dashboard
* 2. check ns filter values
*/
static goToAndConfirmNsValues(cluster: string, {
nsProject,
all
}: {
nsProject?: {
values: string[]
},
all?: {
is: boolean,
}
}) {
const instance = new ClusterDashboardPagePo(cluster);
const nsfilter = new NamespaceFilterPo();

instance.goTo(cluster);
instance.waitForPage();

if (nsProject) {
for (let i = 0; i < nsProject.values.length; i++) {
nsfilter.selectedValues().contains(nsProject.values[i]);
}
} else if (all) {
nsfilter.allSelected();
} else {
throw new Error('Bad Config');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { CustomResourceDefinitionsPagePo } from '@/cypress/e2e/po/pages/explorer
import { generateCrdsDataSmall } from '@/cypress/e2e/blueprints/explorer/more-resources/api/custom-resource-definition-get';
import * as jsyaml from 'js-yaml';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import ClusterDashboardPagePo from '@/cypress/e2e/po/pages/explorer/cluster-dashboard.po';

const crdsPage = new CustomResourceDefinitionsPagePo('local');
const cluster = 'local';
const crdsPage = new CustomResourceDefinitionsPagePo(cluster);
const crdName = `e2etests.${ +new Date() }.example.com`;
const crdGroup = `${ +new Date() }.example.com`;

Expand All @@ -14,11 +16,13 @@ describe('CustomResourceDefinitions', { testIsolation: 'off', tags: ['@explorer'

describe('List', { tags: ['@vai', '@adminUser'] }, () => {
before(() => {
cy.tableRowsPerPageAndNamespaceFilter(10, 'local', 'none', '{\"local\":[]}');
cy.tableRowsPerPageAndNamespaceFilter(10, cluster, 'none', '{\"local\":[]}');
});

it('can create a crd and see it in list view', () => {
crdsPage.goTo();
ClusterDashboardPagePo.goToAndConfirmNsValues(cluster, { all: { is: true } } );

CustomResourceDefinitionsPagePo.navTo();
crdsPage.waitForPage();
crdsPage.create();

Expand Down
9 changes: 1 addition & 8 deletions cypress/e2e/tests/pages/explorer2/workloads/pods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import PodPo from '@/cypress/e2e/po/components/workloads/pod.po';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import { generatePodsDataSmall } from '@/cypress/e2e/blueprints/explorer/workloads/pods/pods-get';
import SortableTablePo from '@/cypress/e2e/po/components/sortable-table.po';
import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po';
import ClusterDashboardPagePo from '@/cypress/e2e/po/pages/explorer/cluster-dashboard.po';

const cluster = 'local';

describe('Pods', { testIsolation: 'off', tags: ['@explorer2', '@adminUser'] }, () => {
const workloadsPodPage = new WorkloadsPodsListPagePo(cluster);
const clusterDashboard = new ClusterDashboardPagePo(cluster);
const nsFilter = new NamespaceFilterPo();

before(() => {
cy.login();
Expand Down Expand Up @@ -67,11 +64,7 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer2', '@adminUser'] }, (
});

it('pagination is visible and user is able to navigate through pods data', () => {
// Confirm that the ns filter is set correctly before navigating to a page that will use it
clusterDashboard.goTo();
clusterDashboard.waitForPage();
nsFilter.selectedValues().contains(nsName1);
nsFilter.selectedValues().contains(nsName2);
ClusterDashboardPagePo.goToAndConfirmNsValues(cluster, { nsProject: { values: [nsName1, nsName2] } });

WorkloadsPodsListPagePo.navTo();
workloadsPodPage.waitForPage();
Expand Down

0 comments on commit 7b89a85

Please sign in to comment.