Skip to content

Commit f778c1a

Browse files
committed
rebase & encapsulate steps
1 parent 7e9b823 commit f778c1a

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// 02.acm_alerting_ui.cy.ts
22
// E2E test for validating ACM Alerting UI integration with Cluster Observability Operator (COO)
3+
import '../../support/commands/auth-commands';
4+
import { nav } from '../../views/nav';
5+
import { acmAlertingPage } from '../../views/acm-alerting-page';
6+
37
const MCP = {
48
namespace: 'openshift-cluster-observability-operator',
59
packageName: 'cluster-observability-operator',
@@ -15,38 +19,17 @@ const MP = {
1519
};
1620
const expectedAlerts = ['Watchdog', 'Watchdog-spoke', 'ClusterCPUHealth-jb'];
1721

18-
// ignore error message
19-
Cypress.on('uncaught:exception', (err) => {
20-
const ignoreList = [
21-
'Unauthorized',
22-
"Cannot read properties of null (reading 'default')",
23-
'ResizeObserver loop limit exceeded',
24-
'Bad Gateway',
25-
'(intermediate value) is not a function',
26-
];
27-
if (ignoreList.some((txt) => err.message.includes(txt))) {
28-
console.warn('Ignored frontend exception:', err.message);
29-
return false;
30-
}
31-
});
32-
3322
describe('ACM Alerting UI', () => {
3423
before(() => {
3524
cy.beforeBlockACM(MCP, MP);
3625
});
3726

3827
it('Navigate to Fleet Management > local-cluster > Observe > Alerting', () => {
3928
// wait for console page loading completed
29+
cy.visit('/');
4030
cy.get('body', { timeout: 60000 }).should('contain.text', 'Administrator');
41-
// click Fleet Management
42-
cy.get('[data-test-id="perspective-switcher-toggle"]', { timeout: 20000 })
43-
.should('be.visible')
44-
.click();
45-
// select “Fleet Management”
46-
cy.get('[data-test-id="perspective-switcher-menu-option"]')
47-
.contains('Fleet Management')
48-
.should('be.visible')
49-
.click();
31+
// switch to Fleet Management page
32+
cy.switchPerspective('Fleet Management');
5033
// close pop-up window
5134
cy.closeOnboardingModalIfPresent();
5235
// click “local-cluster” when visible
@@ -58,13 +41,13 @@ describe('ACM Alerting UI', () => {
5841
cy.wrap($el).click({ force: true });
5942
});
6043
// click side menu -> Observe -> Alerting
61-
cy.contains('Observe', { timeout: 20000 }).should('be.visible').click();
62-
cy.contains('Alerting', { timeout: 20000 }).should('be.visible').click();
44+
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
6345
// Wait for alert tab content to become visible
6446
cy.get('section#alerts-tab-content', { timeout: 60000 })
6547
.should('be.visible');
66-
// confirm Alerting page loading completed then check three alert exist
67-
cy.get('body', { timeout: 60000 }).should('contain.text', 'Alerting');
48+
// confirm Alerting page loading completed
49+
acmAlertingPage.shouldBeLoaded();
50+
// check three test alerts exist
6851
expectedAlerts.forEach((alert) => {
6952
cy.contains('a[data-test-id="alert-resource-link"]', alert, { timeout: 60000 })
7053
.should('be.visible');

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ Cypress.Commands.add('beforeBlockACM', (MCP, MP) => {
580580
timeout: 1200000, // long time script
581581
});
582582
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-uiplugin.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
583+
// add example alerts for test
583584
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-alerrule-test.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
584585
cy.log('ACM environment setup completed');
585586
});

web/cypress/support/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ Cypress.on('uncaught:exception', (err) => {
2020
message.includes('ResizeObserver loop limit exceeded') ||
2121
message.includes('ResizeObserver loop completed with undelivered notifications') ||
2222
message.includes('ResizeObserver') ||
23-
message.includes('Cannot read properties of undefined')
23+
message.includes('Cannot read properties of undefined') ||
24+
message.includes('Unauthorized') ||
25+
message.includes('Bad Gateway') ||
26+
message.includes(`Cannot read properties of null (reading 'default')`) ||
27+
message.includes(`(intermediate value) is not a function`)
2428
) {
29+
console.warn('Ignored frontend exception:', err.message);
2530
return false;
2631
}
2732
// allow other errors to fail the test
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { DataTestIDs, Classes } from "../../src/components/data-test";
2+
3+
export const acmAlertingPage = {
4+
shouldBeLoaded: () => {
5+
cy.log('acmAlertingPage.shouldBeLoaded');
6+
cy.get('body', { timeout: 60000 }).should('contain.text', 'Alerting');
7+
cy.get('section.pf-v6-c-page__main-section h1').should('have.text', 'Alerting')
8+
// To Do:
9+
// other page check could be list here
10+
},
11+
};

0 commit comments

Comments
 (0)