Skip to content

Commit

Permalink
update metrics cypress tests (#2269) (#2272)
Browse files Browse the repository at this point in the history
(cherry picked from commit da1f730)

Signed-off-by: Ritvi Bhatt <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ritvi Bhatt <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2024
1 parent 2830275 commit 1c43c19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Metrics Analytics', () => {
moveToEventsHome();
cy.get('[data-test-subj="eventHome__savedQueryTableName"]')
.first()
.contains(PPL_METRICS_NAMES[metricIndex]);
.contains(PPL_METRICS_NAMES[0]);
});
});

Expand All @@ -41,6 +41,8 @@ describe('Metrics Analytics', () => {
createSavedObjectMetric({ testMetricIndex: 1 });

moveToMetricsHome();
cy.get('[data-test-subj="comboBoxToggleListButton"]').click();
cy.get('[data-test-subj="prometheusOption"]').click();
cy.get('[data-test-subj="metricsListItems_availableMetrics"]')
.contains(PPL_METRICS_NAMES[1])
.should('exist');
Expand All @@ -57,11 +59,11 @@ describe('Metrics Analytics', () => {

describe('Check data source picker', () => {
it('Index picker should be only available under Otel metric datasource', () => {
cy.get('[data-test-subj="metricsDataSourcePicker"]').click();
cy.get('[data-test-subj="comboBoxToggleListButton"]').click();
cy.get('[data-test-subj="prometheusOption"]').click();
cy.get('[data-test-subj="metricsIndexPicker"]').should('not.exist');

cy.get('[data-test-subj="metricsDataSourcePicker"]').click();
cy.get('[data-test-subj="comboBoxToggleListButton"]').click();
cy.get('[data-test-subj="openTelemetryOption"]').click();
cy.get('[data-test-subj="metricsIndexPicker"]').should('exist');
});
Expand Down Expand Up @@ -137,21 +139,18 @@ describe('Metrics Analytics', () => {
.click();
});

it('Drag and drop a Metric visualization in edit mode', () => {
it('Drag and drop a Metric visualization', () => {
cy.get('[data-test-subj="metricsListItems_availableMetrics"]')
.contains(PPL_METRICS_NAMES[1])
.trigger('mouseover')
.click();
cy.get('h5')
.contains(PPL_METRICS_NAMES[0])
.trigger('mousedown', { which: 1, force: true })
.trigger('mousemove', { clientX: 415, clientY: 500 })
.trigger('mouseup', { force: true });
cy.wait(delay * 3);
cy.get('div.react-grid-layout>div')
.eq(1)
.invoke('attr', 'style')
.should('match', new RegExp('(.*)transform: translate((.*)10px)(.*)'));
cy.get('h5').eq(2).contains(PPL_METRICS_NAMES[1]).should('exist');;
cy.get('[data-test-subj="draggable"]').eq(0)
.focus()
.type(' ')
.type('{downarrow}')
.type(' ');
cy.get('h5').eq(2).contains(PPL_METRICS_NAMES[0]).should('exist');
});

it('Change date filter of the Metrics home page', () => {
Expand All @@ -175,7 +174,7 @@ describe('Metrics Analytics', () => {
cy.wait(delay * 3);
moveToMetricsHome();
cy.get('[data-test-subj="metrics__saveManagementPopover"]').trigger('mouseover').click();
cy.get('[data-test-subj="comboBoxSearchInput"]')
cy.get('[data-test-subj="comboBoxSearchInput"]').eq(1)
.focus()
.type(TESTING_PANEL, { force: true });
cy.get('[data-test-subj="metrics__SaveConfirm"]').click({ force: true });
Expand Down Expand Up @@ -211,19 +210,19 @@ const moveToEventsHome = () => {
};

const createCustomMetric = ({ testMetricIndex }) => {
cy.get('[id^=autocomplete-textarea]').focus().type(PPL_METRICS[metricIndex], {
cy.get('[id^=autocomplete-textarea]').focus().type(PPL_METRICS[testMetricIndex], {
delay: 50,
});
cy.get('.euiButton__text').contains('Refresh').trigger('mouseover').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').trigger('mouseover').click();
suppressResizeObserverIssue();
cy.get('button[id="main-content-vis"]').contains('Visualizations').trigger('mouseover').click();
cy.wait(delay * 2);
cy.get('[data-test-subj="comboBoxToggleListButton"]').click();
cy.get('[data-test-subj="comboBoxSearchInput"]').focus().type(VIS_TYPE_LINE, { force: true });
cy.get('[data-test-subj="comboBoxToggleListButton"]').eq(1).click();
cy.get('[data-test-subj="comboBoxSearchInput"]').eq(1).focus().type(VIS_TYPE_LINE, { force: true });
cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').click({ force: true });
cy.get('[data-test-subj="eventExplorer__querySaveName"]')
.focus()
.type(PPL_METRICS_NAMES[metricIndex], { force: true });
.type(PPL_METRICS_NAMES[testMetricIndex], { force: true });
cy.get('[data-test-subj="eventExplorer__metricSaveName"]').click({ force: true });
cy.wait(delay * 10);
cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]', {
Expand Down
6 changes: 2 additions & 4 deletions .cypress/utils/event_analytics/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { COMMAND_TIMEOUT_LONG, suppressResizeObserverIssue, delay } from '../constants';
import { COMMAND_TIMEOUT_LONG, suppressResizeObserverIssue } from '../constants';

export const clearQuerySearchBoxText = (testSubjectName) => {
cy.get(`[data-test-subj="${testSubjectName}"]`, {
Expand All @@ -19,7 +19,7 @@ export const querySearch = (query, rangeSelected) => {
suppressResizeObserverIssue();
cy.get('[data-test-subj="superDatePickerToggleQuickMenuButton"]').click();
cy.get(rangeSelected).click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').contains('Refresh').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
};

export const landOnEventHome = () => {
Expand All @@ -44,7 +44,6 @@ export const landOnPanels = () => {
cy.visit(
`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/`
);
cy.wait(delay);
};

const vis_name_sub_string = Math.floor(Math.random() * 100);
Expand All @@ -58,7 +57,6 @@ export const saveVisualizationAndVerify = () => {
.eq(1)
.type(`Test visualization` + vis_name_sub_string, { force: true });
cy.get('[data-test-subj="eventExplorer__querySaveConfirm"]').click({ force: true });
cy.wait(delay);
cy.get('.euiHeaderBreadcrumbs a').eq(1).click({ force: true });
cy.get('.euiFlexGroup .euiFormControlLayout__childrenWrapper input')
.eq(0)
Expand Down

0 comments on commit 1c43c19

Please sign in to comment.