From 4e9b4c39bf2f9251cd1e6c656afb7d3fc13177ea Mon Sep 17 00:00:00 2001 From: Ritvi Bhatt Date: Fri, 8 Nov 2024 10:49:47 -0800 Subject: [PATCH 1/5] updated cypress testing for traces Signed-off-by: Ritvi Bhatt --- .../trace_analytics_dashboard.spec.js | 37 +++++----- .../trace_analytics_services.spec.js | 73 ++++++++++++++----- .../trace_analytics_traces.spec.js | 22 +++--- .cypress/utils/constants.js | 9 +-- .../common/filters/filter_edit_popover.tsx | 2 + .../common/filters/filter_helpers.tsx | 8 ++ .../components/common/filters/filters.tsx | 1 + 7 files changed, 98 insertions(+), 54 deletions(-) diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_dashboard.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_dashboard.spec.js index 5edf0d33a2..579162d799 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_dashboard.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_dashboard.spec.js @@ -5,7 +5,7 @@ /// -import { testDataSet, delay, setTimeFilter, jaegerTestDataSet } from '../../utils/constants'; +import { testDataSet, setTimeFilter, jaegerTestDataSet } from '../../utils/constants'; import { suppressResizeObserverIssue } from '../../utils/constants'; suppressResizeObserverIssue();//needs to be in file once @@ -102,15 +102,15 @@ describe('Testing dashboard table', () => { }); it('Adds the percentile filters', () => { - cy.contains(' >= 95 percentile').click({ force: true }); - cy.contains(' >= 95 percentile').click({ force: true }); + + cy.get('[data-test-subj="dashboardTable"]').should('be.visible'); + cy.get('[data-test-subj="dashboard-table-percentile-button-2"]').click(); cy.contains('Latency percentile within trace group: >= 95th').should('exist'); cy.contains(' (7)').should('exist'); cy.contains('318.69').should('exist'); - cy.contains(' < 95 percentile').click({ force: true }); - cy.contains(' < 95 percentile').click({ force: true }); + cy.get('[data-test-subj="dashboard-table-percentile-button-1"]').click(); cy.contains('Latency percentile within trace group: < 95th').should('exist'); cy.contains(' (8)').should('exist'); @@ -148,6 +148,7 @@ describe('Testing plots', () => { it('Renders service map', () => { // plotly scale texts are in attribute "data-unformatted" + cy.get('.euiSideNavItemButton__label').contains('Services').click(); cy.get('text.ytitle[data-unformatted="Average duration (ms)"]').should('exist'); cy.get('text[data-unformatted="200"]').should('exist'); cy.get('.vis-network').should('exist'); @@ -218,7 +219,6 @@ describe('Latency by trace group table', () =>{ it('Verify Search engine on Trace dashboard', () => { cy.get('.euiFieldSearch.euiFieldSearch--fullWidth').click().type('client_pay_order'); cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); - cy.wait(delay);//Fails without cy.get('.euiTableCellContent.euiTableCellContent--alignRight.euiTableCellContent--overflowingContent').contains('211.04').should('exist'); cy.get('button[data-test-subj="dashboard-table-trace-group-name-button"]').eq(0).click(); cy.get('.euiBadge.euiBadge--hollow.euiBadge--iconRight.globalFilterItem').click(); @@ -250,25 +250,22 @@ describe('Testing filters on trace analytics page', { scrollBehavior: false }, ( }); it('Verify Change all filters', () =>{ - cy.wait(delay);//Needed after removing waits from setTimeFilter() cy.get('[data-test-subj="global-filter-button"]').click(); cy.get('.euiContextMenuPanelTitle').contains('Change all filters').should('exist'); - cy.get('.euiContextMenuItem__text').eq(0).contains('Enable all'); - cy.get('.euiContextMenuItem__text').eq(1).contains('Disable all'); - cy.get('.euiContextMenuItem__text').eq(2).contains('Invert inclusion'); - cy.get('.euiContextMenuItem__text').eq(3).contains('Invert enabled/disabled'); - cy.get('.euiContextMenuItem__text').eq(4).contains('Remove all'); + cy.get('.euiContextMenuItem__text').eq(1).contains('Enable all'); + cy.get('.euiContextMenuItem__text').eq(2).contains('Disable all'); + cy.get('.euiContextMenuItem__text').eq(3).contains('Invert inclusion'); + cy.get('.euiContextMenuItem__text').eq(4).contains('Invert enabled/disabled'); + cy.get('.euiContextMenuItem__text').eq(5).contains('Remove all'); }) it('Verify Add filter section', () => { - cy.wait(delay);//Needed after removing waits from setTimeFilter() - cy.get('[data-test-subj="addfilter"]').contains('+ Add filter').click(); - cy.get('.euiPopoverTitle').contains('Add filter').should('exist'); - cy.wait(delay);//drop down won't open without - cy.get('.euiComboBox__inputWrap.euiComboBox__inputWrap--noWrap').eq(0).trigger('mouseover').click(); - cy.get('.euiComboBoxOption__content').eq(1).click(); - cy.get('.euiComboBox__inputWrap.euiComboBox__inputWrap--noWrap').eq(1).trigger('mouseover').click(); - cy.get('.euiComboBoxOption__content').eq(2).click(); + cy.get('[data-test-subj="global-filter-button"]').click(); + cy.get('.euiContextMenuItem__text').contains('Add filter').click(); + cy.get('[data-test-subj="field-selector-filter-panel"]').click(); + cy.get('[data-test-subj="field-selector-filter-panel"]').type('traceId{enter}'); + cy.get('[data-test-subj="operator-selector-filter-panel"]').click(); + cy.get('[data-test-subj="operator-selector-filter-panel"]').type('exists{enter}'); cy.get('.euiButton.euiButton--primary.euiButton--fill').contains('Save').click(); cy.get('.euiBadge__content').should('exist').click(); cy.get('.euiIcon.euiIcon--medium.euiContextMenu__arrow').click(); diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js index 1f278c2b34..592b8832a8 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js @@ -32,6 +32,8 @@ describe('Testing services table', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); }); @@ -44,13 +46,13 @@ describe('Testing services table', () => { it('Searches correctly', () => { cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}{enter}`); - cy.get('.euiButton__text').contains('Refresh').click(); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); cy.contains(' (1)').should('exist'); cy.contains('3.57%').should('exist'); }); it('Verify columns in Services table', () => { - cy.get('.euiFlexItem.euiFlexItem--flexGrow10 .panel-title').contains('Services').should('exist'); + cy.get('.euiFlexItem.euiFlexItem--flexGrowZero .panel-title').contains('Services').should('exist'); cy.get('.euiTableCellContent__text[title="Name"]').should('exist'); cy.get('.euiTableCellContent__text[title="Average duration (ms)"]').should('exist'); cy.get('.euiTableCellContent__text[title="Error rate"]').should('exist'); @@ -95,15 +97,19 @@ describe('Testing service view', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}`); cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait - cy.get('[data-test-subj="service-link"]').eq(0).click(); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); }); it('Renders service view', () => { - cy.get('h2.euiTitle').contains(SERVICE_NAME).should('exist'); + cy.get('h1.overview-content').contains(SERVICE_NAME).should('exist'); cy.contains('178.6').should('exist'); cy.contains('3.57%').should('exist'); cy.get('div.vis-network').should('exist'); @@ -111,7 +117,7 @@ describe('Testing service view', () => { it('Has working breadcrumbs', () => { cy.get('.euiBreadcrumb').contains(SERVICE_NAME).click(); - cy.get('h2.euiTitle').contains(SERVICE_NAME).should('exist'); + cy.get('h1.overview-content').contains(SERVICE_NAME).should('exist'); cy.get('.euiBreadcrumb').contains('Services').click(); cy.get('.euiBreadcrumb').contains('Trace analytics').click(); cy.get('.euiBreadcrumb').contains('Observability').click(); @@ -119,7 +125,8 @@ describe('Testing service view', () => { }); it('Renders spans data grid, flyout, filters', () => { - cy.get("[data-test-subj='spanId-link']").contains(SERVICE_SPAN_ID).trigger('mouseover', { force: true }); + // cy.get("[data-test-subj='spanId-link']").contains(SERVICE_SPAN_ID).trigger('mouseover', { force: true }); + cy.get("[data-test-subj='spanId-link']").contains("e275ac9d21929e9b").trigger('mouseover', { force: true }); cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); cy.contains('Span detail').should('exist'); cy.contains('Span attributes').should('exist'); @@ -138,6 +145,8 @@ describe('Testing Service map', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); }); @@ -149,7 +158,7 @@ describe('Testing Service map', () => { cy.contains('60%'); cy.get('[data-text = "Duration"]').click(); cy.contains('100'); - cy.get('.euiText.euiText--medium').contains('Focus on').should('exist'); + cy.get('.euiFormLabel.euiFormControlLayout__prepend').contains('Focus on').should('exist'); cy.get('[placeholder="Service name"]').focus().type('database{enter}'); }) }); @@ -161,28 +170,40 @@ describe('Testing traces Spans table verify table headers functionality', () => win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); }); it('Renders the spans table and verify columns headers', () => { cy.contains(' (8)').should('exist'); cy.contains('analytics-service, frontend-client, recommendation').should('exist'); - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); cy.get('.panel-title').contains('Spans').should('exist'); cy.get('.panel-title-count').contains('8').should('exist'); verify_traces_spans_data_grid_cols_exists(); }); it('Toggle columns and verify the columns hidden text verify rows', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); - cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); + cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click({ force: true }); + cy.get('.panel-title-count').contains('8').should('exist'); cy.get('.euiSwitch.euiSwitch--compressed.euiSwitch--mini .euiSwitch__button').eq(3).click(); cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click().should('have.text', '2 columns hidden'); count_table_row(8); }); it('Show all button Spans table', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click(); cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(0).should('have.text', 'Show all').click(); cy.get('.euiDataGrid__focusWrap').click().should('exist'); @@ -190,7 +211,10 @@ describe('Testing traces Spans table verify table headers functionality', () => }); it('Hide all button Spans table', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); cy.get('.euiTableRow').should('have.length.lessThan', 2);//Replace wait cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click(); cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(1).should('have.text', 'Hide all').click(); @@ -199,7 +223,10 @@ describe('Testing traces Spans table verify table headers functionality', () => }); it('Render Spans table and change data table Density', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + // cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); verify_traces_spans_data_grid_cols_exists(); cy.get('.euiButtonEmpty__text').contains('Density').click(); cy.get('.euiButtonContent__icon').eq(5).click(); @@ -208,7 +235,10 @@ describe('Testing traces Spans table verify table headers functionality', () => }); it('Render Spans table and and click on sort', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); verify_traces_spans_data_grid_cols_exists(); cy.get('[data-test-subj="dataGridColumnSortingButton"]').contains('Sort fields').should('exist').click(); cy.get('[data-test-subj="dataGridColumnSortingPopoverColumnSelection"]').click(); @@ -233,14 +263,20 @@ describe('Testing traces Spans table and verify columns functionality', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); }); it('Renders the spans table and click on first span to verify details', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + // cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); verify_traces_spans_data_grid_cols_exists(); cy.contains(AUTH_SERVICE_SPAN_ID).click(); - cy.get('[data-test-subj="spanDetailFlyout"] .euiTitle.euiTitle--medium').contains('Span detail').should('exist'); + cy.get('[data-test-subj="spanDetailFlyout"]').contains('Span detail').should('exist'); cy.get('.euiFlyoutBody .panel-title').contains('Overview').should('exist'); cy.get('.euiTextColor.euiTextColor--subdued').contains('Span ID').should('exist'); cy.get('[data-test-subj="parentSpanId"]').contains('d03fecfa0f55b77c').should('exist'); @@ -255,7 +291,10 @@ describe('Testing traces Spans table and verify columns functionality', () => { }); it('Render Spans table and verify Column functionality', () => { - cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); verify_traces_spans_data_grid_cols_exists(); cy.get('.euiDataGridHeaderCell__content').contains('Span ID').click(); cy.get('.euiListGroupItem__label').contains('Hide column').click(); diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js index 843e6640ad..b447dd0ef6 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js @@ -35,7 +35,7 @@ describe('Testing traces table', () => { it('Renders the traces table', () => { cy.contains(' (108)').should('exist'); cy.contains('03/25/2021 10:23:45').should('exist'); - cy.contains('03f9c770db5ee2f1caac0...').should('exist'); + cy.contains('03f9c770db5ee2f1caac0afc36db49ba').should('exist'); cy.contains('224.99').should('exist'); // test data contains output from data-prepper 0.8, which doesn't have fields denormalized @@ -52,12 +52,13 @@ describe('Testing traces table', () => { it('Searches correctly', () => { cy.get('input[type="search"]').focus().type(`${TRACE_ID}{enter}`); - cy.get('.euiButton__text').contains('Refresh').click(); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); cy.contains(' (1)').should('exist'); cy.contains('03/25/2021 10:21:22').should('exist'); }); }); +//here describe('Testing trace view', () => { beforeEach(() => { cy.visit(`app/observability-traces#/traces`, { @@ -67,7 +68,7 @@ describe('Testing trace view', () => { }); setTimeFilter(); cy.get('input[type="search"]').focus().type(`${TRACE_ID}`); - cy.get('.euiButton__text').contains('Refresh').click(); + cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait cy.get('[data-test-subj="trace-link"]').eq(0).click(); }); @@ -84,11 +85,11 @@ describe('Testing trace view', () => { }); it('Has working breadcrumbs', () => { - cy.get(`.euiBreadcrumb[href="#/traces/${TRACE_ID}"]`).click(); - cy.get('h2.euiTitle').contains(TRACE_ID).should('exist'); - cy.get('.euiBreadcrumb[href="#/traces"]').click(); - cy.get('.euiBreadcrumb[href="#/"]').click(); - cy.get('.euiBreadcrumb[href="observability-logs#/"]').click(); + cy.get('.euiBreadcrumb').contains(TRACE_ID).click(); + // cy.get('h1.overview-content').contains(TRACE_ID).should('exist'); + cy.get('.euiBreadcrumb').contains('Traces').click(); + cy.get('.euiBreadcrumb').contains('Trace analytics').click(); + cy.get('.euiBreadcrumb').contains('Observability').click(); cy.get('.euiTitle').contains('Logs').should('exist'); }); @@ -121,6 +122,7 @@ describe('Testing traces table', () => { }); it('Renders the traces table and verify Table Column, Pagination and Rows Data ', () => { + cy.contains(' (108)').should('exist'); cy.get('.euiTableCellContent__text').contains('Trace ID').should('exist'); cy.get('.euiTableCellContent__text').contains('Trace group').should('exist'); cy.get('.euiTableCellContent__text').contains('Duration (ms)').should('exist'); @@ -132,8 +134,8 @@ describe('Testing traces table', () => { cy.get('[data-test-subj="pagination-button-previous"]').click(); cy.contains('224.99').should('exist'); cy.get('.euiButtonEmpty').contains('5').click(); - cy.contains('690d3c7af1a78cf89c43e...').should('exist'); - cy.contains('5be8370207cbb002a165d...').click(); + cy.contains('690d3c7af1a78cf89c43e').should('exist'); + cy.contains('5be8370207cbb002a165d').click(); cy.contains('client_create_order').should('exist'); cy.get('path[style*="rgb(116, 146, 231)"]').should('exist'); cy.go('back'); diff --git a/.cypress/utils/constants.js b/.cypress/utils/constants.js index 2f6150d308..d36e8b68db 100644 --- a/.cypress/utils/constants.js +++ b/.cypress/utils/constants.js @@ -68,23 +68,18 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => { cy.get('button.euiButtonEmpty[aria-label="Date quick select"]').click(); cy.get('.euiQuickSelect__applyButton').click(); cy.get('.euiSuperDatePicker__prettyFormatLink').click(); - cy.get( - 'button.euiDatePopoverButton--start[data-test-subj="superDatePickerstartDatePopoverButton"]' - ).click(); cy.get('.euiTab__content').contains('Absolute').click(); cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]') .focus() .type('{selectall}' + startTime, { force: true }); if (setEndTime) { - cy.get( - 'button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]' - ).click(); + cy.get('button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]').click(); cy.get('.euiTab__content').contains('Absolute').click(); cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]') .focus() .type('{selectall}' + endTime, { force: true }); } - if (refresh) cy.get('.euiButton__text').contains('Refresh').click(); + if (refresh) cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); cy.get('.euiTableRow').should('have.length.greaterThan', 3); //Replaces Wait }; diff --git a/public/components/trace_analytics/components/common/filters/filter_edit_popover.tsx b/public/components/trace_analytics/components/common/filters/filter_edit_popover.tsx index dc4d4b6d83..22b97b68a6 100644 --- a/public/components/trace_analytics/components/common/filters/filter_edit_popover.tsx +++ b/public/components/trace_analytics/components/common/filters/filter_edit_popover.tsx @@ -45,6 +45,7 @@ export function FilterEditPopover(props: { { long: [ { label: 'is between', + 'data-test-subj': 'is-between-operator', }, { label: 'is not between', + 'data-test-subj': 'is-not-between-operator', }, ], date_nanos: [ { label: 'is between', + 'data-test-subj': 'is-between-operator', }, { label: 'is not between', + 'data-test-subj': 'is-not-between-operator', }, ], keyword: [], default_first: [ { label: 'is', + 'data-test-subj': 'is-operator', }, { label: 'is not', + 'data-test-subj': 'is-not-operator', }, ], default_last: [ { label: 'exists', + 'data-test-subj': 'exists-operator', }, { label: 'does not exist', + 'data-test-subj': 'does-not-exist-operator', }, ], }; diff --git a/public/components/trace_analytics/components/common/filters/filters.tsx b/public/components/trace_analytics/components/common/filters/filters.tsx index 3acf5870b1..23e3606dcc 100644 --- a/public/components/trace_analytics/components/common/filters/filters.tsx +++ b/public/components/trace_analytics/components/common/filters/filters.tsx @@ -257,6 +257,7 @@ export const GlobalFilterButton = ({ () => getFilterFields(mode, page, attributesFilterFields).map((field) => ({ label: field, + 'data-test-subj': `filterFieldOptions-${field}`, })), [mode, page, attributesFilterFields] ); From c65d9e4d9239e65275eb72a90d8c559ac0d9ff80 Mon Sep 17 00:00:00 2001 From: Ritvi Bhatt Date: Fri, 8 Nov 2024 13:58:22 -0800 Subject: [PATCH 2/5] update snapshots Signed-off-by: Ritvi Bhatt --- .../trace_analytics_test/trace_analytics_services.spec.js | 6 ++---- .cypress/utils/constants.js | 2 +- .../__snapshots__/filter_edit_popover.test.tsx.snap | 4 ++++ .../components/common/filters/filter_helpers.tsx | 8 -------- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js index 592b8832a8..7051c94f7c 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js @@ -125,8 +125,7 @@ describe('Testing service view', () => { }); it('Renders spans data grid, flyout, filters', () => { - // cy.get("[data-test-subj='spanId-link']").contains(SERVICE_SPAN_ID).trigger('mouseover', { force: true }); - cy.get("[data-test-subj='spanId-link']").contains("e275ac9d21929e9b").trigger('mouseover', { force: true }); + cy.get("[data-test-subj='spanId-link']").contains(SERVICE_SPAN_ID).trigger('mouseover', { force: true }); cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); cy.contains('Span detail').should('exist'); cy.contains('Span attributes').should('exist'); @@ -223,7 +222,6 @@ describe('Testing traces Spans table verify table headers functionality', () => }); it('Render Spans table and change data table Density', () => { - // cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); cy.get('[data-test-subj="ActionContextMenu"]').click(); cy.get('[data-test-subj="viewServiceButton"]').click(); @@ -269,7 +267,6 @@ describe('Testing traces Spans table and verify columns functionality', () => { }); it('Renders the spans table and click on first span to verify details', () => { - // cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click(); cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); cy.get('[data-test-subj="ActionContextMenu"]').click(); @@ -287,6 +284,7 @@ describe('Testing traces Spans table and verify columns functionality', () => { cy.get('.euiBadge__content .euiBadge__text').contains('spanId: 277a5934acf55dcf').should('exist'); count_table_row(1); cy.get('[aria-label="remove current filter"]').click(); + cy.get('[aria-label="remove current filter"]').should('not.exist'); count_table_row(8); }); diff --git a/.cypress/utils/constants.js b/.cypress/utils/constants.js index d36e8b68db..177f675070 100644 --- a/.cypress/utils/constants.js +++ b/.cypress/utils/constants.js @@ -18,7 +18,7 @@ export const DATASOURCES_PATH = { export const TRACE_ID = '8832ed6abbb2a83516461960c89af49d'; export const SPAN_ID = 'a673bc074b438374'; export const SERVICE_NAME = 'frontend-client'; -export const SERVICE_SPAN_ID = '7df5609a6d104736'; +export const SERVICE_SPAN_ID = 'e275ac9d21929e9b'; export const AUTH_SERVICE_SPAN_ID = '277a5934acf55dcf'; export const testDataSet = [ diff --git a/public/components/trace_analytics/components/common/filters/__tests__/__snapshots__/filter_edit_popover.test.tsx.snap b/public/components/trace_analytics/components/common/filters/__tests__/__snapshots__/filter_edit_popover.test.tsx.snap index 76e2ee091e..ed16c4579b 100644 --- a/public/components/trace_analytics/components/common/filters/__tests__/__snapshots__/filter_edit_popover.test.tsx.snap +++ b/public/components/trace_analytics/components/common/filters/__tests__/__snapshots__/filter_edit_popover.test.tsx.snap @@ -91,6 +91,7 @@ exports[`Filter popover component renders filter popover 1`] = ` @@ -371,6 +373,7 @@ exports[`Filter popover component renders filter popover 1`] = ` diff --git a/public/components/trace_analytics/components/common/filters/filter_helpers.tsx b/public/components/trace_analytics/components/common/filters/filter_helpers.tsx index 66fc43655c..6634003025 100644 --- a/public/components/trace_analytics/components/common/filters/filter_helpers.tsx +++ b/public/components/trace_analytics/components/common/filters/filter_helpers.tsx @@ -109,42 +109,34 @@ export const getOperatorOptions = (field: string) => { long: [ { label: 'is between', - 'data-test-subj': 'is-between-operator', }, { label: 'is not between', - 'data-test-subj': 'is-not-between-operator', }, ], date_nanos: [ { label: 'is between', - 'data-test-subj': 'is-between-operator', }, { label: 'is not between', - 'data-test-subj': 'is-not-between-operator', }, ], keyword: [], default_first: [ { label: 'is', - 'data-test-subj': 'is-operator', }, { label: 'is not', - 'data-test-subj': 'is-not-operator', }, ], default_last: [ { label: 'exists', - 'data-test-subj': 'exists-operator', }, { label: 'does not exist', - 'data-test-subj': 'does-not-exist-operator', }, ], }; From e6d4a947086e51a8daec717202064b772d9768cb Mon Sep 17 00:00:00 2001 From: Ritvi Bhatt Date: Fri, 8 Nov 2024 15:36:49 -0800 Subject: [PATCH 3/5] wait for page to load before checking rows Signed-off-by: Ritvi Bhatt --- .../trace_analytics_test/trace_analytics_services.spec.js | 3 ++- .../trace_analytics_test/trace_analytics_traces.spec.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js index 7051c94f7c..3e60541b11 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js @@ -222,6 +222,7 @@ describe('Testing traces Spans table verify table headers functionality', () => }); it('Render Spans table and change data table Density', () => { + cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); cy.get('[data-test-subj="ActionContextMenu"]').click(); cy.get('[data-test-subj="viewServiceButton"]').click(); @@ -284,7 +285,7 @@ describe('Testing traces Spans table and verify columns functionality', () => { cy.get('.euiBadge__content .euiBadge__text').contains('spanId: 277a5934acf55dcf').should('exist'); count_table_row(1); cy.get('[aria-label="remove current filter"]').click(); - cy.get('[aria-label="remove current filter"]').should('not.exist'); + cy.get('.panel-title-count').contains('8').should('exist'); count_table_row(8); }); diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js index b447dd0ef6..91f91ecdcd 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js @@ -29,6 +29,8 @@ describe('Testing traces table', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); }); @@ -66,6 +68,8 @@ describe('Testing trace view', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); cy.get('input[type="search"]').focus().type(`${TRACE_ID}`); cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); @@ -86,7 +90,6 @@ describe('Testing trace view', () => { it('Has working breadcrumbs', () => { cy.get('.euiBreadcrumb').contains(TRACE_ID).click(); - // cy.get('h1.overview-content').contains(TRACE_ID).should('exist'); cy.get('.euiBreadcrumb').contains('Traces').click(); cy.get('.euiBreadcrumb').contains('Trace analytics').click(); cy.get('.euiBreadcrumb').contains('Observability').click(); @@ -118,11 +121,12 @@ describe('Testing traces table', () => { win.sessionStorage.clear(); }, }); + cy.get("[data-test-subj='indexPattern-switch-link']").click(); + cy.get("[data-test-subj='data_prepper-mode']").click(); setTimeFilter(); }); it('Renders the traces table and verify Table Column, Pagination and Rows Data ', () => { - cy.contains(' (108)').should('exist'); cy.get('.euiTableCellContent__text').contains('Trace ID').should('exist'); cy.get('.euiTableCellContent__text').contains('Trace group').should('exist'); cy.get('.euiTableCellContent__text').contains('Duration (ms)').should('exist'); From 7bdf434d49ad38eaf34b0a93b6333713fe0f7f94 Mon Sep 17 00:00:00 2001 From: Ritvi Bhatt Date: Mon, 11 Nov 2024 09:22:14 -0800 Subject: [PATCH 4/5] remove forgetten comment Signed-off-by: Ritvi Bhatt --- .../trace_analytics_test/trace_analytics_traces.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js index 91f91ecdcd..acfff9d339 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_traces.spec.js @@ -60,7 +60,6 @@ describe('Testing traces table', () => { }); }); -//here describe('Testing trace view', () => { beforeEach(() => { cy.visit(`app/observability-traces#/traces`, { From f1486075353c3279b7606714ec532fcd5b0cf5e2 Mon Sep 17 00:00:00 2001 From: Ritvi Bhatt Date: Mon, 11 Nov 2024 11:52:06 -0800 Subject: [PATCH 5/5] centralize exapnding service view Signed-off-by: Ritvi Bhatt --- .../trace_analytics_services.spec.js | 38 +++++-------------- .cypress/utils/constants.js | 7 ++++ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js index 3e60541b11..024e3f9843 100644 --- a/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js +++ b/.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js @@ -5,7 +5,7 @@ /// -import { delay, SERVICE_NAME, SERVICE_SPAN_ID, setTimeFilter, verify_traces_spans_data_grid_cols_exists, count_table_row, AUTH_SERVICE_SPAN_ID } from '../../utils/constants'; +import { expandServiceView, SERVICE_NAME, SERVICE_SPAN_ID, setTimeFilter, verify_traces_spans_data_grid_cols_exists, count_table_row, AUTH_SERVICE_SPAN_ID } from '../../utils/constants'; import { suppressResizeObserverIssue } from '../../utils/constants'; suppressResizeObserverIssue();//needs to be in file once @@ -103,9 +103,7 @@ describe('Testing service view', () => { cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}`); cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click(); cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(0); }); it('Renders service view', () => { @@ -178,9 +176,7 @@ describe('Testing traces Spans table verify table headers functionality', () => cy.contains(' (8)').should('exist'); cy.contains('analytics-service, frontend-client, recommendation').should('exist'); cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); cy.get('.panel-title').contains('Spans').should('exist'); cy.get('.panel-title-count').contains('8').should('exist'); verify_traces_spans_data_grid_cols_exists(); @@ -188,9 +184,7 @@ describe('Testing traces Spans table verify table headers functionality', () => it('Toggle columns and verify the columns hidden text verify rows', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click({ force: true }); cy.get('.panel-title-count').contains('8').should('exist'); cy.get('.euiSwitch.euiSwitch--compressed.euiSwitch--mini .euiSwitch__button').eq(3).click(); @@ -200,9 +194,7 @@ describe('Testing traces Spans table verify table headers functionality', () => it('Show all button Spans table', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click(); cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(0).should('have.text', 'Show all').click(); cy.get('.euiDataGrid__focusWrap').click().should('exist'); @@ -211,9 +203,7 @@ describe('Testing traces Spans table verify table headers functionality', () => it('Hide all button Spans table', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); cy.get('.euiTableRow').should('have.length.lessThan', 2);//Replace wait cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click(); cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(1).should('have.text', 'Hide all').click(); @@ -223,9 +213,7 @@ describe('Testing traces Spans table verify table headers functionality', () => it('Render Spans table and change data table Density', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); verify_traces_spans_data_grid_cols_exists(); cy.get('.euiButtonEmpty__text').contains('Density').click(); cy.get('.euiButtonContent__icon').eq(5).click(); @@ -235,9 +223,7 @@ describe('Testing traces Spans table verify table headers functionality', () => it('Render Spans table and and click on sort', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); verify_traces_spans_data_grid_cols_exists(); cy.get('[data-test-subj="dataGridColumnSortingButton"]').contains('Sort fields').should('exist').click(); cy.get('[data-test-subj="dataGridColumnSortingPopoverColumnSelection"]').click(); @@ -269,9 +255,7 @@ describe('Testing traces Spans table and verify columns functionality', () => { it('Renders the spans table and click on first span to verify details', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); verify_traces_spans_data_grid_cols_exists(); cy.contains(AUTH_SERVICE_SPAN_ID).click(); cy.get('[data-test-subj="spanDetailFlyout"]').contains('Span detail').should('exist'); @@ -291,9 +275,7 @@ describe('Testing traces Spans table and verify columns functionality', () => { it('Render Spans table and verify Column functionality', () => { cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist'); - cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(1).click(); - cy.get('[data-test-subj="ActionContextMenu"]').click(); - cy.get('[data-test-subj="viewServiceButton"]').click(); + expandServiceView(1); verify_traces_spans_data_grid_cols_exists(); cy.get('.euiDataGridHeaderCell__content').contains('Span ID').click(); cy.get('.euiListGroupItem__label').contains('Hide column').click(); diff --git a/.cypress/utils/constants.js b/.cypress/utils/constants.js index 177f675070..6c2e3fa697 100644 --- a/.cypress/utils/constants.js +++ b/.cypress/utils/constants.js @@ -83,6 +83,12 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => { cy.get('.euiTableRow').should('have.length.greaterThan', 3); //Replaces Wait }; +export const expandServiceView = (rowIndex = 0) => { + cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(rowIndex).click(); + cy.get('[data-test-subj="ActionContextMenu"]').click(); + cy.get('[data-test-subj="viewServiceButton"]').click(); +}; + // notebooks export const TEST_NOTEBOOK = 'Test Notebook'; export const TEST_INTEGRATION_INSTANCE = 'nginx-test'; @@ -125,6 +131,7 @@ export const PPL_QUERY_TEXT = `%ppl source=opensearch_dashboards_sample_data_flights {enter} `; + export const suppressResizeObserverIssue = () => { // exception is thrown on loading EuiDataGrid in cypress only, ignore for now cy.on('uncaught:exception', (err, runnable) => {