From 99b502042691d984680f774a7a2b16f2c2ee891c Mon Sep 17 00:00:00 2001 From: Pratibha Pandey Date: Thu, 12 May 2022 04:19:28 -0700 Subject: [PATCH 1/2] Existing cypress test cases fixed Signed-off-by: Pratibha Pandey --- .../integration/app_analytics.spec.js | 51 ++++++++++++------- .../integration/event_analytics.spec.js | 17 ++++--- .../.cypress/integration/notebooks.spec.js | 45 +--------------- .../.cypress/utils/app_constants.js | 10 ++-- .../.cypress/utils/event_constants.js | 4 ++ 5 files changed, 54 insertions(+), 73 deletions(-) diff --git a/dashboards-observability/.cypress/integration/app_analytics.spec.js b/dashboards-observability/.cypress/integration/app_analytics.spec.js index 80a66b210..dc888fd0e 100644 --- a/dashboards-observability/.cypress/integration/app_analytics.spec.js +++ b/dashboards-observability/.cypress/integration/app_analytics.spec.js @@ -96,7 +96,14 @@ describe('Creating application', () => { cy.get('[data-test-subj="nameFormRow"]').type(nameOne); cy.get('[data-test-subj="descriptionFormRow"]').type('This application is for testing.'); cy.get('.euiAccordion').contains('Log source').trigger('mouseover').click(); - cy.get('[data-test-subj="searchAutocompleteTextArea"]').focus().type(baseQuery, {delay: TYPING_DELAY}); + cy.get('[data-test-subj="searchAutocompleteTextArea"]') + .trigger('mouseover') + .click() + .wait(3000) + .focus() + .type(baseQuery, { + delay: TYPING_DELAY, + }); cy.get('.euiAccordion').contains('Services & entities').trigger('mouseover').click(); cy.get('[data-test-subj="servicesEntitiesComboBox"]').click(); cy.focused().type('{downArrow}'); @@ -174,9 +181,10 @@ describe('Creating application', () => { cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('contain.value', ''); cy.get('.euiAccordion').contains('Services & entities').trigger('mouseover').click(); cy.get('[data-test-subj="servicesEntitiesComboBox"]').trigger('mouseover').click(); + cy.wait(delay); cy.get('.euiFilterSelectItem').contains(service_one).trigger('click'); cy.get('.euiBadge').contains('1').should('exist'); - cy.get('.euiAccordion-isOpen').within(($service) => { + cy.get('.euiAccordion-isOpen').within(() => { cy.get('.euiButton').contains('Clear all').click(); }) cy.get('.euiButton--danger').contains('Clear all').click(); @@ -188,7 +196,7 @@ describe('Creating application', () => { cy.get('.euiFilterSelectItem').contains(trace_one).trigger('click'); cy.get('.euiFilterSelectItem').contains(trace_two).trigger('click'); cy.get('.euiBadge').contains('2').should('exist'); - cy.get('.euiAccordion-isOpen').within(($trace) => { + cy.get('.euiAccordion-isOpen').within(() => { cy.get('.euiButton').contains('Clear all').click(); }) cy.get('.euiButton--danger').contains('Clear all').click(); @@ -253,6 +261,7 @@ describe('Viewing application', () => { cy.get('.euiLink').contains(nameOne).click(); cy.wait(delay); cy.get('.euiTitle').contains(nameOne).should('exist'); + changeTimeTo24('months'); cy.get('[data-test-subj="superDatePickerShowDatesButton"]').should('contain', 'Last 24 months'); cy.get('.euiBreadcrumb').contains('Application analytics').click(); cy.wait(delay); @@ -281,12 +290,13 @@ describe('Viewing application', () => { cy.wait(delay * 3); cy.get('.euiFlyout').contains('Service detail').should('be.visible'); cy.get('.euiFlyout').within(($flyout) => { - cy.get('.euiDescriptionList').contains('3.52').should('exist'); + cy.wait(delay); + cy.get('.euiDescriptionList').contains('3').should('exist'); cy.get('[data-text="Error rate"]').click(); cy.get('.ytitle').contains('Error rate').should('exist'); }); cy.get('[data-test-subj="euiFlyoutCloseButton"]').click(); - cy.get('.euiFlyout').should('not.be.visible'); + cy.get('.euiFlyout').should('not.exist'); cy.get('.euiLink').contains('authentication').click(); supressResizeObserverIssue(); cy.wait(delay * 3); @@ -294,7 +304,7 @@ describe('Viewing application', () => { cy.get('[data-test-subj="dataGridRowCell"] button').contains('718dc32a693c8a17').click(); cy.get('.euiFlyout').contains('Span detail').should('be.visible'); cy.get('[data-test-subj="euiFlyoutCloseButton"]').click(); - cy.get('.euiFlyout').should('not.be.visible'); + cy.get('.euiFlyout').should('not.exist'); }); it('Opens trace detail flyout when Trace ID is clicked', () => { @@ -308,14 +318,14 @@ describe('Viewing application', () => { }); cy.get('[data-test-subj="euiFlyoutCloseButton"]').click(); cy.wait(delay); - cy.get('.euiFlyout').should('not.be.visible'); + cy.get('.euiFlyout').should('not.exist'); cy.get('[title="03f9c770db5ee2f1caac0afc36db49ba"]').click(); cy.get('[data-text="Span list"]').click(); cy.wait(delay); cy.get('[data-test-subj="dataGridRowCell"] button').contains('d67c5bb617ba9203').click(); cy.get('.euiFlyout').contains('Span detail').should('be.visible'); cy.get('[data-test-subj="euiFlyoutCloseButton"]').click(); - cy.get('.euiFlyout').should('not.be.visible'); + cy.get('.euiFlyout').should('not.exist'); }); it('Opens span detail flyout when Span ID is clicked', () => { @@ -368,17 +378,17 @@ describe('Viewing application', () => { it('Adds availability level to visualization #1', () => { cy.get('.euiTab').contains('Panel').click(); cy.wait(delay); - cy.get('[aria-label="actionMenuButton"]').click(); + cy.get('[aria-label="actionMenuButton"]').eq(0).click(); cy.get('.euiContextMenuItem').contains('Edit').click(); supressResizeObserverIssue(); cy.wait(delay); cy.get('[data-test-subj="superDatePickerShowDatesButton"]').should('contain', 'Last 24 months'); - cy.get('.euiBadge').contains('Bar').click(); + cy.get('[data-test-subj = "configPane__vizTypeSelector"]').contains('Bar').click({force:true}); cy.focused().type('{downArrow}'); cy.focused().type('{enter}'); cy.wait(delay); cy.get('.euiButton').contains('+ Add availability level').click(); - cy.get('[data-test-subj="euiColorPickerAnchor"]').click(); + cy.get('[data-test-subj="euiColorPickerAnchor"]').eq(0).click(); cy.get('[aria-label="Select #54B399 as the color"]').click(); cy.wait(delay); cy.get('[data-test-subj="nameFieldText"]').click().type('Available'); @@ -581,7 +591,9 @@ describe('Application Analytics home page', () => { }) it('Show correct information in table', () => { + cy.wait(delay); cy.get('.euiLink').contains(nameOne).should('exist'); + cy.wait(delay); cy.get('[data-test-subj="appAnalytics__compositionColumn"]').contains(composition).should('exist'); cy.get('.euiBadge').contains('Available').should('exist'); cy.get('[style="background-color: rgb(84, 179, 153); color: rgb(0, 0, 0);"]').should('exist'); @@ -599,29 +611,32 @@ describe('Application Analytics home page', () => { cy.get('.euiContextMenuItem').contains('Rename').click(); cy.get('.euiFieldText').clear().focus().type(newName); cy.get('.euiButton--fill').contains('Rename').click(); - cy.wait(delay); - cy.get('.euiToast').contains(`Application successfully renamed to "${newName}"`); + cy.get('.euiToast').contains(`Application successfully renamed to "${newName}"`),{timeout: 10000}; cy.get('.euiTableRow').first().within(($row) => { cy.get('.euiLink').contains(newName).should('exist'); }); }); it('Deletes application', () => { - cy.get('.euiPopover').contains('Actions').click(); + cy.get('.euiPopover--anchorDownCenter').contains('Actions').click(); cy.get('.euiContextMenuItem-isDisabled').contains('Delete').should('exist'); + cy.get('.euiPopover--anchorDownCenter').contains('Actions').click(); cy.get('.euiTableRow').eq(0).within(($row) => { cy.get('.euiCheckbox').click(); }); - cy.get('.euiTableRow').eq(1).within(($row) => { - cy.get('.euiCheckbox').click(); + cy.get('body').then(($body) => { + if ($body.find('.euiContextMenuItem').length > 0) { + cy.get('.euiPopover--anchorDownCenter').contains('Actions').click(); + cy.wait(delay); + } }); - cy.wait(delay); + cy.wait(delay * 4); cy.get('.euiPopover').contains('Actions').click(); cy.wait(delay); cy.get('.euiContextMenuItem').contains('Delete').click(); cy.get('.euiButton--fill').contains('Delete').click(); cy.wait(delay); - cy.get('.euiToast').contains(`Applications successfully deleted!`); + cy.get('.euiToast').contains(`Application "${newName}" successfully deleted!`); cy.get('.euiLink').contains(newName).should('not.exist'); }); }); diff --git a/dashboards-observability/.cypress/integration/event_analytics.spec.js b/dashboards-observability/.cypress/integration/event_analytics.spec.js index 981b10b53..278548418 100644 --- a/dashboards-observability/.cypress/integration/event_analytics.spec.js +++ b/dashboards-observability/.cypress/integration/event_analytics.spec.js @@ -35,13 +35,19 @@ describe('Has working breadcrumbs', () => { it('Redirect to correct page on breadcrumb click', () => { landOnEventExplorer(); cy.wait(delay * 3); - cy.get('.euiBreadcrumb').contains('Explorer').click(); + cy.get('[data-test-subj="breadcrumbs"]') + .contains('Explorer', { timeout: 10000 }) + .click(); cy.wait(delay); cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('exist'); - cy.get('.euiBreadcrumb').contains('Event analytics').click(); + cy.get('[data-test-subj="breadcrumbs"]') + .contains('Event analytics', { timeout: 10000 }) + .click(); cy.wait(delay); cy.get('.euiTitle').contains('Event analytics').should('exist'); - cy.get('.euiBreadcrumb').contains('Observability').click(); + cy.get('[data-test-subj="breadcrumbs"]') + .contains('Observability', { timeout: 10000 }) + .click(); cy.wait(delay); cy.get('.euiTitle').contains('Event analytics').should('exist'); }); @@ -210,7 +216,7 @@ describe('Click actions', () => { cy.get('[data-test-subj="eventHomeAction__addSamples"]').click(); cy.get('[data-test-subj="confirmModalConfirmButton"]').click(); cy.wait(delay * 4); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + cy.contains('Sample events added successfully.', { timeout: 10000 }); }); it('Actions - delete saved queries', () => { @@ -219,8 +225,7 @@ describe('Click actions', () => { cy.get('[data-test-subj="eventHomeAction__delete"]').click(); cy.get('[data-test-subj="popoverModal__deleteTextInput"]').type('delete'); cy.get('[data-test-subj="popoverModal__deleteButton"').click(); - cy.wait(delay); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + cy.contains('Histories has been successfully deleted.', { timeout: 10000 }); }); }); diff --git a/dashboards-observability/.cypress/integration/notebooks.spec.js b/dashboards-observability/.cypress/integration/notebooks.spec.js index ca0083249..51af972ae 100644 --- a/dashboards-observability/.cypress/integration/notebooks.spec.js +++ b/dashboards-observability/.cypress/integration/notebooks.spec.js @@ -51,10 +51,7 @@ describe('Adding sample data and visualization', () => { 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); + cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); }); }); @@ -480,43 +477,3 @@ 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'); - }); -}); diff --git a/dashboards-observability/.cypress/utils/app_constants.js b/dashboards-observability/.cypress/utils/app_constants.js index 86e713879..796d9d49f 100644 --- a/dashboards-observability/.cypress/utils/app_constants.js +++ b/dashboards-observability/.cypress/utils/app_constants.js @@ -17,17 +17,17 @@ export const moveToHomePage = () => { export const moveToCreatePage = () => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/application_analytics/`); - cy.wait(delay * 2); - cy.get('.euiButton__text').contains('Create application').click(); supressResizeObserverIssue(); - cy.wait(delay); + cy.wait(delay * 7); + cy.get('.euiButton__text').contains('Create application').click(); + cy.wait(delay * 2); cy.get('.euiTitle').contains('Create application').should('exist'); }; export const moveToApplication = (name) => { cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/application_analytics/`); supressResizeObserverIssue(); - cy.wait(delay * 6); + cy.wait(delay * 7); cy.get('.euiLink').contains(name).click(); cy.wait(delay); cy.get('.euiTitle').contains(name).should('exist'); @@ -85,5 +85,5 @@ export const query_one = 'where DestCityName = "Venice" | stats count() by span( export const query_two = 'where OriginCityName = "Seoul" | stats count() by span( timestamp , 6h )'; export const visOneName = 'Flights to Venice'; export const visTwoName = 'Flights from Seoul'; -export const composition = 'order, payment, HTTP POST, HTTP GET, client_pay_order' +export const composition = 'order, payment, HTTP POST, HTTP GET'; export const newName = 'Monterey Cypress'; \ No newline at end of file diff --git a/dashboards-observability/.cypress/utils/event_constants.js b/dashboards-observability/.cypress/utils/event_constants.js index 130d32590..1fb868e1a 100644 --- a/dashboards-observability/.cypress/utils/event_constants.js +++ b/dashboards-observability/.cypress/utils/event_constants.js @@ -28,6 +28,10 @@ export const TEST_QUERIES = [ query: 'source = opensearch_dashboards_sample_data_logs | stats count(), avg(bytes) by host, tags', dateRangeDOM: YEAR_TO_DATE_DOM_ID }, + { + query:"source = opensearch_dashboards_sample_data_logs | where response='503' or response='404' | stats count() by span(timestamp,1d)", + dateRangeDOM: YEAR_TO_DATE_DOM_ID + }, ]; export const TESTING_PANEL = 'Mock Testing Panels'; From 42f712f8f2e64a6308bab4f26ed997e920d8db01 Mon Sep 17 00:00:00 2001 From: Pratibha Pandey Date: Thu, 12 May 2022 06:07:47 -0700 Subject: [PATCH 2/2] Rebasing with main Signed-off-by: Pratibha Pandey --- .../integration/1_event_analytics.spec.js | 17 ++++--- .../.cypress/integration/2_notebooks.spec.js | 45 +------------------ .../.cypress/utils/event_constants.js | 4 ++ 3 files changed, 16 insertions(+), 50 deletions(-) diff --git a/dashboards-observability/.cypress/integration/1_event_analytics.spec.js b/dashboards-observability/.cypress/integration/1_event_analytics.spec.js index 981b10b53..278548418 100644 --- a/dashboards-observability/.cypress/integration/1_event_analytics.spec.js +++ b/dashboards-observability/.cypress/integration/1_event_analytics.spec.js @@ -35,13 +35,19 @@ describe('Has working breadcrumbs', () => { it('Redirect to correct page on breadcrumb click', () => { landOnEventExplorer(); cy.wait(delay * 3); - cy.get('.euiBreadcrumb').contains('Explorer').click(); + cy.get('[data-test-subj="breadcrumbs"]') + .contains('Explorer', { timeout: 10000 }) + .click(); cy.wait(delay); cy.get('[data-test-subj="searchAutocompleteTextArea"]').should('exist'); - cy.get('.euiBreadcrumb').contains('Event analytics').click(); + cy.get('[data-test-subj="breadcrumbs"]') + .contains('Event analytics', { timeout: 10000 }) + .click(); cy.wait(delay); cy.get('.euiTitle').contains('Event analytics').should('exist'); - cy.get('.euiBreadcrumb').contains('Observability').click(); + cy.get('[data-test-subj="breadcrumbs"]') + .contains('Observability', { timeout: 10000 }) + .click(); cy.wait(delay); cy.get('.euiTitle').contains('Event analytics').should('exist'); }); @@ -210,7 +216,7 @@ describe('Click actions', () => { cy.get('[data-test-subj="eventHomeAction__addSamples"]').click(); cy.get('[data-test-subj="confirmModalConfirmButton"]').click(); cy.wait(delay * 4); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + cy.contains('Sample events added successfully.', { timeout: 10000 }); }); it('Actions - delete saved queries', () => { @@ -219,8 +225,7 @@ describe('Click actions', () => { cy.get('[data-test-subj="eventHomeAction__delete"]').click(); cy.get('[data-test-subj="popoverModal__deleteTextInput"]').type('delete'); cy.get('[data-test-subj="popoverModal__deleteButton"').click(); - cy.wait(delay); - cy.get('.euiToastHeader__title').contains('successfully').should('exist'); + cy.contains('Histories has been successfully deleted.', { timeout: 10000 }); }); }); diff --git a/dashboards-observability/.cypress/integration/2_notebooks.spec.js b/dashboards-observability/.cypress/integration/2_notebooks.spec.js index ca0083249..51af972ae 100644 --- a/dashboards-observability/.cypress/integration/2_notebooks.spec.js +++ b/dashboards-observability/.cypress/integration/2_notebooks.spec.js @@ -51,10 +51,7 @@ describe('Adding sample data and visualization', () => { 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); + cy.get('.euiTableCellContent').contains(SAMPLE_PANEL).should('exist'); }); }); @@ -480,43 +477,3 @@ 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'); - }); -}); diff --git a/dashboards-observability/.cypress/utils/event_constants.js b/dashboards-observability/.cypress/utils/event_constants.js index 130d32590..1fb868e1a 100644 --- a/dashboards-observability/.cypress/utils/event_constants.js +++ b/dashboards-observability/.cypress/utils/event_constants.js @@ -28,6 +28,10 @@ export const TEST_QUERIES = [ query: 'source = opensearch_dashboards_sample_data_logs | stats count(), avg(bytes) by host, tags', dateRangeDOM: YEAR_TO_DATE_DOM_ID }, + { + query:"source = opensearch_dashboards_sample_data_logs | where response='503' or response='404' | stats count() by span(timestamp,1d)", + dateRangeDOM: YEAR_TO_DATE_DOM_ID + }, ]; export const TESTING_PANEL = 'Mock Testing Panels';