From 3687a6b4f53f749aff958e94cc669e71176ea498 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Tue, 3 Mar 2020 14:29:39 -0700 Subject: [PATCH] [Maps] add functional test to ensure visualize create menu only shows Maps app (#58746) (#59210) Co-authored-by: Elastic Machine Co-authored-by: Elastic Machine --- .../functional/page_objects/visualize_page.ts | 28 +++++++++++-- x-pack/test/functional/apps/maps/index.js | 1 + .../apps/maps/visualize_create_menu.js | 40 +++++++++++++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 x-pack/test/functional/apps/maps/visualize_create_menu.js diff --git a/test/functional/page_objects/visualize_page.ts b/test/functional/page_objects/visualize_page.ts index 82ef3dc800f6c5..3b63fa68d71ee9 100644 --- a/test/functional/page_objects/visualize_page.ts +++ b/test/functional/page_objects/visualize_page.ts @@ -79,6 +79,10 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide await this.waitForVisualizationSelectPage(); } + public async hasVisType(type: string) { + return await testSubjects.exists(`visType-${type}`); + } + public async clickVisType(type: string) { await testSubjects.click(`visType-${type}`); await header.waitUntilLoadingHasFinished(); @@ -100,6 +104,10 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide await this.clickVisType('region_map'); } + public async hasRegionMap() { + return await this.hasVisType('region_map'); + } + public async clickMarkdownWidget() { await this.clickVisType('markdown'); } @@ -120,6 +128,10 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide await this.clickVisType('tile_map'); } + public async hasTileMap() { + return await this.hasVisType('tile_map'); + } + public async clickTagCloud() { await this.clickVisType('tagcloud'); } @@ -144,6 +156,18 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide await this.clickVisType('input_control_vis'); } + public async clickLensWidget() { + await this.clickVisType('lens'); + } + + public async clickMapsApp() { + await this.clickVisType('maps'); + } + + public async hasMapsApp() { + return await this.hasVisType('maps'); + } + public async createSimpleMarkdownViz(vizName: string) { await this.gotoVisualizationLandingPage(); await this.navigateToNewVisualization(); @@ -315,10 +339,6 @@ export function VisualizePageProvider({ getService, getPageObjects }: FtrProvide async () => (await globalNav.getLastBreadcrumb()) === vizName ); } - - public async clickLensWidget() { - await this.clickVisType('lens'); - } } return new VisualizePage(); diff --git a/x-pack/test/functional/apps/maps/index.js b/x-pack/test/functional/apps/maps/index.js index e8a9d7ba54bc55..44a7c4c9a5f866 100644 --- a/x-pack/test/functional/apps/maps/index.js +++ b/x-pack/test/functional/apps/maps/index.js @@ -45,6 +45,7 @@ export default function({ loadTestFile, getService }) { loadTestFile(require.resolve('./import_geojson')); loadTestFile(require.resolve('./layer_errors')); loadTestFile(require.resolve('./embeddable')); + loadTestFile(require.resolve('./visualize_create_menu')); loadTestFile(require.resolve('./discover')); }); }); diff --git a/x-pack/test/functional/apps/maps/visualize_create_menu.js b/x-pack/test/functional/apps/maps/visualize_create_menu.js new file mode 100644 index 00000000000000..ed0c153b9f99d2 --- /dev/null +++ b/x-pack/test/functional/apps/maps/visualize_create_menu.js @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; + +export default function({ getPageObjects }) { + const PageObjects = getPageObjects(['visualize', 'header', 'maps']); + + describe('visualize create menu', () => { + before(async () => { + await PageObjects.visualize.navigateToNewVisualization(); + }); + + it('should show maps application in create menu', async () => { + const hasMapsApp = await PageObjects.visualize.hasMapsApp(); + expect(hasMapsApp).to.equal(true); + }); + + it('should not show legacy region map visualizion in create menu', async () => { + const hasLegecyViz = await PageObjects.visualize.hasRegionMap(); + expect(hasLegecyViz).to.equal(false); + }); + + it('should not show legacy tilemap map visualizion in create menu', async () => { + const hasLegecyViz = await PageObjects.visualize.hasTileMap(); + expect(hasLegecyViz).to.equal(false); + }); + + it('should take users to Maps application when Maps is clicked', async () => { + await PageObjects.visualize.clickMapsApp(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.maps.waitForLayersToLoad(); + const doesLayerExist = await PageObjects.maps.doesLayerExist('Road map'); + expect(doesLayerExist).to.equal(true); + }); + }); +}