Skip to content

Commit 1d87d9d

Browse files
committed
fixing flaky steps
1 parent ff1b26d commit 1d87d9d

6 files changed

Lines changed: 25 additions & 16 deletions

File tree

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/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)