-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
_field_data.ts
116 lines (102 loc) · 4.73 KB
/
_field_data.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* 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']);
describe('discover tab', function describeIndexTests() {
this.tags('includeFirefox');
before(async function () {
await esArchiver.loadIfNeeded('logstash_functional');
await esArchiver.load('discover');
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
const marks = await PageObjects.discover.getMarks();
expect(marks.length).to.be(50);
expect(marks.indexOf('php')).to.be(0);
});
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('doc view should show Time and _source columns', async function () {
const expectedHeader = 'Time _source';
const Docheader = await PageObjects.discover.getDocHeader();
expect(Docheader).to.be(expectedHeader);
});
it('doc view should sort ascending', async function () {
const expectedTimeStamp = 'Sep 20, 2015 @ 00:00:00.000';
await PageObjects.discover.clickDocSortDown();
// 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 rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData.startsWith(expectedTimeStamp)).to.be.ok();
});
});
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.be('Time relatedContent');
});
const field = await PageObjects.discover.getDocTableField(1, 1);
expect(field).to.include.string('"og:description":');
const marks = await PageObjects.discover.getMarks();
expect(marks.length).to.be(0);
});
});
});
}