Skip to content

Commit

Permalink
Add e2e test for cluster manager namespace bug (#10964)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwmac authored May 7, 2024
1 parent cd85fda commit f60d943
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import TabbedPo from '~/cypress/e2e/po/components/tabbed.po';
*/
export default abstract class ClusterManagerDetailPagePo extends PagePo {
private static createPath(clusterId: string, clusterName: string, tab?: string) {
return `/c/${ clusterId }/manager/provisioning.cattle.io.cluster/fleet-default/${ clusterName }`;
const namespace = clusterName === 'local' ? 'fleet-local' : 'fleet-default';

return `/c/${ clusterId }/manager/provisioning.cattle.io.cluster/${ namespace }/${ clusterName }`;
}

static goTo(path: string): Cypress.Chainable<Cypress.AUTWindow> {
Expand Down Expand Up @@ -50,4 +52,8 @@ export default abstract class ClusterManagerDetailPagePo extends PagePo {

return this;
}

namespace() {
return cy.get('[data-testid="masthead-subheader-namespace"]');
}
}
15 changes: 15 additions & 0 deletions cypress/e2e/po/pages/cluster-manager/namespace.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';

export default class ClusterManagerNamespacePagePo extends PagePo {
private static createPath(clusterId: string, namespace) {
return `/c/${ clusterId }/manager/namespace/${ namespace }`;
}

constructor(clusterId = 'local', namespace = 'fleet-local') {
super(ClusterManagerNamespacePagePo.createPath(clusterId, namespace));
}

namespace() {
return cy.get('.mastehead-resource-title');
}
}
15 changes: 14 additions & 1 deletion cypress/e2e/tests/pages/manager/cluster-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ClusterManagerCreateRke2CustomPagePo from '@/cypress/e2e/po/edit/provisio
import ClusterManagerEditRke2CustomPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/edit/cluster-edit-rke2-custom.po';
import ClusterManagerImportGenericPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/import/cluster-import.generic.po';
import ClusterManagerEditGenericPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/edit/cluster-edit-generic.po';
import ClusterManagerNamespacePagePo from '@/cypress/e2e/po/pages/cluster-manager/namespace.po';
import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po';
import * as path from 'path';
import * as jsyaml from 'js-yaml';
Expand All @@ -22,7 +23,7 @@ import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import { nodeDriveResponse } from '@/cypress/e2e/tests/pages/manager/mock-responses';
import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po';
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import TabbedPo from '~/cypress/e2e/po/components/tabbed.po';
import TabbedPo from '@/cypress/e2e/po/components/tabbed.po';

// At some point these will come from somewhere central, then we can make tools to remove resources from this or all runs
const runTimestamp = +new Date();
Expand Down Expand Up @@ -566,6 +567,18 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs
clusterDetail.machinePoolsList().details('machine-', 2).should('be.visible');
clusterDetail.machinePoolsList().downloadYamlButton().should('be.disabled');
});

it('can navigate to namespace from cluster detail view', () => {
clusterDetail.waitForPage();

clusterDetail.namespace().should('contain.text', 'fleet-local');
clusterDetail.namespace().click();

const nsPage = new ClusterManagerNamespacePagePo();

nsPage.waitForPage();
nsPage.namespace().should('contain.text', 'fleet-local');
});
});

it(`can navigate to local cluster's explore product`, () => {
Expand Down
1 change: 1 addition & 0 deletions shell/components/ResourceDetail/Masthead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export default {
<router-link
v-if="!hideNamespaceLocation"
:to="namespaceLocation"
data-testid="masthead-subheader-namespace"
>
{{ namespace }}
</router-link>
Expand Down

0 comments on commit f60d943

Please sign in to comment.