Skip to content

Commit 0a520a2

Browse files
DavidRajnohaclaude
andcommitted
fix(tests): harden incident filter selectors and scroll visibility
Extract incident IDs from data-test attributes instead of text content to avoid description text pollution. Use container existence check instead of visibility assertion for 0-height dropdown. Add scrollIntoView and .first() to fix viewport and multi-element ambiguity issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 96b1d46 commit 0a520a2

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

web/cypress/e2e/incidents/01.incidents.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,11 @@ describe('BVT: Incidents - UI', { tags: ['@smoke', '@incidents'] }, () => {
9595

9696
it('6. Admin perspective - Incidents page - Bar click selection walkthrough', () => {
9797
cy.log('6.1 Load multi-incident fixture and verify chart bars are clickable');
98+
incidentsPage.setDays('7 days');
9899
cy.mockIncidentFixture(
99100
'incident-scenarios/1-single-incident-firing-critical-and-warning-alerts.yaml',
100101
);
101-
incidentsPage.goTo();
102102
incidentsPage.clearAllFilters();
103-
incidentsPage.setDays('7 days');
104103
incidentsPage.elements.incidentsChartContainer().should('be.visible');
105104

106105
cy.log('6.2 Select incident bar and verify table appears with expected alerts');

web/cypress/e2e/incidents/regression/01.reg_filtering.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('Regression: Incidents Filtering', { tags: ['@incidents'] }, () => {
122122

123123
cy.log('2.3 Select an incident by ID filter and verify table appears');
124124
incidentsPage.selectIncidentIdFilter(ids[0]);
125-
incidentsPage.elements.incidentsTable().should('be.visible');
125+
incidentsPage.elements.incidentsTable().scrollIntoView().should('be.visible');
126126
incidentsPage.elements.incidentsChartBarsGroups().should('have.length', 1);
127127

128128
cy.log('2.4 Clear the Incident ID filter and verify all incidents return');
@@ -144,10 +144,10 @@ describe('Regression: Incidents Filtering', { tags: ['@incidents'] }, () => {
144144
cy.mockIncidentFixture('incident-scenarios/7-comprehensive-filtering-test-scenarios.yaml');
145145
incidentsPage.clearAllFilters();
146146
incidentsPage.selectIncidentIdFilter('etcd-critical-warning-001');
147-
incidentsPage.elements.incidentsTable().should('be.visible');
147+
incidentsPage.elements.incidentsTable().scrollIntoView().should('be.visible');
148148
incidentsPage.elements.incidentsTableComponentCell(0).should('contain.text', 'etcd');
149149
incidentsPage.expandRow(0);
150-
incidentsPage.elements.incidentsDetailsTable().should('be.visible');
150+
incidentsPage.elements.incidentsDetailsTable().scrollIntoView().should('be.visible');
151151
incidentsPage.elements
152152
.incidentsDetailsTable()
153153
.should('contain.text', 'EtcdClusterUnavailable001');

web/cypress/e2e/incidents/regression/04.reg_redux_effects.cy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ describe('Regression: Redux State Management', { tags: ['@incidents', '@incident
123123
.first()
124124
.click({ force: true });
125125

126-
incidentsPage.elements.alertsChartContainer().should('be.visible');
127-
incidentsPage.elements.incidentIdFilterChip().should('be.visible');
126+
incidentsPage.elements.alertsChartContainer().first().scrollIntoView().should('be.visible');
127+
incidentsPage.elements.incidentIdFilterChip().first().scrollIntoView().should('be.visible');
128128

129129
dropdown.setup();
130130

@@ -153,11 +153,11 @@ describe('Regression: Redux State Management', { tags: ['@incidents', '@incident
153153
incidentsPage.elements.incidentsChartBarsVisiblePathsNonEmpty().first().click({ force: true });
154154

155155
cy.log('3.4 Verify incident ID filter chip appears');
156-
incidentsPage.elements.incidentIdFilterChip().should('be.visible');
156+
incidentsPage.elements.incidentIdFilterChip().first().should('be.visible');
157157

158158
cy.log('3.5 Verify both Critical and Incident ID chips are present');
159159
incidentsPage.elements.filterChipValue('Critical').should('be.visible');
160-
incidentsPage.elements.incidentIdFilterChip().should('be.visible');
160+
incidentsPage.elements.incidentIdFilterChip().first().should('be.visible');
161161

162162
cy.log(
163163
'3.6 Deselect Critical and Apply Warning filter (which does not match the critical incident)',
@@ -174,7 +174,7 @@ describe('Regression: Redux State Management', { tags: ['@incidents', '@incident
174174

175175
cy.log('3.8 Verify BOTH Warning filter and Incident ID filter are still applied');
176176
incidentsPage.elements.filterChipValue('Warning').should('be.visible');
177-
incidentsPage.elements.incidentIdFilterChip().should('be.visible');
177+
incidentsPage.elements.incidentIdFilterChip().first().should('be.visible');
178178

179179
cy.log(
180180
'SUCCESS: Incident ID filter was not removed when non-matching severity filter was added',
@@ -187,7 +187,7 @@ describe('Regression: Redux State Management', { tags: ['@incidents', '@incident
187187

188188
cy.log('3.10 With only Incident ID filter, incident should be visible again');
189189
incidentsPage.elements.incidentsChartBarsGroups().should('have.length', 1);
190-
incidentsPage.elements.incidentIdFilterChip().should('be.visible');
190+
incidentsPage.elements.incidentIdFilterChip().first().should('be.visible');
191191
cy.log('SUCCESS: Incident reappears when conflicting filter removed');
192192
});
193193
});

web/cypress/views/incidents-page.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ export const incidentsPage = {
189189
.incidentsDetailsTable()
190190
.find('tbody tr')
191191
.eq(index)
192-
.find('td[data-label="expanded-details-alertname"]'),
192+
.find('td[data-label="expanded-details-alertname"]')
193+
.scrollIntoView(),
193194
incidentsDetailsAlertRuleLink: (index: number) =>
194195
incidentsPage.elements
195196
.incidentsDetailsTable()
@@ -445,18 +446,21 @@ export const incidentsPage = {
445446

446447
incidentsPage.ensureFilterTypeSelected('Incident ID');
447448
incidentsPage.elements.incidentIdFilterToggle().scrollIntoView().click({ force: true });
448-
incidentsPage.elements.incidentIdFilterList().should('be.visible');
449449

450+
// Container has 0 height so .should('be.visible') fails on it.
451+
// Empty list is valid (no incidents), so we wait for the container then read items.
452+
// Extract IDs from data-test attributes to avoid reading text that includes descriptions.
453+
const prefix = `${DataTestIDs.IncidentsPage.FiltersSelectOption}-incident id-`;
450454
return incidentsPage.elements
451455
.incidentIdFilterList()
452-
.find('button[role="menuitem"] .pf-v6-c-menu__item-text')
453-
.then(($texts) => {
456+
.should('exist')
457+
.then(($list) => {
458+
const $items = $list.find(`[data-test^="${prefix}"]`);
454459
const ids: string[] = [];
455-
$texts.each((_, el) => {
456-
const text = Cypress.$(el).text().trim();
457-
if (text) ids.push(text);
460+
$items.each((_, el) => {
461+
const id = Cypress.$(el).attr('data-test')?.slice(prefix.length);
462+
if (id) ids.push(id);
458463
});
459-
// Close the dropdown without selecting
460464
incidentsPage.elements.incidentIdFilterToggle().scrollIntoView().click({ force: true });
461465
return cy.wrap(ids, _qLog());
462466
});

0 commit comments

Comments
 (0)