Skip to content

Commit

Permalink
[8.15] [Discover] Add functional tests for defaultRoute setting (#189801
Browse files Browse the repository at this point in the history
) (#189849)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Discover] Add functional tests for defaultRoute setting
(#189801)](#189801)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-08-03T19:27:46Z","message":"[Discover]
Add functional tests for defaultRoute setting (#189801)\n\n- Follow up
for https://github.com/elastic/kibana/issues/189184\r\n\r\n##
Summary\r\n\r\nAdding more
tests.","sha":"faf86d2242e6872114c8cf5ce96d97c65a83b3d0","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:DataDiscovery","backport:prev-minor","v8.16.0"],"title":"[Discover]
Add functional tests for defaultRoute
setting","number":189801,"url":"https://github.com/elastic/kibana/pull/189801","mergeCommit":{"message":"[Discover]
Add functional tests for defaultRoute setting (#189801)\n\n- Follow up
for https://github.com/elastic/kibana/issues/189184\r\n\r\n##
Summary\r\n\r\nAdding more
tests.","sha":"faf86d2242e6872114c8cf5ce96d97c65a83b3d0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/189801","number":189801,"mergeCommit":{"message":"[Discover]
Add functional tests for defaultRoute setting (#189801)\n\n- Follow up
for https://github.com/elastic/kibana/issues/189184\r\n\r\n##
Summary\r\n\r\nAdding more
tests.","sha":"faf86d2242e6872114c8cf5ce96d97c65a83b3d0"}}]}]
BACKPORT-->

Co-authored-by: Julia Rechkunova <[email protected]>
  • Loading branch information
kibanamachine and jughosta authored Aug 3, 2024
1 parent 6c9cc62 commit 8aa0b59
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/functional/apps/discover/group8/_default_route.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/group8/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
}

0 comments on commit 8aa0b59

Please sign in to comment.