From 2012f294220f4a3537aa0ef4f48b30ffb559c51a Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Wed, 5 Feb 2025 10:02:03 -0800 Subject: [PATCH] Update notebooks and traces tests with dynamic wait (#1693) * Fix flaky notebook, traces tests Signed-off-by: Shenoy Pratik * waits for reporting panel to appear Signed-off-by: Shenoy Pratik * wait for paragraph to run Signed-off-by: Shenoy Pratik * update reporting context menu interaction Signed-off-by: Shenoy Pratik * wait for all notebooks to be loaded Signed-off-by: Shenoy Pratik --------- Signed-off-by: Shenoy Pratik (cherry picked from commit 68eb31f5d9e7f1cd23330ac4d28659d8616bf744) --- .../2_trace_analytics_services.spec.js | 2 +- .../6_notebooks.spec.js | 74 +++++++++++-------- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/cypress/integration/plugins/observability-dashboards/2_trace_analytics_services.spec.js b/cypress/integration/plugins/observability-dashboards/2_trace_analytics_services.spec.js index 57ae03624..13d6b6b04 100644 --- a/cypress/integration/plugins/observability-dashboards/2_trace_analytics_services.spec.js +++ b/cypress/integration/plugins/observability-dashboards/2_trace_analytics_services.spec.js @@ -9,7 +9,6 @@ import { SERVICE_NAME, setTimeFilter, delayTime, - TIMEOUT_DELAY, } from '../../../utils/constants'; describe('Testing services table', () => { @@ -32,6 +31,7 @@ describe('Testing services table', () => { }); it('Opens service flyout', () => { + cy.contains('6.42').should('exist'); cy.get('button[data-test-subj^="service-flyout-action-btn"]') .first() .click(); diff --git a/cypress/integration/plugins/observability-dashboards/6_notebooks.spec.js b/cypress/integration/plugins/observability-dashboards/6_notebooks.spec.js index 99efd8245..b26b6570b 100644 --- a/cypress/integration/plugins/observability-dashboards/6_notebooks.spec.js +++ b/cypress/integration/plugins/observability-dashboards/6_notebooks.spec.js @@ -52,18 +52,37 @@ const makePopulatedParagraph = () => { cy.get('textarea[data-test-subj="editorArea-0"]').focus(); cy.get('textarea[data-test-subj="editorArea-0"]').type(MARKDOWN_TEXT); cy.get('button[data-test-subj="runRefreshBtn-0"]').click(); + cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist'); + cy.get(`a[href="${SAMPLE_URL}"]`).should('exist'); + cy.get('code').contains('POST').should('exist'); }; -const deleteNotebook = (notebookName) => { - moveToNotebookHome(); +const deleteNotebook = () => { + cy.get('button[data-test-subj="notebook-delete-icon"]').click(); + cy.get('input[data-test-subj="delete-notebook-modal-input"]').type('delete'); + cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should( + 'not.be.disabled' + ); + cy.get( + 'button[data-test-subj="delete-notebook-modal-delete-button"]' + ).click(); +}; - cy.contains('.euiTableRow', notebookName) - .find('input[type="checkbox"]') - .check(); +const deleteAllNotebooks = () => { + cy.intercept( + 'DELETE', + '/api/observability/notebooks/note/savedNotebook/*' + ).as('deleteNotebook'); + moveToNotebookHome(); - cy.get('[data-test-subj="deleteSelectedNotebooks"]').click(); + cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist'); - cy.get('input[data-test-subj="delete-notebook-modal-input"]').focus(); + cy.get('input[data-test-subj="checkboxSelectAll"]').should('exist'); + cy.get('input[data-test-subj="checkboxSelectAll"]').click(); + cy.get('button[data-test-subj="deleteSelectedNotebooks"]') + .contains('Delete 4 notebooks') + .should('exist'); + cy.get('button[data-test-subj="deleteSelectedNotebooks"]').click(); cy.get('input[data-test-subj="delete-notebook-modal-input"]').type('delete'); cy.get('button[data-test-subj="delete-notebook-modal-delete-button"]').should( 'not.be.disabled' @@ -71,9 +90,8 @@ const deleteNotebook = (notebookName) => { cy.get( 'button[data-test-subj="delete-notebook-modal-delete-button"]' ).click(); - moveToNotebookHome(); - cy.contains('.euiTableRow', notebookName).should('not.exist'); + cy.wait('@deleteNotebook').its('response.statusCode').should('eq', 200); }; describe('Testing notebook actions', () => { @@ -83,9 +101,7 @@ describe('Testing notebook actions', () => { }); afterEach(() => { - cy.get('@notebook').then((notebook) => { - deleteNotebook(notebook.name); - }); + deleteNotebook(); }); it('Creates a code paragraph', () => { @@ -99,9 +115,6 @@ describe('Testing notebook actions', () => { it('Renders markdown', () => { makePopulatedParagraph(); - cy.get('textarea[data-test-subj="editorArea-0"]').should('not.exist'); - cy.get(`a[href="${SAMPLE_URL}"]`).should('exist'); - cy.get('code').contains('POST').should('exist'); cy.get('td').contains('b2').should('exist'); }); }); @@ -114,35 +127,39 @@ describe('Test reporting integration if plugin installed', () => { skipOn($body.find('#reportingActionsButton').length <= 0); }); makePopulatedParagraph(); + cy.get('.euiContextMenuPanel').should('not.exist'); + cy.get('button[data-test-subj="reporting-actions-button"]').should( + 'be.visible' + ); + cy.get('button[data-test-subj="reporting-actions-button"]').click(); }); - afterEach(() => { - cy.get('@notebook').then((notebook) => { - deleteNotebook(notebook.name); - }); + after(() => { + deleteAllNotebooks(); }); it('Create in-context PDF report from notebook', () => { - cy.get('#reportingActionsButton').click(); cy.get('button.euiContextMenuItem:nth-child(1)') .contains('Download PDF') - .click(); - cy.get('body').contains('Please continue report generation in the new tab'); + .click({ force: true }); + cy.get('body') + .contains('Please continue report generation in the new tab') + .should('exist'); }); it('Create in-context PNG report from notebook', () => { - cy.get('#reportingActionsButton').click(); cy.get('button.euiContextMenuItem:nth-child(2)') .contains('Download PNG') - .click(); - cy.get('body').contains('Please continue report generation in the new tab'); + .click({ force: true }); + cy.get('body') + .contains('Please continue report generation in the new tab') + .should('exist'); }); it('Create on-demand report definition from context menu', () => { - cy.get('#reportingActionsButton').click(); cy.get('button.euiContextMenuItem:nth-child(3)') .contains('Create report definition') - .click(); + .click({ force: true }); cy.location('pathname', { timeout: delayTime * 3 }).should( 'include', '/reports-dashboards' @@ -152,10 +169,9 @@ describe('Test reporting integration if plugin installed', () => { }); it('View reports homepage from context menu', () => { - cy.get('#reportingActionsButton').click(); cy.get('button.euiContextMenuItem:nth-child(4)') .contains('View reports') - .click(); + .click({ force: true }); cy.location('pathname', { timeout: delayTime * 3 }).should( 'include', '/reports-dashboards'