From ec58ca94eea221bc5e6e12104f37724ec97cdc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Reme=C5=A1?= Date: Wed, 12 Aug 2026 12:56:21 +0200 Subject: [PATCH] test: improve OLS timeseries Cypress test stability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Target first Perses panel element to avoid ambiguity when multiple panels exist. Replace cy.wait() calls with proper Cypress assertions and timeouts. Improve dashboard creation verification by checking breadcrumb and edit mode buttons instead of page load helper. Signed-off-by: Tomáš Remeš Assisted-by: Claude Code:claude-opus-4-6 --- .../03.coo_lightspeed_show_timeseries.cy.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/web/cypress/e2e/coo/03.coo_lightspeed_show_timeseries.cy.ts b/web/cypress/e2e/coo/03.coo_lightspeed_show_timeseries.cy.ts index ddb839a04..808b080d9 100644 --- a/web/cypress/e2e/coo/03.coo_lightspeed_show_timeseries.cy.ts +++ b/web/cypress/e2e/coo/03.coo_lightspeed_show_timeseries.cy.ts @@ -93,15 +93,15 @@ describe('COO-LightSpeed: show_timeseries', { tags: ['@ols'] }, () => { .should('exist'); cy.get(SEL.persesPanel, { timeout: OLS_RESPONSE_TIMEOUT }) - .should('exist') + .first() .scrollIntoView() .should('be.visible'); - cy.get(SEL.persesPanel).find(SEL.persesSvg).should('exist'); + cy.get(SEL.persesPanel).first().find(SEL.persesSvg).should('exist'); - cy.get(SEL.persesPanel).should('contain.text', 'CPU'); - cy.get(SEL.persesPanel).should('contain.text', 'openshift-monitoring'); - cy.get(SEL.persesPanel).find('svg path[d]').should('have.length.greaterThan', 0); + cy.get(SEL.persesPanel).first().should('contain.text', 'CPU'); + cy.get(SEL.persesPanel).first().should('contain.text', 'openshift-monitoring'); + cy.get(SEL.persesPanel).first().find('svg path[d]').should('have.length.greaterThan', 0); }); it('adds the rendered chart to a new Perses dashboard via Add to Dashboard button', () => { @@ -121,7 +121,12 @@ describe('COO-LightSpeed: show_timeseries', { tags: ['@ols'] }, () => { persesCreateDashboardsPage.selectProject(DASHBOARD_PROJECT); persesCreateDashboardsPage.enterDashboardName(DASHBOARD_NAME); persesCreateDashboardsPage.createDashboardDialogCreateButton(); - persesDashboardsPage.shouldBeLoadedEditionMode(DASHBOARD_NAME); + commonPages.titleShouldHaveText('Dashboards'); + cy.byTestID('perses-dashboards-breadcrumb-dashboard-name-item') + .scrollIntoView() + .should('contain', DASHBOARD_NAME) + .should('be.visible'); + persesDashboardsPage.assertEditModeButtons(); persesDashboardsPage.shouldBeLoadedEditionModeFromCreateDashboard(); // Save the empty dashboard first so it exits edit mode @@ -149,20 +154,22 @@ describe('COO-LightSpeed: show_timeseries', { tags: ['@ols'] }, () => { cy.get(SEL.persesPanel, { timeout: OLS_RESPONSE_TIMEOUT }).should('exist'); - // Wait for the streaming response to stabilize before interacting - cy.wait(5000); - - // The "Add to dashboard" button should be visible because a dashboard is open. + // Wait for the "Add to dashboard" button to appear once the streaming response stabilizes. // The AI may return multiple show_timeseries tool calls, so pick the first one. // The button may be inside a collapsed tool-call accordion in the OLS chat, // so use force:true to click it regardless of visibility. - cy.get(SEL.aiResponse).last().find(SEL.addToDashboard).first().click({ force: true }); + cy.get(SEL.aiResponse, { timeout: OLS_RESPONSE_TIMEOUT }) + .last() + .find(SEL.addToDashboard, { timeout: OLS_RESPONSE_TIMEOUT }) + .first() + .click({ force: true }); // Close the chat panel to see the dashboard cy.get(SEL.chatButton).click(); + cy.get(SEL.chatPanel).should('not.exist'); // The dashboard should have entered edit mode and the panel should be added - cy.wait(5000); + persesDashboardsPage.assertEditModeButtons(); // Verify a panel was added to the dashboard cy.byDataTestID(persesMUIDataTestIDs.panelHeader).find('h6').should('be.visible');