From a8a3d5fdf738ceab2f44e6aa486002203d31a415 Mon Sep 17 00:00:00 2001 From: Francesco Fagnani Date: Mon, 7 Apr 2025 15:47:53 +0200 Subject: [PATCH] [Synthetics] Fix save lens visualization on monitors overview (#216695) This PR closes #212490 by fixing the save lens visualization. https://github.com/user-attachments/assets/34949692-6b72-41f5-aa61-6c743ea5c5a3 (cherry picked from commit 07994d2706808d7ddf1bf2ca3cdf8a29ac033839) --- .../embeddable/embeddable.tsx | 9 +-- .../e2e/synthetics/journeys/index.ts | 1 + ...verview_save_lens_visualization.journey.ts | 55 +++++++++++++++++++ .../overview_errors_sparklines.tsx | 1 + 4 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/overview_save_lens_visualization.journey.ts diff --git a/x-pack/solutions/observability/plugins/exploratory_view/public/components/shared/exploratory_view/embeddable/embeddable.tsx b/x-pack/solutions/observability/plugins/exploratory_view/public/components/shared/exploratory_view/embeddable/embeddable.tsx index 66efa951ff300..9cd6e2a85e75b 100644 --- a/x-pack/solutions/observability/plugins/exploratory_view/public/components/shared/exploratory_view/embeddable/embeddable.tsx +++ b/x-pack/solutions/observability/plugins/exploratory_view/public/components/shared/exploratory_view/embeddable/embeddable.tsx @@ -9,12 +9,7 @@ import { i18n } from '@kbn/i18n'; import { Position } from '@elastic/charts'; import React, { useState } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui'; -import { - FormulaPublicApi, - LensEmbeddableInput, - LensPublicStart, - XYState, -} from '@kbn/lens-plugin/public'; +import { FormulaPublicApi, LensPublicStart, XYState } from '@kbn/lens-plugin/public'; import { observabilityFeatureId } from '@kbn/observability-shared-plugin/public'; import styled from 'styled-components'; import { AnalyticsServiceSetup } from '@kbn/core-analytics-browser'; @@ -217,7 +212,7 @@ export default function Embeddable(props: ExploratoryEmbeddableComponentProps) { /> {isSaveOpen && attributesJSON && ( setIsSaveOpen(false)} // if we want to do anything after the viz is saved // right now there is no action, so an empty function diff --git a/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/index.ts b/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/index.ts index 61ece103432b4..e2a1145645b43 100644 --- a/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/index.ts +++ b/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/index.ts @@ -26,3 +26,4 @@ export * from './monitor_details_page/monitor_summary.journey'; export * from './test_run_details.journey'; export * from './step_details.journey'; export * from './project_monitor_read_only.journey'; +export * from './overview_save_lens_visualization.journey'; diff --git a/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/overview_save_lens_visualization.journey.ts b/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/overview_save_lens_visualization.journey.ts new file mode 100644 index 0000000000000..d4f87466f6e5c --- /dev/null +++ b/x-pack/solutions/observability/plugins/synthetics/e2e/synthetics/journeys/overview_save_lens_visualization.journey.ts @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { before, expect, journey, step, after } from '@elastic/synthetics'; +import { syntheticsAppPageProvider } from '../page_objects/synthetics_app'; +import { SyntheticsServices } from './services/synthetics_services'; + +journey('OverviewSaveLensVisualization', async ({ page, params }) => { + const syntheticsApp = syntheticsAppPageProvider({ page, kibanaUrl: params.kibanaUrl, params }); + const syntheticsService = new SyntheticsServices(params); + + before(async () => { + await syntheticsService.cleanUp(); + }); + + after(async () => { + await syntheticsService.cleanUp(); + }); + + step('Go to Monitors overview page', async () => { + await syntheticsApp.navigateToOverview(true, 15); + }); + + step('Create test monitor', async () => { + await syntheticsService.addTestMonitor('Test Overview Save Lens Visualization Monitor', { + type: 'http', + urls: 'https://www.google.com', + locations: ['us_central'], + }); + await page.getByTestId('syntheticsRefreshButtonButton').click(); + }); + + step('Open the save lens visualization', async () => { + await page + .getByTestId('overviewErrorsSparklines') + .getByTestId('embeddablePanelHoverActions-') + .hover(); + + await page + .getByTestId('overviewErrorsSparklines') + .getByTestId('embeddablePanelToggleMenuIcon') + .click(); + await page.getByTestId('embeddablePanelAction-expViewSave').click(); + }); + + step('The attributes are correctly passed to the save lens visualization modal', async () => { + expect(await page.getByTestId('savedObjectTitle').inputValue()).toBe( + 'Prefilled from exploratory view app' + ); + }); +}); diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_errors/overview_errors_sparklines.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_errors/overview_errors_sparklines.tsx index b97e0eef8bbb5..bda21026444c7 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_errors/overview_errors_sparklines.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/monitors_page/overview/overview/overview_errors/overview_errors_sparklines.tsx @@ -29,6 +29,7 @@ export const OverviewErrorsSparklines = ({ from, to, monitorIds, locations }: Pr return (