|
| 1 | +/* |
| 2 | +Regression test for mixed severity interval boundary times (Section 2.3.3). |
| 3 | +
|
| 4 | +Test 1 (OU-1205): Verifies tooltip End times at severity interval boundaries |
| 5 | +are rounded to 5-minute precision. Without rounding, consecutive interval end |
| 6 | +times can land on non-5-minute values (e.g., "10:58" instead of "11:00"). |
| 7 | +
|
| 8 | +Test 2 (OU-1221, XFAIL): Verifies Start times shown in incident tooltips match |
| 9 | +alert tooltips and alerts table, and that consecutive segment boundaries align |
| 10 | +with no 5-minute gap between End of one segment and Start of the next. |
| 11 | +*/ |
| 12 | + |
| 13 | +import { incidentsPage } from '../../../views/incidents-page'; |
| 14 | + |
| 15 | +const MCP = { |
| 16 | + namespace: Cypress.env('COO_NAMESPACE'), |
| 17 | + packageName: 'cluster-observability-operator', |
| 18 | + operatorName: 'Cluster Observability Operator', |
| 19 | + config: { |
| 20 | + kind: 'UIPlugin', |
| 21 | + name: 'monitoring', |
| 22 | + }, |
| 23 | +}; |
| 24 | + |
| 25 | +const MP = { |
| 26 | + namespace: 'openshift-monitoring', |
| 27 | + operatorName: 'Cluster Monitoring Operator', |
| 28 | +}; |
| 29 | + |
| 30 | +describe('Regression: Mixed Severity Interval Boundary Times', { tags: ['@incidents', '@xfail'] }, () => { |
| 31 | + |
| 32 | + before(() => { |
| 33 | + cy.beforeBlockCOO(MCP, MP, { dashboards: false, troubleshootingPanel: false }); |
| 34 | + }); |
| 35 | + |
| 36 | + beforeEach(() => { |
| 37 | + cy.mockIncidentFixture('incident-scenarios/21-multi-severity-boundary-times.yaml'); |
| 38 | + }); |
| 39 | + |
| 40 | + const extractTime = (tooltipText: string, field: 'Start' | 'End'): string => { |
| 41 | + const afterField = tooltipText.split(field)[1] || ''; |
| 42 | + const match = afterField.match(/(\d{1,2}:\d{2}(\s*[AP]M)?)/); |
| 43 | + return match ? match[1].trim() : ''; |
| 44 | + }; |
| 45 | + |
| 46 | + it('1. Tooltip End times at severity boundaries show 5-minute rounded values', () => { |
| 47 | + const verifyEndTimeRounded = (label: string) => { |
| 48 | + incidentsPage.elements.tooltip() |
| 49 | + .invoke('text') |
| 50 | + .then((text) => { |
| 51 | + cy.log(`${label} tooltip: "${text}"`); |
| 52 | + |
| 53 | + if (text.match(/End.*---/)) { |
| 54 | + cy.log(`${label}: Firing, End shows --- (skipped)`); |
| 55 | + return; |
| 56 | + } |
| 57 | + |
| 58 | + const endPart = text.split('End')[1]; |
| 59 | + expect(endPart, `${label}: should contain End time`).to.exist; |
| 60 | + |
| 61 | + const timeMatch = endPart.match(/(\d{1,2}):(\d{2})/); |
| 62 | + expect(timeMatch, `${label}: End time should be parseable`).to.not.be.null; |
| 63 | + |
| 64 | + const minutes = parseInt(timeMatch[2], 10); |
| 65 | + const remainder = minutes % 5; |
| 66 | + expect(remainder, `${label}: End minutes (${minutes}) should be divisible by 5, remainder=${remainder}`).to.equal(0); |
| 67 | + cy.log(`${label}: End ${timeMatch[1]}:${timeMatch[2]} - minutes divisible by 5`); |
| 68 | + }); |
| 69 | + }; |
| 70 | + |
| 71 | + cy.log('1.1 Verify multi-severity incident loaded'); |
| 72 | + incidentsPage.clearAllFilters(); |
| 73 | + incidentsPage.setDays('1 day'); |
| 74 | + incidentsPage.elements.incidentsChartContainer().should('be.visible'); |
| 75 | + incidentsPage.elements.incidentsChartBarsGroups().should('have.length', 1); |
| 76 | + |
| 77 | + cy.log('1.2 Verify bar has multiple severity segments'); |
| 78 | + incidentsPage.getIncidentBarVisibleSegments(0).then((segments) => { |
| 79 | + expect(segments.length, 'Multi-severity bar should have at least 2 visible segments') |
| 80 | + .to.be.greaterThan(1); |
| 81 | + cy.log(`Found ${segments.length} visible severity segments`); |
| 82 | + }); |
| 83 | + |
| 84 | + cy.log('1.3 Check first segment end time (Info -> Warning boundary)'); |
| 85 | + incidentsPage.hoverOverIncidentBarSegment(0, 0); |
| 86 | + verifyEndTimeRounded('First segment'); |
| 87 | + |
| 88 | + cy.log('1.4 Check second segment end time (Warning -> Critical boundary)'); |
| 89 | + incidentsPage.hoverOverIncidentBarSegment(0, 1); |
| 90 | + verifyEndTimeRounded('Second segment'); |
| 91 | + |
| 92 | + cy.log('1.5 Check third segment end time (Critical end)'); |
| 93 | + incidentsPage.hoverOverIncidentBarSegment(0, 2); |
| 94 | + verifyEndTimeRounded('Third segment'); |
| 95 | + |
| 96 | + cy.log('Verified: All tooltip End times at severity boundaries are at 5-minute precision (OU-1205)'); |
| 97 | + }); |
| 98 | + |
| 99 | + it('2. Start times match between incident tooltip, alert tooltip, and table; consecutive boundaries align', |
| 100 | + () => { |
| 101 | + cy.log('2.1 Setup: verify multi-severity incident loaded'); |
| 102 | + incidentsPage.clearAllFilters(); |
| 103 | + incidentsPage.setDays('1 day'); |
| 104 | + incidentsPage.elements.incidentsChartContainer().should('be.visible'); |
| 105 | + incidentsPage.elements.incidentsChartBarsGroups().should('have.length', 1); |
| 106 | + cy.pause(); |
| 107 | + |
| 108 | + cy.log('2.2 Consecutive interval boundaries: End of segment 1 should equal Start of segment 2'); |
| 109 | + incidentsPage.hoverOverIncidentBarSegment(0, 0); |
| 110 | + incidentsPage.elements.tooltip().invoke('text').then((firstText) => { |
| 111 | + const firstEnd = extractTime(firstText, 'End'); |
| 112 | + cy.log(`First segment End: ${firstEnd}`); |
| 113 | + expect(firstEnd, 'First segment End should be parseable').to.not.be.empty; |
| 114 | + |
| 115 | + incidentsPage.hoverOverIncidentBarSegment(0, 1); |
| 116 | + incidentsPage.elements.tooltip().invoke('text').then((secondText) => { |
| 117 | + const secondStart = extractTime(secondText, 'Start'); |
| 118 | + cy.log(`Second segment Start: ${secondStart}`); |
| 119 | + expect(secondStart, 'Second segment Start should be parseable').to.not.be.empty; |
| 120 | + expect(secondStart, |
| 121 | + `No 5-min gap: second Start (${secondStart}) should equal first End (${firstEnd})` |
| 122 | + ).to.equal(firstEnd); |
| 123 | + }); |
| 124 | + }); |
| 125 | + cy.pause(); |
| 126 | + |
| 127 | + cy.log('2.3 Incident tooltip Start vs alert tooltip Start vs alerts table Start'); |
| 128 | + incidentsPage.hoverOverIncidentBarSegment(0, 0); |
| 129 | + incidentsPage.elements.tooltip().invoke('text').then((incidentText) => { |
| 130 | + const incidentStart = extractTime(incidentText, 'Start'); |
| 131 | + cy.log(`Incident tooltip Start: ${incidentStart}`); |
| 132 | + expect(incidentStart, 'Incident Start should be parseable').to.not.be.empty; |
| 133 | + |
| 134 | + cy.log('2.4 Select incident and get alert tooltip Start'); |
| 135 | + incidentsPage.selectIncidentById('monitoring-multi-severity-boundary-001'); |
| 136 | + incidentsPage.elements.alertsChartCard().should('be.visible'); |
| 137 | + |
| 138 | + incidentsPage.hoverOverAlertBar(0); |
| 139 | + incidentsPage.elements.alertsChartTooltip().invoke('text').then((alertText) => { |
| 140 | + const alertStart = extractTime(alertText, 'Start'); |
| 141 | + cy.log(`Alert tooltip Start: ${alertStart}`); |
| 142 | + expect(incidentStart, |
| 143 | + `Incident Start (${incidentStart}) should match alert Start (${alertStart})` |
| 144 | + ).to.equal(alertStart); |
| 145 | + }); |
| 146 | + |
| 147 | + cy.log('2.5 Compare incident tooltip Start with alerts table Start'); |
| 148 | + incidentsPage.getSelectedIncidentAlerts().then((alerts) => { |
| 149 | + expect(alerts.length, 'Should have at least 1 alert row').to.be.greaterThan(0); |
| 150 | + alerts[0].getStartCell().invoke('text').then((cellText) => { |
| 151 | + const tableMatch = cellText.trim().match(/(\d{1,2}:\d{2}(\s*[AP]M)?)/); |
| 152 | + expect(tableMatch, 'Table Start time should be parseable').to.not.be.null; |
| 153 | + const tableStart = tableMatch[1].trim(); |
| 154 | + cy.log(`Alerts table Start: ${tableStart}`); |
| 155 | + expect(incidentStart, |
| 156 | + `Incident Start (${incidentStart}) should match table Start (${tableStart})` |
| 157 | + ).to.equal(tableStart); |
| 158 | + }); |
| 159 | + }); |
| 160 | + }); |
| 161 | + cy.pause(); |
| 162 | + |
| 163 | + cy.log('Expected failure: Incident tooltip Start times are 5 minutes off (OU-1221)'); |
| 164 | + }); |
| 165 | +}); |
0 commit comments