Skip to content

Commit 403a5ae

Browse files
Merge pull request #709 from etmurasaki/etmura-flaky
NO-JIRA: monitoring automation fixing Core platform change
2 parents b79e634 + 431febe commit 403a5ae

9 files changed

Lines changed: 35 additions & 30 deletions

web/cypress/e2e/coo/01.coo_ivt.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ describe('IVT: Monitoring UIPlugin + Virtualization', { tags: ['@smoke', '@coo']
2525
it('1. Virtualization perspective - Observe Menu', () => {
2626
cy.log('Virtualization perspective - Observe Menu and verify all submenus');
2727
cy.switchPerspective('Virtualization');
28-
cy.byAriaLabel('Welcome modal').should('be.visible');
2928
guidedTour.closeKubevirtTour();
3029
troubleshootingPanelPage.signalCorrelationShouldNotBeVisible();
31-
cy.switchPerspective('Administrator');
30+
cy.switchPerspective('Core platform', 'Administrator');
3231

3332
});
3433

web/cypress/support/commands/auth-commands.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export {};
77
declare global {
88
namespace Cypress {
99
interface Chainable {
10-
switchPerspective(perspective: string);
10+
switchPerspective(...perspectives: string[]);
1111
uiLogin(provider: string, username: string, password: string, oauthurl?: string);
1212
uiLogout();
1313
cliLogin(username?, password?, hostapi?);
@@ -119,7 +119,7 @@ declare global {
119119
cy.validateLogin();
120120
});
121121

122-
Cypress.Commands.add('switchPerspective', (perspective: string) => {
122+
Cypress.Commands.add('switchPerspective', (...perspectives: string[]) => {
123123
/* If side bar is collapsed then expand it
124124
before switching perspecting */
125125
cy.wait(2000);
@@ -128,8 +128,9 @@ declare global {
128128
cy.get('#nav-toggle').click();
129129
}
130130
});
131-
nav.sidenav.switcher.changePerspectiveTo(perspective);
132-
cy.validateLogin();
131+
nav.sidenav.switcher.changePerspectiveTo(...perspectives);
132+
cy.wait(3000);
133+
guidedTour.close();
133134
});
134135

135136
// To avoid influence from upstream login change

web/cypress/support/commands/utility-commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Cypress.Commands.add('waitUntilWithCustomTimeout', (
116116

117117
Cypress.Commands.add('podImage', (pod: string, namespace: string) => {
118118
cy.log('Get pod image');
119-
cy.switchPerspective('Core platform');
119+
cy.switchPerspective('Core platform', 'Administrator');
120120
cy.wait(5000);
121121
cy.clickNavLink(['Workloads', 'Pods']);
122122
cy.changeNamespace(namespace);

web/cypress/support/commands/virtualization-commands.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ const virtualizationUtils = {
218218
validate() {
219219
cy.validateLogin();
220220
// Additional validation for Virtualization setup
221-
cy.visit('/k8s/all-namespaces/virtualization-overview');
222-
cy.url().should('include', '/k8s/all-namespaces/virtualization-overview');
221+
cy.switchPerspective('Virtualization');
223222
guidedTour.closeKubevirtTour();
224223

225224
},

web/cypress/support/monitoring/03.reg_legacy_dashboards.cy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { nav } from '../../views/nav';
22
import { legacyDashboardsPage } from '../../views/legacy-dashboards';
3-
import { API_PERFORMANCE_DASHBOARD_PANELS, LegacyDashboardsDashboardDropdown, MetricsPageQueryInput, WatchdogAlert } from '../../fixtures/monitoring/constants';
3+
import { LegacyDashboardsDashboardDropdown, MetricsPageQueryInput, WatchdogAlert } from '../../fixtures/monitoring/constants';
44
import { Classes, LegacyDashboardPageTestIDs, DataTestIDs } from '../../../src/components/data-test';
55
import { metricsPage } from '../../views/metrics';
66
import { alertingRuleDetailsPage } from '../../views/alerting-rule-details-page';
@@ -35,9 +35,7 @@ export function testLegacyDashboardsRegression(perspective: PerspectiveConfig) {
3535
legacyDashboardsPage.clickDashboardDropdown('API_PERFORMANCE');
3636

3737
cy.log('1.5 Dashboard API Performance panels');
38-
for (const panel of Object.values(API_PERFORMANCE_DASHBOARD_PANELS)) {
39-
legacyDashboardsPage.dashboardAPIPerformancePanelAssertion(panel);
40-
}
38+
legacyDashboardsPage.dashboardAPIPerformancePanelAssertion();
4139

4240
cy.log('1.6 Inspect - API Request Duration by Verb - 99th Percentile');
4341
cy.byTestID(LegacyDashboardPageTestIDs.Inspect).eq(0).scrollIntoView().should('be.visible').click();

web/cypress/support/monitoring/06.reg_legacy_dashboards_namespace.cy.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { nav } from '../../views/nav';
22
import { legacyDashboardsPage } from '../../views/legacy-dashboards';
3-
import { KUBERNETES_COMPUTE_RESOURCES_NAMESPACE_PODS_PANELS, LegacyDashboardsDashboardDropdownNamespace, MetricsPageQueryInputByNamespace, WatchdogAlert } from '../../fixtures/monitoring/constants';
3+
import { LegacyDashboardsDashboardDropdownNamespace, MetricsPageQueryInputByNamespace, WatchdogAlert } from '../../fixtures/monitoring/constants';
44
import { Classes, LegacyDashboardPageTestIDs, DataTestIDs } from '../../../src/components/data-test';
55
import { metricsPage } from '../../views/metrics';
66
import { alertingRuleDetailsPage } from '../../views/alerting-rule-details-page';
@@ -34,9 +34,7 @@ export function testLegacyDashboardsRegressionNamespace(perspective: Perspective
3434
legacyDashboardsPage.dashboardDropdownAssertion(LegacyDashboardsDashboardDropdownNamespace);
3535

3636
cy.log('1.5 Dashboard Kubernetes Compute Resources Namespace Pods panels');
37-
for (const panel of Object.values(KUBERNETES_COMPUTE_RESOURCES_NAMESPACE_PODS_PANELS)) {
38-
legacyDashboardsPage.dashboardKubernetesComputeResourcesNamespacePodsPanelAssertion(panel);
39-
}
37+
legacyDashboardsPage.dashboardKubernetesComputeResourcesNamespacePodsPanelAssertion();
4038

4139
cy.log('1.6 Inspect - CPU Utilisation (from requests)');
4240
cy.byTestID(LegacyDashboardPageTestIDs.Inspect).eq(0).scrollIntoView().should('be.visible').click();

web/cypress/views/legacy-dashboards.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ export const legacyDashboardsPage = {
7777
cy.byTestID(LegacyDashboardPageTestIDs.DashboardDropdown).find('button').should('be.visible').click();
7878
},
7979

80-
dashboardAPIPerformancePanelAssertion: (panel: API_PERFORMANCE_DASHBOARD_PANELS) => {
80+
dashboardAPIPerformancePanelAssertion: () => {
8181
cy.log('legacyDashboardsPage.dashboardAPIPerformancePanelAssertion');
8282
function formatDataTestID(panel: API_PERFORMANCE_DASHBOARD_PANELS): string {
8383
return panel.toLowerCase().replace(/\s+/g, '-').concat('-chart');
8484
}
85-
const dataTestID = Object.values(API_PERFORMANCE_DASHBOARD_PANELS).map(formatDataTestID);
86-
dataTestID.forEach((dataTestID) => {
85+
const dataTestIDs = Object.values(API_PERFORMANCE_DASHBOARD_PANELS).map(formatDataTestID);
86+
dataTestIDs.forEach((dataTestID) => {
8787
cy.log('Data test ID: ' + dataTestID);
8888
cy.byTestID(dataTestID).scrollIntoView().should('be.visible');
8989
});
9090
},
9191

92-
dashboardKubernetesComputeResourcesNamespacePodsPanelAssertion: (panel: KUBERNETES_COMPUTE_RESOURCES_NAMESPACE_PODS_PANELS) => {
92+
dashboardKubernetesComputeResourcesNamespacePodsPanelAssertion: () => {
9393
cy.log('legacyDashboardsPage.dashboardKubernetesComputeResourcesNamespacePodsPanelAssertion');
9494
function formatDataTestID(panel: KUBERNETES_COMPUTE_RESOURCES_NAMESPACE_PODS_PANELS): string {
9595
return panel.toLowerCase().replace(/\s+/g, '-').concat('-chart');
9696
}
97-
const dataTestID = Object.values(KUBERNETES_COMPUTE_RESOURCES_NAMESPACE_PODS_PANELS).map(formatDataTestID);
98-
dataTestID.forEach((dataTestID) => {
97+
const dataTestIDs = Object.values(KUBERNETES_COMPUTE_RESOURCES_NAMESPACE_PODS_PANELS).map(formatDataTestID);
98+
dataTestIDs.forEach((dataTestID) => {
9999
cy.log('Data test ID: ' + dataTestID);
100100
cy.byTestID(dataTestID).scrollIntoView().should('be.visible');
101101
});

web/cypress/views/nav.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@ export const nav = {
66
cy.clickNavLink(path);
77
},
88
switcher: {
9-
changePerspectiveTo: (perspective: string) => {
9+
changePerspectiveTo: (...perspectives: string[]) => {
1010
cy.get('body').then((body) => {
11-
if (body.find('#perspective-switcher-toggle').length > 0) {
12-
cy.log('Switch perspective - ' + `${perspective}`);
13-
cy.byLegacyTestID('perspective-switcher-toggle').scrollIntoView().should('be.visible').click({force: true});
14-
cy.byLegacyTestID('perspective-switcher-menu-option').contains(perspective).should('be.visible');
15-
cy.byLegacyTestID('perspective-switcher-menu-option').contains(perspective).should('be.visible').click({force: true});
11+
if (body.find('button[data-test-id="perspective-switcher-toggle"]:visible').length > 0) {
12+
cy.byLegacyTestID('perspective-switcher-toggle').scrollIntoView().click({ force: true });
13+
14+
cy.get('[data-test-id="perspective-switcher-menu-option"]').then(($options) => {
15+
const foundPerspective = perspectives.find(p => $options.text().includes(p));
16+
if (foundPerspective) {
17+
cy.byLegacyTestID('perspective-switcher-menu-option')
18+
.contains(foundPerspective)
19+
.click({ force: true });
20+
} else {
21+
cy.log('No matching perspective found');
22+
cy.get('body').type('{esc}');
23+
}
24+
});
25+
1626
}
1727
});
18-
1928
},
2029
shouldHaveText: (perspective: string) => {
2130
cy.log('Should have text - ' + `${perspective}`);

web/cypress/views/silences-list-page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const silencesListPage = {
8888

8989
clickAlertKebab: () => {
9090
cy.log('silencesListPage.rows.clickAlertKebab');
91+
cy.wait(2000);
9192
cy.byTestID(DataTestIDs.KebabDropdownButton).should('be.visible').click();
9293
},
9394

0 commit comments

Comments
 (0)