From cea2b4b7b8554cdb10317a6edd67bb741e3d38af Mon Sep 17 00:00:00 2001 From: Adela Almasan <88068998+adela-almasan@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:34:24 -0500 Subject: [PATCH] Geomap: Spatial operations location options transform e2e test (#54162) --- ...geomap-spatial-operations-transformer.json | 125 ++++++++++++++++++ ...eomap-spatial-operations-transform.spec.ts | 119 +++++++++++++++++ .../src/selectors/components.ts | 21 +++ .../app/features/geo/editor/locationEditor.ts | 25 +++- 4 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 devenv/dev-dashboards/panel-geomap/geomap-spatial-operations-transformer.json create mode 100644 e2e/various-suite/geomap-spatial-operations-transform.spec.ts diff --git a/devenv/dev-dashboards/panel-geomap/geomap-spatial-operations-transformer.json b/devenv/dev-dashboards/panel-geomap/geomap-spatial-operations-transformer.json new file mode 100644 index 00000000000..e7f869e351c --- /dev/null +++ b/devenv/dev-dashboards/panel-geomap/geomap-spatial-operations-transformer.json @@ -0,0 +1,125 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "controls": { + "mouseWheelZoom": true, + "showAttribution": true, + "showDebug": false, + "showMeasure": false, + "showScale": false, + "showZoom": true + }, + "tooltip": { + "mode": "details" + }, + "view": { + "id": "zero", + "lat": 0, + "lon": 0, + "zoom": 1 + } + }, + "pluginVersion": "9.2.0-pre", + "targets": [ + { + "csvFileName": "flight_info_by_state.csv", + "datasource": { + "type": "testdata", + "uid": "PD8C576611E62080A" + }, + "refId": "A", + "scenarioId": "csv_file" + } + ], + "title": "Geomap/Geohash", + "type": "geomap" + } + ], + "schemaVersion": 37, + "style": "dark", + "tags": [ + "gdev", + "panel-tests", + "geomap" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Panel Tests - Geomap geohash transformer", + "uid": "P2jR04WVk", + "version": 10, + "weekStart": "" +} diff --git a/e2e/various-suite/geomap-spatial-operations-transform.spec.ts b/e2e/various-suite/geomap-spatial-operations-transform.spec.ts new file mode 100644 index 00000000000..54ba2ae4526 --- /dev/null +++ b/e2e/various-suite/geomap-spatial-operations-transform.spec.ts @@ -0,0 +1,119 @@ +import { e2e } from '@grafana/e2e'; + +const DASHBOARD_ID = 'P2jR04WVk'; + +e2e.scenario({ + describeName: 'Geomap spatial operations - auto transforms', + itName: 'Tests location auto option', + addScenarioDataSource: false, + addScenarioDashBoard: false, + skipScenario: false, + scenario: () => { + e2e.flows.openDashboard({ uid: DASHBOARD_ID, queryParams: { editPanel: 1 } }); + e2e.components.Tab.title('Transform').should('be.visible').click(); + + e2e.components.TransformTab.newTransform('Spatial operations').scrollIntoView().should('be.visible').click(); + e2e.components.Transforms.SpatialOperations.actionLabel().type('Prepare spatial field{enter}'); + e2e.components.Transforms.SpatialOperations.locationLabel().should('be.visible'); + + e2e.components.Transforms.SpatialOperations.location.autoOption().check({ force: true }); + e2e.components.Transforms.SpatialOperations.location.autoOption().should('be.checked'); + + e2e.components.PanelEditor.toggleTableView().click({ force: true }); + e2e.components.Panels.Visualization.Table.header() + .should('be.visible') + .within(() => { + cy.contains('Point').should('be.visible'); + }); + }, +}); + +e2e.scenario({ + describeName: 'Geomap spatial operations - coords transforms ', + itName: 'Tests location coords option', + addScenarioDataSource: false, + addScenarioDashBoard: false, + skipScenario: false, + scenario: () => { + e2e.flows.openDashboard({ uid: DASHBOARD_ID, queryParams: { editPanel: 1 } }); + e2e.components.Tab.title('Transform').should('be.visible').click(); + + e2e.components.TransformTab.newTransform('Spatial operations').scrollIntoView().should('be.visible').click(); + e2e.components.Transforms.SpatialOperations.actionLabel().type('Prepare spatial field{enter}'); + e2e.components.Transforms.SpatialOperations.locationLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.coords.option().check({ force: true }); + e2e.components.Transforms.SpatialOperations.location.coords.option().should('be.checked'); + + e2e.components.Transforms.SpatialOperations.location.coords.latitudeFieldLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.coords.latitudeFieldLabel().type('Lat{enter}'); + + e2e.components.Transforms.SpatialOperations.location.coords.longitudeFieldLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.coords.longitudeFieldLabel().type('Lng{enter}'); + + e2e.components.PanelEditor.toggleTableView().click({ force: true }); + e2e.components.Panels.Visualization.Table.header() + .should('be.visible') + .within(() => { + cy.contains('Point').should('be.visible'); + }); + }, +}); + +e2e.scenario({ + describeName: 'Geomap spatial operations - geohash transforms ', + itName: 'Tests geoshash field column appears in table view', + addScenarioDataSource: false, + addScenarioDashBoard: false, + skipScenario: false, + scenario: () => { + e2e.flows.openDashboard({ uid: DASHBOARD_ID, queryParams: { editPanel: 1 } }); + e2e.components.Tab.title('Transform').should('be.visible').click(); + + e2e.components.TransformTab.newTransform('Spatial operations').scrollIntoView().should('be.visible').click(); + e2e.components.Transforms.SpatialOperations.actionLabel().type('Prepare spatial field{enter}'); + e2e.components.Transforms.SpatialOperations.locationLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.geohash.option().check({ force: true }); + e2e.components.Transforms.SpatialOperations.location.geohash + .geohashFieldLabel() + .should('be.visible') + .type('State{enter}'); + + e2e.components.PanelEditor.toggleTableView().click({ force: true }); + e2e.components.Panels.Visualization.Table.header() + .should('be.visible') + .within(() => { + cy.contains('State 1').should('be.visible'); + }); + }, +}); + +e2e.scenario({ + describeName: 'Geomap spatial operations - lookup transforms ', + itName: 'Tests location lookup option', + addScenarioDataSource: false, + addScenarioDashBoard: false, + skipScenario: false, + scenario: () => { + e2e.flows.openDashboard({ uid: DASHBOARD_ID, queryParams: { editPanel: 1 } }); + e2e.components.Tab.title('Transform').should('be.visible').click(); + + e2e.components.TransformTab.newTransform('Spatial operations').scrollIntoView().should('be.visible').click(); + e2e.components.Transforms.SpatialOperations.actionLabel().type('Prepare spatial field{enter}'); + e2e.components.Transforms.SpatialOperations.locationLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.lookup.option().check({ force: true }); + e2e.components.Transforms.SpatialOperations.location.lookup.option().should('be.checked'); + + e2e.components.Transforms.SpatialOperations.location.lookup.lookupFieldLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.lookup.lookupFieldLabel().type('State{enter}'); + + e2e.components.Transforms.SpatialOperations.location.lookup.gazetteerFieldLabel().should('be.visible'); + e2e.components.Transforms.SpatialOperations.location.lookup.gazetteerFieldLabel().type('USA States{enter}'); + + e2e.components.PanelEditor.toggleTableView().click({ force: true }); + e2e.components.Panels.Visualization.Table.header() + .should('be.visible') + .within(() => { + cy.contains('Geometry').should('be.visible'); + }); + }, +}); diff --git a/packages/grafana-e2e-selectors/src/selectors/components.ts b/packages/grafana-e2e-selectors/src/selectors/components.ts index 7815c89e92b..cb9be600448 100644 --- a/packages/grafana-e2e-selectors/src/selectors/components.ts +++ b/packages/grafana-e2e-selectors/src/selectors/components.ts @@ -199,6 +199,27 @@ export const Components = { modeLabel: 'Transform mode label', calculationsLabel: 'Transform calculations label', }, + SpatialOperations: { + actionLabel: 'root Action field property editor', + locationLabel: 'root Location field property editor', + location: { + autoOption: 'Auto location option', + coords: { + option: 'Coords location option', + latitudeFieldLabel: 'root Latitude field field property editor', + longitudeFieldLabel: 'root Longitude field field property editor', + }, + geohash: { + option: 'Geohash location option', + geohashFieldLabel: 'root Geohash field field property editor', + }, + lookup: { + option: 'Lookup location option', + lookupFieldLabel: 'root Lookup field field property editor', + gazetteerFieldLabel: 'root Gazetteer field property editor', + }, + }, + }, searchInput: 'search transformations', }, PageToolbar: { diff --git a/public/app/features/geo/editor/locationEditor.ts b/public/app/features/geo/editor/locationEditor.ts index d8a5cc8fcab..0358b3eb8ef 100644 --- a/public/app/features/geo/editor/locationEditor.ts +++ b/public/app/features/geo/editor/locationEditor.ts @@ -5,6 +5,7 @@ import { FrameGeometrySourceMode, PanelOptionsEditorBuilder, } from '@grafana/data'; +import { selectors } from '@grafana/e2e-selectors/src'; import { GazetteerPathEditor } from 'app/features/geo/editor/GazetteerPathEditor'; export function addLocationFields( @@ -20,10 +21,26 @@ export function addLocationFields( defaultValue: FrameGeometrySourceMode.Auto, settings: { options: [ - { value: FrameGeometrySourceMode.Auto, label: 'Auto' }, - { value: FrameGeometrySourceMode.Coords, label: 'Coords' }, - { value: FrameGeometrySourceMode.Geohash, label: 'Geohash' }, - { value: FrameGeometrySourceMode.Lookup, label: 'Lookup' }, + { + value: FrameGeometrySourceMode.Auto, + label: 'Auto', + ariaLabel: selectors.components.Transforms.SpatialOperations.location.autoOption, + }, + { + value: FrameGeometrySourceMode.Coords, + label: 'Coords', + ariaLabel: selectors.components.Transforms.SpatialOperations.location.coords.option, + }, + { + value: FrameGeometrySourceMode.Geohash, + label: 'Geohash', + ariaLabel: selectors.components.Transforms.SpatialOperations.location.geohash.option, + }, + { + value: FrameGeometrySourceMode.Lookup, + label: 'Lookup', + ariaLabel: selectors.components.Transforms.SpatialOperations.location.lookup.option, + }, ], }, });