135 lines
5.7 KiB
TypeScript
135 lines
5.7 KiB
TypeScript
/*
|
|
* 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 retry = getService('retry');
|
|
const esArchiver = getService('esArchiver');
|
|
const kibanaServer = getService('kibanaServer');
|
|
const toasts = getService('toasts');
|
|
const queryBar = getService('queryBar');
|
|
const browser = getService('browser');
|
|
const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize', 'timePicker']);
|
|
const find = getService('find');
|
|
const testSubjects = getService('testSubjects');
|
|
|
|
describe('discover tab', function describeIndexTests() {
|
|
this.tags('includeFirefox');
|
|
before(async function () {
|
|
await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] });
|
|
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json');
|
|
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
|
|
await kibanaServer.uiSettings.replace({
|
|
defaultIndex: 'logstash-*',
|
|
'discover:searchFieldsFromSource': true,
|
|
});
|
|
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
|
|
await PageObjects.common.navigateToApp('discover');
|
|
});
|
|
describe('field data', function () {
|
|
it('search php should show the correct hit count', async function () {
|
|
const expectedHitCount = '445';
|
|
await retry.try(async function () {
|
|
await queryBar.setQuery('php');
|
|
await queryBar.submitQuery();
|
|
const hitCount = await PageObjects.discover.getHitCount();
|
|
expect(hitCount).to.be(expectedHitCount);
|
|
});
|
|
});
|
|
|
|
it('the search term should be highlighted in the field data', async function () {
|
|
// marks is the style that highlights the text in yellow
|
|
await queryBar.setQuery('php');
|
|
await queryBar.submitQuery();
|
|
await PageObjects.discover.clickFieldListItemAdd('extension');
|
|
const marks = await PageObjects.discover.getMarks();
|
|
expect(marks.length).to.be.greaterThan(0);
|
|
expect(marks.indexOf('php')).to.be(0);
|
|
await PageObjects.discover.clickFieldListItemRemove('extension');
|
|
});
|
|
|
|
it('search type:apache should show the correct hit count', async function () {
|
|
const expectedHitCount = '11,156';
|
|
await queryBar.setQuery('type:apache');
|
|
await queryBar.submitQuery();
|
|
await retry.try(async function tryingForTime() {
|
|
const hitCount = await PageObjects.discover.getHitCount();
|
|
expect(hitCount).to.be(expectedHitCount);
|
|
});
|
|
});
|
|
|
|
it('a bad syntax query should show an error message', async function () {
|
|
const expectedError =
|
|
'Expected ":", "<", "<=", ">", ">=", AND, OR, end of input, ' +
|
|
'whitespace but "(" found.';
|
|
await queryBar.setQuery('xxx(yyy))');
|
|
await queryBar.submitQuery();
|
|
const { message } = await toasts.getErrorToast();
|
|
expect(message).to.contain(expectedError);
|
|
await toasts.dismissToast();
|
|
});
|
|
|
|
it('shows top-level object keys', async function () {
|
|
await queryBar.setQuery('election');
|
|
await queryBar.submitQuery();
|
|
const currentUrl = await browser.getCurrentUrl();
|
|
const [, hash] = currentUrl.split('#/');
|
|
await PageObjects.common.navigateToUrl(
|
|
'discover',
|
|
hash.replace('columns:!(_source)', 'columns:!(relatedContent)'),
|
|
{ useActualUrl: true }
|
|
);
|
|
await retry.try(async function tryingForTime() {
|
|
expect(await PageObjects.discover.getDocHeader()).to.contain('relatedContent');
|
|
});
|
|
|
|
const field = await PageObjects.discover.getDocTableIndex(1);
|
|
expect(field).to.contain('og:description');
|
|
|
|
const marks = await PageObjects.discover.getMarks();
|
|
expect(marks.length).to.be(0);
|
|
});
|
|
|
|
describe('legacy table tests', async function () {
|
|
before(async function () {
|
|
await kibanaServer.uiSettings.update({ 'doc_table:legacy': true });
|
|
await PageObjects.common.navigateToApp('discover');
|
|
});
|
|
|
|
after(async function () {
|
|
await kibanaServer.uiSettings.replace({});
|
|
});
|
|
it('doc view should show Time and _source columns', async function () {
|
|
const expectedHeader = 'Time\n_source';
|
|
const docHeader = await find.byCssSelector('thead > tr:nth-child(1)');
|
|
const docHeaderText = await docHeader.getVisibleText();
|
|
expect(docHeaderText).to.be(expectedHeader);
|
|
});
|
|
|
|
it('doc view should sort ascending', async function () {
|
|
const expectedTimeStamp = 'Sep 20, 2015 @ 00:00:00.000';
|
|
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
|
|
|
|
// we don't technically need this sleep here because the tryForTime will retry and the
|
|
// results will match on the 2nd or 3rd attempt, but that debug output is huge in this
|
|
// case and it can be avoided with just a few seconds sleep.
|
|
await PageObjects.common.sleep(2000);
|
|
await retry.try(async function tryingForTime() {
|
|
const row = await find.byCssSelector(`tr.kbnDocTable__row:nth-child(1)`);
|
|
const rowData = await row.getVisibleText();
|
|
expect(rowData.startsWith(expectedTimeStamp)).to.be.ok();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|