diff --git a/web/cypress/e2e/monitoring/00.bvt_admin.cy.ts b/web/cypress/e2e/monitoring/00.bvt_admin.cy.ts index 6ef745739..b0eeb588e 100644 --- a/web/cypress/e2e/monitoring/00.bvt_admin.cy.ts +++ b/web/cypress/e2e/monitoring/00.bvt_admin.cy.ts @@ -37,6 +37,7 @@ describe('BVT: Monitoring', { tags: ['@smoke', '@monitoring'] }, () => { nav.sidenav.clickNavLink(['Observe', 'Dashboards']); commonPages.titleShouldHaveText('Dashboards'); nav.sidenav.clickNavLink(['Observe', 'Targets']); + nav.sidenav.clickNavLink(['Observe', 'Targets']); commonPages.titleShouldHaveText('Metrics targets'); diff --git a/web/cypress/fixtures/perses/constants.ts b/web/cypress/fixtures/perses/constants.ts index 48f9e520b..44f36e70f 100644 --- a/web/cypress/fixtures/perses/constants.ts +++ b/web/cypress/fixtures/perses/constants.ts @@ -39,4 +39,4 @@ export enum persesDashboardsAcceleratorsCommonMetricsPanels { TEMPERATURE_CELCIUS = 'Temperature (Celsius)', SM_CLOCK_HERTZ = 'SM Clock (Hertz)', MEMORY_CLOCK_HERTZ = 'Memory Clock (Hertz)', -} \ No newline at end of file +} diff --git a/web/cypress/support/commands/utility-commands.ts b/web/cypress/support/commands/utility-commands.ts index c3a017e61..b90b6bbf6 100644 --- a/web/cypress/support/commands/utility-commands.ts +++ b/web/cypress/support/commands/utility-commands.ts @@ -12,6 +12,7 @@ declare global { changeNamespace(namespace: string): Chainable; aboutModal(): Chainable; podImage(pod: string, namespace: string): Chainable; + assertNamespace(namespace: string, exists: boolean): Chainable; } } } @@ -60,29 +61,51 @@ Cypress.Commands.add('waitUntilWithCustomTimeout', ( cy.log('Changing Namespace to: ' + namespace); cy.wait(2000); cy.get('body').then(($body) => { - const hasNamespaceBarDropdown = $body.find('[data-test-id="'+LegacyTestIDs.NamespaceBarDropdown+'"]').length > 0; + const hasNamespaceBarDropdown = + $body.find('[data-test-id="' + LegacyTestIDs.NamespaceBarDropdown + '"]').length > 0; if (hasNamespaceBarDropdown) { - cy.byLegacyTestID(LegacyTestIDs.NamespaceBarDropdown).find('button').scrollIntoView().should('be.visible'); - cy.byLegacyTestID(LegacyTestIDs.NamespaceBarDropdown).find('button').scrollIntoView().should('be.visible').click({force: true}); + cy.byLegacyTestID(LegacyTestIDs.NamespaceBarDropdown) + .find('button') + .scrollIntoView() + .should('be.visible'); + cy.byLegacyTestID(LegacyTestIDs.NamespaceBarDropdown) + .find('button') + .scrollIntoView() + .should('be.visible') + .click({ force: true }); } else { cy.get(Classes.NamespaceDropdown).scrollIntoView().should('be.visible'); - cy.get(Classes.NamespaceDropdown).scrollIntoView().should('be.visible').click({force: true}); + cy.get(Classes.NamespaceDropdown) + .scrollIntoView() + .should('be.visible') + .click({ force: true }); } }); cy.get('body').then(($body) => { - const hasShowSystemSwitch = $body.find('[data-test="'+DataTestIDs.NamespaceDropdownShowSwitch+'"]').length > 0; + const hasShowSystemSwitch = + $body.find('[data-test="' + DataTestIDs.NamespaceDropdownShowSwitch + '"]').length > 0; if (hasShowSystemSwitch) { - cy.get('[data-test="'+DataTestIDs.NamespaceDropdownShowSwitch+'"]').then(($element)=> { + cy.get('[data-test="' + DataTestIDs.NamespaceDropdownShowSwitch + '"]').then(($element) => { if ($element.attr('data-checked-state') !== 'true') { - cy.byTestID(DataTestIDs.NamespaceDropdownShowSwitch).siblings('span').eq(0).should('be.visible'); - cy.byTestID(DataTestIDs.NamespaceDropdownShowSwitch).siblings('span').eq(0).should('be.visible').click({force: true}); + cy.byTestID(DataTestIDs.NamespaceDropdownShowSwitch) + .siblings('span') + .eq(0) + .should('be.visible'); + cy.byTestID(DataTestIDs.NamespaceDropdownShowSwitch) + .siblings('span') + .eq(0) + .should('be.visible') + .click({ force: true }); } }); } }); - cy.byTestID(DataTestIDs.NamespaceDropdownTextFilter).type(namespace, {delay: 100}); + cy.byTestID(DataTestIDs.NamespaceDropdownTextFilter).type(namespace, { delay: 100 }); cy.byTestID(DataTestIDs.NamespaceDropdownMenuLink).contains(namespace).should('be.visible'); - cy.byTestID(DataTestIDs.NamespaceDropdownMenuLink).contains(namespace).should('be.visible').click({force: true}); + cy.byTestID(DataTestIDs.NamespaceDropdownMenuLink) + .contains(namespace) + .should('be.visible') + .click({ force: true }); cy.log('Namespace changed to: ' + namespace); }); @@ -95,50 +118,69 @@ Cypress.Commands.add('waitUntilWithCustomTimeout', ( cy.byAriaLabel('About modal').find('div[class*="co-select-to-copy"]').eq(0).should('be.visible').then(($ocpversion) => { cy.log('OCP version: ' + $ocpversion.text()); }); - cy.byAriaLabel('Close Dialog').should('be.visible').click(); - } + cy.byAriaLabel('Close Dialog').should('be.visible').click(); + } +}); - }); +Cypress.Commands.overwrite('log', (log, ...args) => { + if (Cypress.browser.isHeadless && Cypress.env('DEBUG')) { + // Log to the terminal using the custom task + return cy.task('log', args, { log: false }).then(() => { + // The original cy.log is still executed but its output is hidden from the + // command log in headless mode + return log(...args); + }); + } else { + // In headed mode, use the original cy.log behavior + return log(...args); + } +}); - Cypress.Commands.overwrite('log', (log, ...args) => { - if (Cypress.browser.isHeadless && Cypress.env('DEBUG')) { - // Log to the terminal using the custom task - return cy.task('log', args, { log: false }).then(() => { - // The original cy.log is still executed but its output is hidden from the - // command log in headless mode - return log(...args); - }); +Cypress.Commands.add('podImage', (pod: string, namespace: string) => { + cy.log('Get pod image'); + cy.switchPerspective('Core platform'); + cy.clickNavLink(['Workloads', 'Pods']); + cy.byTestID('page-heading').contains('Pods').should('be.visible'); + cy.changeNamespace(namespace); + // Check for DataViewFilters component using Cypress's built-in retry-ability + cy.get('body').then(($body) => { + const hasDataViewFilters = $body.find('[data-ouia-component-id="DataViewFilters"]').length > 0; + if (hasDataViewFilters) { + cy.get('[placeholder="Filter by name"]').scrollIntoView().should('be.visible').type(pod); } else { - // In headed mode, use the original cy.log behavior - return log(...args); + cy.byTestID('name-filter-input').should('be.visible').type(pod); } }); - - Cypress.Commands.add('podImage', (pod: string, namespace: string) => { - cy.log('Get pod image'); - cy.switchPerspective('Core platform'); - cy.wait(5000); - cy.clickNavLink(['Workloads', 'Pods']); - cy.changeNamespace(namespace); - cy.byTestID('page-heading').contains('Pods').should('be.visible'); - cy.wait(5000); - // Check for DataViewFilters component using Cypress's built-in retry-ability - cy.get('body').then(($body) => { - const hasDataViewFilters = $body.find('[data-ouia-component-id="DataViewFilters"]').length > 0; - if (hasDataViewFilters) { - cy.byOUIAID('DataViewFilters').find('button').contains('Status').scrollIntoView().should('be.visible').click(); - cy.byOUIAID('OUIA-Generated-Menu').find('button').contains('Name').scrollIntoView().should('be.visible').click(); - cy.get('[placeholder="Filter by name"]').scrollIntoView().should('be.visible').type(pod); - } else { - cy.byTestID('name-filter-input').should('be.visible').type(pod); - } + cy.get(`a[data-test^="${pod}"]`).eq(0).as('podLink').click(); + cy.get('@podLink').should('be.visible').click(); + cy.byPFRole('rowgroup').find('td').eq(1).scrollIntoView().should('be.visible').then(($td) => { + cy.log('Pod image: ' + $td.text()); }); - cy.get(`a[data-test^="${pod}"]`).eq(0).as('podLink').click(); - cy.get('@podLink').should('be.visible').click(); - cy.byPFRole('rowgroup').find('td').eq(1).scrollIntoView().should('be.visible').then(($td) => { - cy.log('Pod image: ' + $td.text()); - }); - cy.log('Get pod image completed'); + cy.log('Get pod image completed'); +}); + +Cypress.Commands.add('assertNamespace', (namespace: string, exists: boolean) => { + cy.log('Asserting Namespace: ' + namespace + ' exists: ' + exists); + cy.get('body').then(($body) => { + const hasNamespaceBarDropdown = + $body.find('[data-test-id="' + LegacyTestIDs.NamespaceBarDropdown + '"]').length > 0; + if (hasNamespaceBarDropdown) { + cy.byLegacyTestID(LegacyTestIDs.NamespaceBarDropdown) + .find('button') + .scrollIntoView() + .should('be.visible'); + cy.byLegacyTestID(LegacyTestIDs.NamespaceBarDropdown) + .find('button') + .scrollIntoView() + .should('be.visible') + .click({ force: true }); + } else { + cy.get(Classes.NamespaceDropdown).scrollIntoView().should('be.visible'); + cy.get(Classes.NamespaceDropdown) + .scrollIntoView() + .should('be.visible') + .click({ force: true }); + } }); +}); - diff --git a/web/cypress/support/monitoring/00.bvt_monitoring.cy.ts b/web/cypress/support/monitoring/00.bvt_monitoring.cy.ts index bee9e9c38..982691b53 100644 --- a/web/cypress/support/monitoring/00.bvt_monitoring.cy.ts +++ b/web/cypress/support/monitoring/00.bvt_monitoring.cy.ts @@ -20,65 +20,68 @@ export function runBVTMonitoringTests(perspective: PerspectiveConfig) { export function testBVTMonitoring(perspective: PerspectiveConfig) { - it(`${perspective.name} perspective - Alerting > Alerting Details page > Alerting Rule > Metrics`, () => { - cy.log('5.1. use sidebar nav to go to Observe > Alerting'); - commonPages.titleShouldHaveText('Alerting'); - listPage.tabShouldHaveText('Alerts'); - listPage.tabShouldHaveText('Silences'); - listPage.tabShouldHaveText('Alerting rules'); - commonPages.linkShouldExist('Export as CSV'); - commonPages.linkShouldExist('Clear all filters'); - listPage.ARRows.shouldBeLoaded(); - - cy.log('5.2. filter Alerts and click on Alert'); - listPage.filter.byName(`${WatchdogAlert.ALERTNAME}`); - listPage.ARRows.countShouldBe(1); - listPage.ARRows.ARShouldBe(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`, 1, 'Firing'); - listPage.ARRows.expandRow(); - listPage.ARRows.AShouldBe(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`, `${WatchdogAlert.NAMESPACE}`); - listPage.ARRows.clickAlert(); - - cy.log('5.3. click on Alert Details Page'); - commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); - commonPages.detailsPage.common(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`); - commonPages.detailsPage.alert(`${WatchdogAlert.ALERTNAME}`); - - const timeIntervalValue = getValFromElement(`[data-ouia-component-id^="OUIA-Generated-TextInputBase"]`); - timeIntervalValue.then((value) => { - expect(value).to.not.be.empty; + it( + `${perspective.name} perspective - ` + + 'Alerting > Alerting Details page > Alerting Rule > Metrics', + () => { + cy.log('5.1. use sidebar nav to go to Observe > Alerting'); + commonPages.titleShouldHaveText('Alerting'); + listPage.tabShouldHaveText('Alerts'); + listPage.tabShouldHaveText('Silences'); + listPage.tabShouldHaveText('Alerting rules'); + commonPages.linkShouldExist('Export as CSV'); + commonPages.linkShouldExist('Clear all filters'); + listPage.ARRows.shouldBeLoaded(); + + cy.log('5.2. filter Alerts and click on Alert'); + listPage.filter.byName(`${WatchdogAlert.ALERTNAME}`); + listPage.ARRows.countShouldBe(1); + listPage.ARRows.ARShouldBe(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`, 1, 'Firing'); + listPage.ARRows.expandRow(); + listPage.ARRows.AShouldBe(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`, `${WatchdogAlert.NAMESPACE}`); + listPage.ARRows.clickAlert(); + + cy.log('5.3. click on Alert Details Page'); + commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); + commonPages.detailsPage.common(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`); + commonPages.detailsPage.alert(`${WatchdogAlert.ALERTNAME}`); + + const timeIntervalValue = getValFromElement(`[data-ouia-component-id^="OUIA-Generated-TextInputBase"]`); + timeIntervalValue.then((value) => { + expect(value).to.not.be.empty; + }); + + cy.log('5.4. click on Alert Rule link'); + detailsPage.clickAlertRule(`${WatchdogAlert.ALERTNAME}`); + commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); + commonPages.detailsPage.alertRule; + commonPages.detailsPage.common(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`); + cy.get(`[class="pf-v6-c-code-block__content"]`).invoke('text').then((expText) => { + cy.log(`${expText}`); + cy.wrap(expText).as('alertExpression'); + }); + + + cy.log('5.5. click on Alert Details Page'); + detailsPage.clickAlertDesc(`${WatchdogAlert.ALERT_DESC}`); + commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); + commonPages.detailsPage.common(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`); + commonPages.detailsPage.alert(`${WatchdogAlert.ALERTNAME}`); + + cy.log('5.6. click on Inspect on Alert Details Page'); + detailsPage.clickInspectAlertPage(); + + cy.log('5.7. Metrics page is loaded'); + commonPages.titleShouldHaveText('Metrics'); + + cy.log('5.8. Assert Expression'); + cy.get('[class="cm-line"]').should('be.visible'); + cy.get(`@alertExpression`).then((expText) => { + cy.log(`${expText}`); + cy.get('[class="cm-line"]').invoke('text').should('equal', `${expText}`); + }); }); - cy.log('5.4. click on Alert Rule link'); - detailsPage.clickAlertRule(`${WatchdogAlert.ALERTNAME}`); - commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); - commonPages.detailsPage.alertRule; - commonPages.detailsPage.common(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`); - cy.get(`[class="pf-v6-c-code-block__content"]`).invoke('text').then((expText) => { - cy.log(`${expText}`); - cy.wrap(expText).as('alertExpression'); - }); - - - cy.log('5.5. click on Alert Details Page'); - detailsPage.clickAlertDesc(`${WatchdogAlert.ALERT_DESC}`); - commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); - commonPages.detailsPage.common(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`); - commonPages.detailsPage.alert(`${WatchdogAlert.ALERTNAME}`); - - cy.log('5.6. click on Inspect on Alert Details Page'); - detailsPage.clickInspectAlertPage(); - - cy.log('5.7. Metrics page is loaded'); - commonPages.titleShouldHaveText('Metrics'); - - cy.log('5.8. Assert Expression'); - cy.get('[class="cm-line"]').should('be.visible'); - cy.get(`@alertExpression`).then((expText) => { - cy.log(`${expText}`); - cy.get('[class="cm-line"]').invoke('text').should('equal', `${expText}`); - }); - }); - it(`${perspective.name} perspective - Creates and expires a Silence`, () => { cy.log('6.1 filter to Watchdog alert'); nav.tabs.switchTab('Alerts'); @@ -147,6 +150,7 @@ export function testBVTMonitoring(perspective: PerspectiveConfig) { cy.log('6.8 verify on Alerting Rules list page again'); nav.sidenav.clickNavLink(['Observe', 'Alerting']); nav.tabs.switchTab('Alerting rules'); + listPage.filter.byName(`${WatchdogAlert.ALERTNAME}`); alertingRuleListPage.ARShouldBe(`${WatchdogAlert.ALERTNAME}`, `${WatchdogAlert.SEVERITY}`, 1, AlertsAlertState.SILENCED); diff --git a/web/cypress/support/monitoring/02.reg_metrics_1.cy.ts b/web/cypress/support/monitoring/02.reg_metrics_1.cy.ts index aaca4c269..53be0e3fb 100644 --- a/web/cypress/support/monitoring/02.reg_metrics_1.cy.ts +++ b/web/cypress/support/monitoring/02.reg_metrics_1.cy.ts @@ -160,7 +160,7 @@ export function testMetricsRegression1(perspective: PerspectiveConfig) { metricsPage.clickActionsDeleteAllQueries(); metricsPage.clickPredefinedQuery(MetricsPagePredefinedQueries.CPU_USAGE); metricsPage.graphCardInlineInfoAssertion(true); - metricsPage.clickGraphTimespanDropdown(GraphTimespan.ONE_WEEK); + metricsPage.clickGraphTimespanDropdown(GraphTimespan.TWO_WEEKS); metricsPage.graphCardInlineInfoAssertion(false); cy.log('4.6 Reset Zoom Button'); diff --git a/web/cypress/support/monitoring/03.reg_legacy_dashboards.cy.ts b/web/cypress/support/monitoring/03.reg_legacy_dashboards.cy.ts index 9955344d7..e4096ccdf 100644 --- a/web/cypress/support/monitoring/03.reg_legacy_dashboards.cy.ts +++ b/web/cypress/support/monitoring/03.reg_legacy_dashboards.cy.ts @@ -92,16 +92,11 @@ export function testLegacyDashboardsRegression(perspective: PerspectiveConfig) { listPage.ARRows.clickAlertingRule(); commonPages.titleShouldHaveText(`${WatchdogAlert.ALERTNAME}`); alertingRuleDetailsPage.clickHideGraphButton(); - cy.wait(2000); cy.byTestID(DataTestIDs.MetricGraph).should('not.exist'); alertingRuleDetailsPage.clickShowGraphButton(); - cy.wait(2000); cy.byTestID(DataTestIDs.MetricGraph).should('be.visible'); - cy.wait(2000); alertingRuleDetailsPage.clickHideGraphButton(); - cy.wait(2000); cy.byTestID(DataTestIDs.MetricGraph).should('not.exist'); - cy.wait(2000); cy.log('4.4 Observe > Alert details - Verify graph is visible'); cy.byTestID(DataTestIDs.AlertResourceLink).first().click(); diff --git a/web/cypress/support/monitoring/06.reg_legacy_dashboards_namespace.cy.ts b/web/cypress/support/monitoring/06.reg_legacy_dashboards_namespace.cy.ts index d8de89a78..cc3b99873 100644 --- a/web/cypress/support/monitoring/06.reg_legacy_dashboards_namespace.cy.ts +++ b/web/cypress/support/monitoring/06.reg_legacy_dashboards_namespace.cy.ts @@ -7,7 +7,6 @@ import { alertingRuleDetailsPage } from '../../views/alerting-rule-details-page' import { alerts } from '../../fixtures/monitoring/alert'; import { listPage } from '../../views/list-page'; import { commonPages } from '../../views/common'; -import { guidedTour } from '../../views/tour'; export interface PerspectiveConfig { name: string; @@ -61,9 +60,6 @@ export function testLegacyDashboardsRegressionNamespace(perspective: Perspective it(`${perspective.name} perspective - Dashboards (legacy) - No kebab dropdown`, () => { cy.log('3.1 Single Stat - No kebab dropdown'); - cy.visit('/'); - guidedTour.close(); - cy.validateLogin(); nav.sidenav.clickNavLink(['Observe', 'Dashboards']); commonPages.titleShouldHaveText('Dashboards'); cy.changeNamespace('openshift-monitoring'); diff --git a/web/cypress/views/alerting-rule-list-page.ts b/web/cypress/views/alerting-rule-list-page.ts index 807956c41..2f9ce8b6b 100644 --- a/web/cypress/views/alerting-rule-list-page.ts +++ b/web/cypress/views/alerting-rule-list-page.ts @@ -26,7 +26,6 @@ export const alertingRuleListPage = { throw error; } }, - }, clickAlertingRule: (alertRule: string) => { diff --git a/web/cypress/views/common.ts b/web/cypress/views/common.ts index e69fd524a..fa183efd5 100644 --- a/web/cypress/views/common.ts +++ b/web/cypress/views/common.ts @@ -1,5 +1,4 @@ import { detailsPage } from "./details-page"; -import { nav } from "./nav"; import { DataTestIDs, Classes } from "../../src/components/data-test"; export const commonPages = { @@ -7,7 +6,14 @@ export const commonPages = { projectDropdownShouldExist: () => cy.byLegacyTestID('namespace-bar-dropdown').should('exist'), titleShouldHaveText: (title: string) => { cy.log('commonPages.titleShouldHaveText - ' + `${title}`); - cy.bySemanticElement('h1', title).scrollIntoView().should('be.visible'); + cy.waitUntil(() => cy.bySemanticElement('h1', title).scrollIntoView().should('be.visible'), { + timeout: 60000, + }); + }, + + titleModalShouldHaveText: (title: string) => { + cy.log('commonPages.titleModalShouldHaveText - ' + `${title}`); + cy.bySemanticElement('h2', title).scrollIntoView().should('be.visible'); }, linkShouldExist: (linkName: string) => { diff --git a/web/cypress/views/perses-dashboards.ts b/web/cypress/views/perses-dashboards.ts index 9448cd1af..a9d6515af 100644 --- a/web/cypress/views/perses-dashboards.ts +++ b/web/cypress/views/perses-dashboards.ts @@ -16,7 +16,6 @@ export const persesDashboardsPage = { cy.byTestID(DataTestIDs.PersesDashboardDropdown).find('input').should('be.visible'); cy.byTestID(DataTestIDs.PersesDashboardDropdown).find('button').should('be.visible'); cy.byLegacyTestID(LegacyTestIDs.PersesDashboardSection).should('be.visible'); - }, clickTimeRangeDropdown: (timeRange: persesDashboardsTimeRange) => {