diff --git a/dashboards-observability/.cypress/integration/notebooks.spec.js b/dashboards-observability/.cypress/integration/notebooks.spec.js index d15b922a7..ca0083249 100644 --- a/dashboards-observability/.cypress/integration/notebooks.spec.js +++ b/dashboards-observability/.cypress/integration/notebooks.spec.js @@ -18,6 +18,18 @@ import { SAMPLE_PANEL } from '../utils/panel_constants'; import { skipOn } from '@cypress/skip-test'; +const moveToEventsHome = () => { + cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics/`); + cy.wait(delay * 3); +}; + +const moveToPanelHome = () => { + cy.visit( + `${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels/` + ); + cy.wait(delay * 3); +}; + describe('Adding sample data and visualization', () => { it('Adds sample flights data for visualization paragraph', () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/home#/tutorial_directory/sampleData`); @@ -27,17 +39,22 @@ describe('Adding sample data and visualization', () => { }); it('Add sample observability data', () => { - cy.visit( - `${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels/` - ); - cy.get('.euiButton__text').contains('Actions').click(); - cy.get('.euiContextMenuItem__text').contains('Add samples').click(); + moveToPanelHome(); + cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click(); + cy.wait(100); + cy.get('.euiContextMenuItem__text').contains('Add samples').trigger('mouseover').click(); + cy.wait(100 * 3); cy.get('.euiModalHeader__title[data-test-subj="confirmModalTitleText"]') .contains('Add samples') .should('exist'); - cy.get('.euiButton__text').contains('Yes').click(); - cy.wait(delay * 5); - cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); + cy.wait(100); + cy.get('.euiButton__text').contains('Yes').trigger('mouseover').click(); + cy.wait(100 * 5); + cy.route2('POST', '/addSamplePanels').as('addSamples'); + cy.wait('@addSamples').then(() => { + cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); + }); + cy.wait(100); }); }); @@ -235,7 +252,7 @@ describe('Testing paragraphs', () => { }); it('Renders input only mode', () => { - cy.get('.euiToggle__input[title="Input only"]').click(); + cy.get('.euiButton__text[title="Input only"]').click(); cy.wait(delay); cy.get('div.markdown-body').should('not.exist'); @@ -248,7 +265,7 @@ describe('Testing paragraphs', () => { }); it('Renders output only mode', () => { - cy.get('.euiToggle__input[title="Output only"]').click(); + cy.get('.euiButton__text[title="Output only"]').click(); cy.wait(delay); cy.get('button[aria-label="Open paragraph menu"]').should('not.exist'); @@ -279,7 +296,9 @@ describe('Testing paragraphs', () => { cy.get('.euiButton__text').contains('Browse').click(); cy.wait(delay); - cy.get('.euiFieldSearch').focus().type('[Flights] Flight Count and Average Ticket Price{enter}'); + cy.get('.euiFieldSearch') + .focus() + .type('[Flights] Flight Count and Average Ticket Price{enter}'); cy.wait(delay); cy.get('.euiButton__text').contains('Select').click(); cy.wait(delay); @@ -444,7 +463,7 @@ describe('Testing paragraphs', () => { cy.get('.euiButton__text').contains('Create notebook').should('exist'); }); - + it('Cleans up test notebooks', () => { cy.get('[data-test-subj="notebook-notebook-actions-button"]').click(); cy.wait(delay); @@ -461,3 +480,43 @@ describe('Testing paragraphs', () => { cy.get('.euiText').contains('No notebooks').should('exist'); }); }); + +describe('clean up all test data', () => { + it('Delete visualizations from event analytics', () => { + moveToEventsHome(); + cy.get('[data-test-subj="tablePaginationPopoverButton"]').trigger('mouseover').click(); + cy.get('.euiContextMenuItem__text').contains('50 rows').trigger('mouseover').click(); + cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]').trigger('mouseover').click(); + cy.wait(delay); + cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click(); + cy.wait(delay); + cy.get('.euiContextMenuItem__text').contains('Delete').trigger('mouseover').click(); + cy.wait(delay); + cy.get('button.euiButton--danger').should('be.disabled'); + cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', { + delay: 50, + }); + cy.get('button.euiButton--danger').should('not.be.disabled'); + cy.get('.euiButton__text').contains('Delete').trigger('mouseover').click(); + cy.wait(delay); + cy.get('.euiTextAlign').contains('No Queries or Visualizations').should('exist'); + }); + + it('Deletes test panel', () => { + moveToPanelHome(); + cy.get('.euiCheckbox__input[data-test-subj="checkboxSelectAll"]').trigger('mouseover').click(); + cy.wait(delay); + cy.get('.euiButton__text').contains('Actions').trigger('mouseover').click(); + cy.wait(delay); + cy.get('.euiContextMenuItem__text').contains('Delete').trigger('mouseover').click(); + cy.wait(delay); + cy.get('button.euiButton--danger').should('be.disabled'); + cy.get('input.euiFieldText[placeholder="delete"]').focus().type('delete', { + delay: 50, + }); + cy.get('button.euiButton--danger').should('not.be.disabled'); + cy.get('.euiButton__text').contains('Delete').trigger('mouseover').click(); + + cy.get('.euiTextAlign').contains('No Operational Panels').should('exist'); + }); +});