diff --git a/test/functional/apps/discover/group8/_default_route.ts b/test/functional/apps/discover/group8/_default_route.ts new file mode 100644 index 0000000000000..2740d6e42f6cb --- /dev/null +++ b/test/functional/apps/discover/group8/_default_route.ts @@ -0,0 +1,74 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const PageObjects = getPageObjects([ + 'common', + 'home', + 'settings', + 'discover', + 'timePicker', + 'header', + ]); + const kibanaServer = getService('kibanaServer'); + const security = getService('security'); + const retry = getService('retry'); + const deployment = getService('deployment'); + const browser = getService('browser'); + const filterBar = getService('filterBar'); + const queryBar = getService('queryBar'); + + describe('discover as defaultRoute', function () { + before(async function () { + await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']); + await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + }); + + after(async () => { + await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + await kibanaServer.uiSettings.replace({}); + await kibanaServer.savedObjects.cleanStandardList(); + }); + + it('can use a saved search as defaultRoute', async function () { + await kibanaServer.uiSettings.update({ + defaultRoute: '/app/discover#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a', + }); + await browser.navigateTo(deployment.getHostPort()); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await retry.try(async () => { + expect(await PageObjects.discover.getCurrentQueryName()).to.be('A Saved Search'); + expect(await PageObjects.discover.getHitCount()).to.be('14,004'); + }); + }); + + it('can use a URL with filters as defaultRoute', async function () { + await kibanaServer.uiSettings.update({ + defaultRoute: + "/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:'2015-09-19T06:31:44.000Z',to:'2015-09-23T18:31:44.000Z'))&_a=(columns:!(extension,host),dataSource:(dataViewId:'logstash-*',type:dataView),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,field:extension.raw,index:'logstash-*',key:extension.raw,negate:!f,params:(query:jpg),type:phrase),query:(match_phrase:(extension.raw:jpg)))),hideChart:!f,interval:auto,query:(language:lucene,query:media),sort:!(!('@timestamp',desc)))", + }); + await browser.navigateTo(deployment.getHostPort()); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await retry.try(async () => { + expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true); + expect(await queryBar.getQueryString()).to.be('media'); + expect(await PageObjects.discover.getHitCount()).to.be('9,109'); + }); + }); + }); +} diff --git a/test/functional/apps/discover/group8/index.ts b/test/functional/apps/discover/group8/index.ts index 09aaca23e8b95..962fe266776a1 100644 --- a/test/functional/apps/discover/group8/index.ts +++ b/test/functional/apps/discover/group8/index.ts @@ -20,6 +20,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); }); + loadTestFile(require.resolve('./_default_route')); loadTestFile(require.resolve('./_hide_announcements')); }); }