Skip to content

Commit 99e1211

Browse files
committed
skip chart E2E tests when charts are filtered due to annotations 2.13
1 parent efb4026 commit 99e1211

14 files changed

Lines changed: 691 additions & 480 deletions

cypress/e2e/po/pages/explorer/charts/install-charts.po.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export class InstallChartPage extends PagePo {
5151
return this;
5252
}
5353

54+
footerControls() {
55+
return cy.get('#wizard-footer-controls');
56+
}
57+
5458
chartName() {
5559
return this.self().get('[data-testid="NameNsDescriptionNameInput"]');
5660
}

cypress/e2e/po/pages/explorer/cluster-tools.po.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default class ClusterToolsPagePo extends PagePo {
2828
}
2929

3030
featureChartCards() {
31-
return cy.get('[data-testid="tools-app-chart-cards"]').find('[data-testid*="item-card-"]');
31+
return cy.get('[data-testid="tools-app-chart-cards"]').find('[data-testid*="item-card-cluster"]');
3232
}
3333

3434
getCardByName(name: string): RcItemCardPo {

cypress/e2e/tests/navigation/side-nav/product-side-nav-highlighting.spec.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import UsersPo from '@/cypress/e2e/po/pages/users-and-auth/users.po';
66
import RolesPo from '@/cypress/e2e/po/pages/users-and-auth/roles.po';
77
import ClusterProjectMembersPo from '@/cypress/e2e/po/pages/explorer/cluster-project-members.po';
88
import { BLANK_CLUSTER } from '@shell/store/store-types.js';
9+
import { runTestWhenChartAvailable } from '@/cypress/support/commands/rancher-api-commands';
910

1011
Cypress.config();
1112
describe('Side navigation: Highlighting ', { tags: ['@navigation', '@adminUser'] }, () => {
@@ -19,6 +20,7 @@ describe('Side navigation: Highlighting ', { tags: ['@navigation', '@adminUser']
1920

2021
beforeEach(() => {
2122
cy.login();
23+
cy.setUserPreference({ 'show-pre-release': true }, true); // Show pre-release versions so charts with only -rc versions appear on Charts page
2224
HomePagePo.goTo();
2325
});
2426

@@ -36,25 +38,27 @@ describe('Side navigation: Highlighting ', { tags: ['@navigation', '@adminUser']
3638
productNavPo.activeNavItem().should('equal', 'Cluster and Project Members');
3739
});
3840

39-
it('Chart and sub-pages are highlighted correctly', () => {
40-
HomePagePo.goTo();
41-
chartsPage.goTo();
41+
it('Chart and sub-pages are highlighted correctly', function() {
42+
runTestWhenChartAvailable(CHART.repo, CHART.id, this, () => {
43+
HomePagePo.goTo();
44+
chartsPage.goTo();
4245

43-
const productNavPo = new ProductNavPo();
46+
const productNavPo = new ProductNavPo();
4447

45-
productNavPo.visibleNavTypes().eq(0).should('be.visible').click()
46-
.then((link) => {
47-
cy.url().should('equal', link.prop('href'));
48-
});
49-
productNavPo.activeNavItem().should('equal', 'Charts');
48+
productNavPo.visibleNavTypes().eq(0).should('be.visible').click()
49+
.then((link) => {
50+
cy.url().should('equal', link.prop('href'));
51+
});
52+
productNavPo.activeNavItem().should('equal', 'Charts');
5053

51-
// Go to install page
52-
chartsPage.clickChart(CHART.name);
53-
chartPage.waitForChartPage(CHART.repo, CHART.id);
54-
productNavPo.activeNavItem().should('equal', 'Charts');
54+
// Go to install page
55+
chartsPage.clickChart(CHART.name);
56+
chartPage.waitForChartPage(CHART.repo, CHART.id);
57+
productNavPo.activeNavItem().should('equal', 'Charts');
5558

56-
chartPage.goToInstall();
57-
productNavPo.activeNavItem().should('equal', 'Charts');
59+
chartPage.goToInstall();
60+
productNavPo.activeNavItem().should('equal', 'Charts');
61+
});
5862
});
5963

6064
it('User Retention highlighting', () => {
@@ -84,4 +88,8 @@ describe('Side navigation: Highlighting ', { tags: ['@navigation', '@adminUser']
8488
roles.list(CLUSTER).rowWithName('Cluster Owner').checkExists();
8589
productNavPo.activeNavItem().should('equal', 'Role Templates');
8690
});
91+
92+
after(() => {
93+
cy.setUserPreference({ 'show-pre-release': false });
94+
});
8795
});

cypress/e2e/tests/pages/charts/chart-install-wizard.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('Charts Wizard', { testIsolation: 'off', tags: ['@charts', '@adminUser'
2525

2626
before(() => {
2727
cy.login();
28+
cy.setUserPreference({ 'show-pre-release': true }, true); // Show pre-release versions so charts with only -rc versions appear on Charts page
2829
HomePagePo.goTo();
2930
});
3031

@@ -67,4 +68,8 @@ describe('Charts Wizard', { testIsolation: 'off', tags: ['@charts', '@adminUser'
6768
cy.updateNamespaceFilter('local', 'none', '{"local":["all://user"]}');
6869
});
6970
});
71+
72+
after(() => {
73+
cy.setUserPreference({ 'show-pre-release': false });
74+
});
7075
});

cypress/e2e/tests/pages/charts/compliance.spec.ts

Lines changed: 73 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { MEDIUM_TIMEOUT_OPT, LONG_TIMEOUT_OPT } from '@/cypress/support/utils/ti
55
import Kubectl from '@/cypress/e2e/po/components/kubectl.po';
66
import { CompliancePo, ComplianceListPo } from '~/cypress/e2e/po/other-products/compliance.po';
77
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
8+
import { runTestWhenChartAvailable } from '@/cypress/support/commands/rancher-api-commands';
89

910
describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, () => {
1011
before(() => {
1112
cy.login();
13+
cy.setUserPreference({ 'show-pre-release': true }, true); // Show pre-release versions so charts with only -rc versions appear on Charts page
1214
HomePagePo.goTo();
1315
});
1416

@@ -17,78 +19,80 @@ describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, ()
1719
const chartPage = new ChartPage();
1820

1921
describe('YAML view', () => {
20-
beforeEach(() => {
21-
ChartPage.navTo(null, 'Rancher Compliance');
22-
chartPage.waitForChartHeader('Rancher Compliance', MEDIUM_TIMEOUT_OPT);
23-
chartPage.goToInstall();
24-
installChartPage.nextPage().editYaml();
25-
});
26-
2722
describe('UI Elements', () => {
28-
it('Footer controls should sticky to bottom', () => {
29-
cy.get('#wizard-footer-controls').should('be.visible');
30-
31-
cy.get('#wizard-footer-controls').then(($el) => {
32-
const elementRect = $el[0].getBoundingClientRect();
33-
const viewportHeight = Cypress.config('viewportHeight');
34-
const pageHeight = Cypress.$(cy.state('window')).height();
35-
36-
expect(elementRect.bottom).to.eq(pageHeight);
37-
expect(elementRect.bottom).to.eq(viewportHeight);
23+
it('Footer controls should sticky to bottom', function() {
24+
runTestWhenChartAvailable('rancher-charts', 'rancher-compliance', this, () => {
25+
ChartPage.navTo(null, 'Rancher Compliance');
26+
chartPage.waitForChartHeader('Rancher Compliance', MEDIUM_TIMEOUT_OPT);
27+
chartPage.goToInstall();
28+
installChartPage.nextPage().editYaml();
29+
30+
installChartPage.footerControls().should('be.visible');
31+
32+
installChartPage.footerControls().then(($el) => {
33+
const elementRect = $el[0].getBoundingClientRect();
34+
const viewportHeight = Cypress.config('viewportHeight');
35+
const pageHeight = Cypress.$(cy.state('window')).height();
36+
37+
expect(elementRect.bottom).to.eq(pageHeight);
38+
expect(elementRect.bottom).to.eq(viewportHeight);
39+
});
3840
});
3941
});
4042
});
4143
});
4244

4345
describe('Compliance Chart setup', () => {
44-
it('Complete install and a Scan is created', () => {
45-
cy.updateNamespaceFilter('local', 'none', '{"local":[]}');
46-
const kubectl = new Kubectl();
47-
const compliance = new CompliancePo();
48-
const complianceList = new ComplianceListPo();
49-
const sideNav = new ProductNavPo();
50-
const terminal = new Kubectl();
51-
52-
ChartPage.navTo(null, 'Rancher Compliance');
53-
chartPage.waitForChartHeader('Rancher Compliance', MEDIUM_TIMEOUT_OPT);
54-
chartPage.goToInstall();
55-
56-
installChartPage.nextPage();
57-
58-
cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as('chartInstall');
59-
installChartPage.installChart();
60-
cy.wait('@chartInstall').its('response.statusCode').should('eq', 201);
61-
kubectl.waitForTerminalStatus('Disconnected');
62-
63-
kubectl.closeTerminal();
64-
65-
sideNav.navToSideMenuGroupByLabel('Compliance');
66-
complianceList.waitForPage();
67-
68-
// Compliance does not come with any profiles, so create one
69-
70-
// Open terminal
71-
terminal.openTerminal(LONG_TIMEOUT_OPT);
72-
73-
// kubectl commands
74-
terminal.executeCommand(`apply -f https://raw.githubusercontent.com/rancher/compliance-operator/refs/heads/main/tests/k3s-bench-test.yaml`);
75-
76-
terminal.closeTerminal();
77-
78-
complianceList.createScan();
79-
compliance.waitForPage();
80-
compliance.cruResource().saveAndWaitForRequests('POST', 'v1/compliance.cattle.io.clusterscans')
81-
.then(({ response }) => {
82-
expect(response?.statusCode).to.eq(201);
83-
expect(response?.body).to.have.property('type', 'compliance.cattle.io.clusterscan');
84-
expect(response?.body.metadata).to.have.property('name');
85-
expect(response?.body.metadata).to.have.property('generateName', 'scan-');
86-
});
87-
complianceList.waitForPage();
88-
complianceList.checkVisible();
89-
90-
complianceList.list().resourceTable().checkVisible();
91-
complianceList.list().resourceTable().sortableTable().checkRowCount(false, 2);
46+
it('Complete install and a Scan is created', function() {
47+
runTestWhenChartAvailable('rancher-charts', 'rancher-compliance', this, () => {
48+
cy.updateNamespaceFilter('local', 'none', '{"local":[]}');
49+
const kubectl = new Kubectl();
50+
const compliance = new CompliancePo();
51+
const complianceList = new ComplianceListPo();
52+
const sideNav = new ProductNavPo();
53+
const terminal = new Kubectl();
54+
55+
ChartPage.navTo(null, 'Rancher Compliance');
56+
chartPage.waitForChartHeader('Rancher Compliance', MEDIUM_TIMEOUT_OPT);
57+
chartPage.goToInstall();
58+
59+
installChartPage.nextPage();
60+
61+
cy.intercept('POST', 'v1/catalog.cattle.io.clusterrepos/rancher-charts?action=install').as('chartInstall');
62+
installChartPage.installChart();
63+
cy.wait('@chartInstall').its('response.statusCode').should('eq', 201);
64+
kubectl.waitForTerminalStatus('Disconnected');
65+
66+
kubectl.closeTerminal();
67+
68+
sideNav.navToSideMenuGroupByLabel('Compliance');
69+
complianceList.waitForPage();
70+
71+
// Compliance does not come with any profiles, so create one
72+
73+
// Open terminal
74+
terminal.openTerminal(LONG_TIMEOUT_OPT);
75+
76+
// kubectl commands
77+
terminal.executeCommand(`apply -f https://raw.githubusercontent.com/rancher/compliance-operator/refs/heads/main/tests/k3s-bench-test.yaml`);
78+
79+
terminal.closeTerminal();
80+
81+
complianceList.createScan();
82+
compliance.waitForPage();
83+
compliance.cruResource().saveAndWaitForRequests('POST', 'v1/compliance.cattle.io.clusterscans')
84+
.then(({ response }) => {
85+
expect(response?.statusCode).to.eq(201);
86+
expect(response?.body).to.have.property('type', 'compliance.cattle.io.clusterscan');
87+
expect(response?.body.metadata).to.have.property('name');
88+
expect(response?.body.metadata).to.have.property('generateName', 'scan-');
89+
});
90+
complianceList.waitForPage();
91+
complianceList.checkVisible();
92+
93+
complianceList.list().resourceTable().checkVisible();
94+
complianceList.list().resourceTable().sortableTable().checkRowCount(false, 2);
95+
});
9296
});
9397

9498
after('clean up', () => {
@@ -102,4 +106,8 @@ describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, ()
102106
});
103107
});
104108
});
109+
110+
after(() => {
111+
cy.setUserPreference({ 'show-pre-release': false });
112+
});
105113
});

0 commit comments

Comments
 (0)