Conversion to ES6 - Discover tests (#20112)

Discover Tests conversion to ES6
This commit is contained in:
Rashmi Kulkarni 2018-06-22 09:38:47 -07:00 committed by GitHub
parent 3b983e9c22
commit 1ab14f1637
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 361 additions and 271 deletions

View file

@ -26,64 +26,51 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['common', 'discover', 'header']);
describe('discover tab', function describeIndexTests() {
before(function () {
before(async function () {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';
// delete .kibana index and update configDoc
return kibanaServer.uiSettings.replace({
await kibanaServer.uiSettings.replace({
'dateFormat:tz': 'UTC',
'defaultIndex': 'logstash-*'
})
.then(function loadkibanaIndexPattern() {
log.debug('load kibana index with default index pattern');
return esArchiver.load('discover');
})
defaultIndex: 'logstash-*',
});
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');
// and load a set of makelogs data
.then(function loadIfEmptyMakelogs() {
return esArchiver.loadIfNeeded('logstash_functional');
})
.then(function () {
log.debug('discover');
return PageObjects.common.navigateToApp('discover');
})
.then(function () {
log.debug('setAbsoluteRange');
return PageObjects.header.setAbsoluteRange(fromTime, toTime);
});
await esArchiver.loadIfNeeded('logstash_functional');
log.debug('discover');
await PageObjects.common.navigateToApp('discover');
log.debug('setAbsoluteRange');
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
});
describe('field data', function () {
it('should initially be expanded', function () {
return PageObjects.discover.getSidebarWidth()
.then(function (width) {
log.debug('expanded sidebar width = ' + width);
expect(width > 20).to.be(true);
});
describe('collapse expand', function () {
it('should initially be expanded', async function () {
const width = await PageObjects.discover.getSidebarWidth();
log.debug('expanded sidebar width = ' + width);
expect(width > 20).to.be(true);
});
it('should collapse when clicked', function () {
return PageObjects.discover.toggleSidebarCollapse()
.then(function () {
log.debug('PageObjects.discover.getSidebarWidth()');
return PageObjects.discover.getSidebarWidth();
})
.then(function (width) {
log.debug('collapsed sidebar width = ' + width);
expect(width < 20).to.be(true);
});
it('should collapse when clicked', async function () {
await PageObjects.discover.toggleSidebarCollapse();
log.debug('PageObjects.discover.getSidebarWidth()');
const width = await PageObjects.discover.getSidebarWidth();
log.debug('collapsed sidebar width = ' + width);
expect(width < 20).to.be(true);
});
it('should expand when clicked', function () {
return PageObjects.discover.toggleSidebarCollapse()
.then(function () {
log.debug('PageObjects.discover.getSidebarWidth()');
return PageObjects.discover.getSidebarWidth();
})
.then(function (width) {
log.debug('expanded sidebar width = ' + width);
expect(width > 20).to.be(true);
});
it('should expand when clicked', async function () {
await PageObjects.discover.toggleSidebarCollapse();
log.debug('PageObjects.discover.getSidebarWidth()');
const width = await PageObjects.discover.getSidebarWidth();
log.debug('expanded sidebar width = ' + width);
expect(width > 20).to.be(true);
});
});
});

View file

@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['common', 'discover', 'header']);
const defaultSettings = {
'dateFormat:tz': 'UTC',
'defaultIndex': 'logstash-*'
defaultIndex: 'logstash-*',
};
describe('discover app', function describeIndexTests() {
@ -73,20 +73,48 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.discover.loadSavedSearch(queryName1);
await retry.try(async function () {
expect(await PageObjects.discover.getCurrentQueryName()).to.be(queryName1);
expect(await PageObjects.discover.getCurrentQueryName()).to.be(
queryName1
);
});
});
it('should show the correct hit count', async function () {
const expectedHitCount = '14,004';
await retry.try(async function () {
expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount);
expect(await PageObjects.discover.getHitCount()).to.be(
expectedHitCount
);
});
});
it('should show the correct bar chart', async function () {
const expectedBarChartData = [ 35, 189, 694, 1347, 1285, 704, 176, 29, 39, 189, 640,
1276, 1327, 663, 166, 25, 30, 164, 663, 1320, 1270, 681, 188, 27 ];
const expectedBarChartData = [
35,
189,
694,
1347,
1285,
704,
176,
29,
39,
189,
640,
1276,
1327,
663,
166,
25,
30,
164,
663,
1320,
1270,
681,
188,
27,
];
await verifyChartData(expectedBarChartData);
});
@ -107,16 +135,86 @@ export default function ({ getService, getPageObjects }) {
it('should show correct data for chart interval Hourly', async function () {
await PageObjects.discover.setChartInterval('Hourly');
const expectedBarChartData = [ 4, 7, 16, 23, 38, 87, 132, 159, 248, 320, 349, 376, 380,
324, 293, 233, 188, 125, 69, 40, 28, 17, 2, 3, 8, 10, 12, 28, 36, 84, 111, 157, 229, 292,
324, 373, 378, 345, 306, 223, 167, 124, 72, 35, 22, 11, 7, 1, 6, 5, 12, 25, 27, 76, 111, 175,
228, 294, 358, 372, 366, 344, 276, 213, 201, 113, 72, 39, 36, 12, 7, 3 ];
const expectedBarChartData = [
4,
7,
16,
23,
38,
87,
132,
159,
248,
320,
349,
376,
380,
324,
293,
233,
188,
125,
69,
40,
28,
17,
2,
3,
8,
10,
12,
28,
36,
84,
111,
157,
229,
292,
324,
373,
378,
345,
306,
223,
167,
124,
72,
35,
22,
11,
7,
1,
6,
5,
12,
25,
27,
76,
111,
175,
228,
294,
358,
372,
366,
344,
276,
213,
201,
113,
72,
39,
36,
12,
7,
3,
];
await verifyChartData(expectedBarChartData);
});
it('should show correct data for chart interval Daily', async function () {
const chartInterval = 'Daily';
const expectedBarChartData = [ 4757, 4614, 4633 ];
const expectedBarChartData = [4757, 4614, 4633];
await PageObjects.discover.setChartInterval(chartInterval);
await retry.try(async () => {
await verifyChartData(expectedBarChartData);
@ -125,7 +223,7 @@ export default function ({ getService, getPageObjects }) {
it('should show correct data for chart interval Weekly', async function () {
const chartInterval = 'Weekly';
const expectedBarChartData = [ 4757, 9247 ];
const expectedBarChartData = [4757, 9247];
await PageObjects.discover.setChartInterval(chartInterval);
await retry.try(async () => {
@ -135,7 +233,7 @@ export default function ({ getService, getPageObjects }) {
it('browser back button should show previous interval Daily', async function () {
const expectedChartInterval = 'Daily';
const expectedBarChartData = [ 4757, 4614, 4633 ];
const expectedBarChartData = [4757, 4614, 4633];
await remote.goBack();
await retry.try(async function tryingForTime() {
@ -147,7 +245,7 @@ export default function ({ getService, getPageObjects }) {
it('should show correct data for chart interval Monthly', async function () {
const chartInterval = 'Monthly';
const expectedBarChartData = [ 13129 ];
const expectedBarChartData = [13129];
await PageObjects.discover.setChartInterval(chartInterval);
await verifyChartData(expectedBarChartData);
@ -155,7 +253,7 @@ export default function ({ getService, getPageObjects }) {
it('should show correct data for chart interval Yearly', async function () {
const chartInterval = 'Yearly';
const expectedBarChartData = [ 13129 ];
const expectedBarChartData = [13129];
await PageObjects.discover.setChartInterval(chartInterval);
await verifyChartData(expectedBarChartData);
@ -163,8 +261,32 @@ export default function ({ getService, getPageObjects }) {
it('should show correct data for chart interval Auto', async function () {
const chartInterval = 'Auto';
const expectedBarChartData = [ 35, 189, 694, 1347, 1285, 704, 176, 29, 39, 189,
640, 1276, 1327, 663, 166, 25, 30, 164, 663, 1320, 1270, 681, 188, 27 ];
const expectedBarChartData = [
35,
189,
694,
1347,
1285,
704,
176,
29,
39,
189,
640,
1276,
1327,
663,
166,
25,
30,
164,
663,
1320,
1270,
681,
188,
27,
];
await PageObjects.discover.setChartInterval(chartInterval);
await verifyChartData(expectedBarChartData);
@ -190,9 +312,19 @@ export default function ({ getService, getPageObjects }) {
let stringResults = '';
let hasFailure = false;
for (let y = 0; y < expectedBarChartData.length; y++) {
stringResults += y + ': expected = ' + expectedBarChartData[y] + ', actual = ' + paths[y] +
', Pass = ' + (Math.abs(expectedBarChartData[y] - paths[y]) < barHeightTolerance) + '\n';
if ((Math.abs(expectedBarChartData[y] - paths[y]) > barHeightTolerance)) {
stringResults +=
y +
': expected = ' +
expectedBarChartData[y] +
', actual = ' +
paths[y] +
', Pass = ' +
(Math.abs(expectedBarChartData[y] - paths[y]) <
barHeightTolerance) +
'\n';
if (
Math.abs(expectedBarChartData[y] - paths[y]) > barHeightTolerance
) {
hasFailure = true;
}
}
@ -201,7 +333,9 @@ export default function ({ getService, getPageObjects }) {
log.debug(paths);
}
for (let x = 0; x < expectedBarChartData.length; x++) {
expect(Math.abs(expectedBarChartData[x] - paths[x]) < barHeightTolerance).to.be.ok();
expect(
Math.abs(expectedBarChartData[x] - paths[x]) < barHeightTolerance
).to.be.ok();
}
});
}
@ -213,8 +347,7 @@ export default function ({ getService, getPageObjects }) {
before(() => {
log.debug('setAbsoluteRangeForAnotherQuery');
return PageObjects.header
.setAbsoluteRange(fromTime, toTime);
return PageObjects.header.setAbsoluteRange(fromTime, toTime);
});
it('should show "no results"', async () => {
@ -257,12 +390,15 @@ export default function ({ getService, getPageObjects }) {
it('should have correct data-shared-item title and description', async () => {
const expected = {
title: 'A Saved Search',
description: 'A Saved Search Description'
description: 'A Saved Search Description',
};
await retry.try(async () => {
await PageObjects.discover.loadSavedSearch(expected.title);
const { title, description } = await PageObjects.common.getSharedItemTitleAndDescription();
const {
title,
description,
} = await PageObjects.common.getSharedItemTitleAndDescription();
expect(title).to.eql(expected.title);
expect(description).to.eql(expected.description);
});

View file

@ -36,7 +36,9 @@ export default function ({ getService, getPageObjects }) {
describe('invalid scripted field error', () => {
it('is rendered', async () => {
const isFetchErrorVisible = await testSubjects.exists('discoverFetchError');
const isFetchErrorVisible = await testSubjects.exists(
'discoverFetchError'
);
expect(isFetchErrorVisible).to.be(true);
});
});

View file

@ -1,21 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import expect from 'expect.js';
@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize']);
describe('discover app', function describeIndexTests() {
describe('discover tab', function describeIndexTests() {
before(async function () {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';
@ -42,52 +42,42 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
});
describe('field data', function () {
it('search php should show the correct hit count', function () {
it('search php should show the correct hit count', async function () {
const expectedHitCount = '445';
return PageObjects.discover.query('php')
.then(function () {
return retry.try(function tryingForTime() {
return PageObjects.discover.getHitCount()
.then(function compareData(hitCount) {
expect(hitCount).to.be(expectedHitCount);
});
});
});
await PageObjects.discover.query('php');
await retry.try(async function tryingForTime() {
const hitCount = await PageObjects.discover.getHitCount();
expect(hitCount).to.be(expectedHitCount);
});
});
it('the search term should be highlighted in the field data', function () {
it('the search term should be highlighted in the field data', async function () {
// marks is the style that highlights the text in yellow
return PageObjects.discover.getMarks()
.then(function (marks) {
expect(marks.length).to.be(50);
expect(marks.indexOf('php')).to.be(0);
});
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', function () {
it('search type:apache should show the correct hit count', async function () {
const expectedHitCount = '11,156';
return PageObjects.discover.query('type:apache')
.then(function () {
return retry.try(function tryingForTime() {
return PageObjects.discover.getHitCount()
.then(function compareData(hitCount) {
expect(hitCount).to.be(expectedHitCount);
});
});
});
await PageObjects.discover.query('type:apache');
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', function () {
it('doc view should show Time and _source columns', async function () {
const expectedHeader = 'Time _source';
return PageObjects.discover.getDocHeader()
.then(function (header) {
expect(header).to.be(expectedHeader);
});
const Docheader = await PageObjects.discover.getDocHeader();
expect(Docheader).to.be(expectedHeader);
});
it('doc view should sort ascending', function () {
it('doc view should sort ascending', async function () {
// Note: Could just check the timestamp, but might as well check that the whole doc is as expected.
const ExpectedDoc =
'September 20th 2015, 00:00:00.000\ntype:apache index:logstash-2015.09.20 @timestamp:September 20th 2015, 00:00:00.000'
@ -161,36 +151,24 @@ export default function ({ getService, getPageObjects }) {
+ ' 16:01:03.000 relatedContent.article:published_time:October 21st 2005, 01:10:25.000, March 5th 2006,'
+ ' 01:03:42.000, December 13th 2006, 20:12:04.000, April 4th 2008, 23:00:00.000, April 25th 2008,'
+ ' 14:26:41.000';
return PageObjects.discover.clickDocSortDown()
.then(function () {
// 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.
return PageObjects.common.sleep(2000);
})
.then(function () {
return retry.try(function tryingForTime() {
return PageObjects.discover.getDocTableIndex(1)
.then(function (rowData) {
expect(rowData).to.be(ExpectedDoc);
});
});
});
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).to.be(ExpectedDoc);
});
});
it('a bad syntax query should show an error message', function () {
it('a bad syntax query should show an error message', async function () {
const expectedError = 'Discover: Failed to parse query [xxx(yyy]';
return PageObjects.discover.query('xxx(yyy')
.then(function () {
return PageObjects.header.getToastMessage();
})
.then(function (toastMessage) {
expect(toastMessage).to.contain(expectedError);
})
.then(function () {
return PageObjects.header.clickToastOK();
});
await PageObjects.discover.query('xxx(yyy');
const toastMessage = await PageObjects.header.getToastMessage();
expect(toastMessage).to.contain(expectedError);
await PageObjects.header.clickToastOK();
});
});
});

View file

@ -23,7 +23,12 @@ export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const log = getService('log');
const retry = getService('retry');
const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover']);
const PageObjects = getPageObjects([
'common',
'home',
'settings',
'discover',
]);
describe('test large strings', function () {
before(async function () {
@ -34,16 +39,16 @@ export default function ({ getService, getPageObjects }) {
it('verify the large string book present', async function () {
const ExpectedDoc =
'mybook:Project Gutenberg EBook of Hamlet, by William Shakespeare'
+ ' This eBook is for the use of anyone anywhere in the United States'
+ ' and most other parts of the world at no cost and with almost no restrictions whatsoever.'
+ ' You may copy it, give it away or re-use it under the terms of the'
+ ' Project Gutenberg License included with this eBook or online at www.gutenberg.org.'
+ ' If you are not located in the United States,'
+ ' youll have to check the laws of the country where you are'
+ ' located before using this ebook.'
+ ' Title: Hamlet Author: William Shakespeare Release Date: November 1998 [EBook #1524]'
+ ' Last Updated: December 30, 2017 Language: English Character set encoding:';
'mybook:Project Gutenberg EBook of Hamlet, by William Shakespeare' +
' This eBook is for the use of anyone anywhere in the United States' +
' and most other parts of the world at no cost and with almost no restrictions whatsoever.' +
' You may copy it, give it away or re-use it under the terms of the' +
' Project Gutenberg License included with this eBook or online at www.gutenberg.org.' +
' If you are not located in the United States,' +
' youll have to check the laws of the country where you are' +
' located before using this ebook.' +
' Title: Hamlet Author: William Shakespeare Release Date: November 1998 [EBook #1524]' +
' Last Updated: December 30, 2017 Language: English Character set encoding:';
let rowData;
await PageObjects.common.navigateToApp('discover');
@ -76,6 +81,5 @@ export default function ({ getService, getPageObjects }) {
after(async () => {
await esArchiver.unload('hamlet');
});
});
}

View file

@ -1,21 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import expect from 'expect.js';
@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) {
describe('shared links', function describeIndexTests() {
let baseUrl;
before(function () {
before(async function () {
baseUrl = PageObjects.common.getHostPort();
log.debug('baseUrl = ' + baseUrl);
// browsers don't show the ':port' if it's 80 or 443 so we have to
@ -41,60 +41,51 @@ export default function ({ getService, getPageObjects }) {
const toTime = '2015-09-23 18:31:44.000';
// delete .kibana index and update configDoc
return kibanaServer.uiSettings.replace({
await kibanaServer.uiSettings.replace({
'dateFormat:tz': 'UTC',
'defaultIndex': 'logstash-*'
})
.then(function loadkibanaIndexPattern() {
log.debug('load kibana index with default index pattern');
return esArchiver.load('discover');
})
// and load a set of makelogs data
.then(function loadIfEmptyMakelogs() {
return esArchiver.loadIfNeeded('logstash_functional');
})
.then(function () {
log.debug('discover');
return PageObjects.common.navigateToApp('discover');
})
.then(function () {
log.debug('setAbsoluteRange');
return PageObjects.header.setAbsoluteRange(fromTime, toTime);
})
.then(function () {
//After hiding the time picker, we need to wait for
//the refresh button to hide before clicking the share button
return PageObjects.common.sleep(1000);
});
});
describe('shared link', function () {
it('should show "Share a link" caption', function () {
const expectedCaption = 'Share saved';
return PageObjects.discover.clickShare()
.then(function () {
return PageObjects.discover.getShareCaption();
})
.then(function (actualCaption) {
expect(actualCaption).to.contain(expectedCaption);
});
defaultIndex: 'logstash-*',
});
it('should show the correct formatted URL', function () {
const expectedUrl = baseUrl
+ '/app/kibana?_t=1453775307251#'
+ '/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time'
+ ':(from:\'2015-09-19T06:31:44.000Z\',mode:absolute,to:\'2015-09'
+ '-23T18:31:44.000Z\'))&_a=(columns:!(_source),index:\'logstash-'
+ '*\',interval:auto,query:(language:lucene,query:\'\')'
+ ',sort:!(\'@timestamp\',desc))';
return PageObjects.discover.getSharedUrl()
.then(function (actualUrl) {
// strip the timestamp out of each URL
expect(actualUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP'))
.to.be(expectedUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP'));
});
log.debug('load kibana index with default index pattern');
await esArchiver.load('discover');
await esArchiver.loadIfNeeded('logstash_functional');
log.debug('discover');
await PageObjects.common.navigateToApp('discover');
log.debug('setAbsoluteRange');
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
//After hiding the time picker, we need to wait for
//the refresh button to hide before clicking the share button
return PageObjects.common.sleep(1000);
});
describe('shared link', function () {
it('should show "Share a link" caption', async function () {
const expectedCaption = 'Share saved';
await PageObjects.discover.clickShare();
const actualCaption = await PageObjects.discover.getShareCaption();
expect(actualCaption).to.contain(expectedCaption);
});
it('should show the correct formatted URL', async function () {
const expectedUrl =
baseUrl +
'/app/kibana?_t=1453775307251#' +
'/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time' +
':(from:\'2015-09-19T06:31:44.000Z\',mode:absolute,to:\'2015-09' +
'-23T18:31:44.000Z\'))&_a=(columns:!(_source),index:\'logstash-' +
'*\',interval:auto,query:(language:lucene,query:\'\')' +
',sort:!(\'@timestamp\',desc))';
const actualUrl = await PageObjects.discover.getSharedUrl();
// strip the timestamp out of each URL
expect(actualUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')).to.be(
expectedUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')
);
});
it('gets copied to clipboard', async function () {
@ -103,17 +94,13 @@ export default function ({ getService, getPageObjects }) {
});
// TODO: verify clipboard contents
it('shorten URL button should produce a short URL', function () {
it('shorten URL button should produce a short URL', async function () {
const re = new RegExp(baseUrl + '/goto/[0-9a-f]{32}$');
return PageObjects.discover.clickShortenUrl()
.then(function () {
return retry.try(function tryingForTime() {
return PageObjects.discover.getSharedUrl()
.then(function (actualUrl) {
expect(actualUrl).to.match(re);
});
});
});
await PageObjects.discover.clickShortenUrl();
await retry.try(async function tryingForTime() {
const actualUrl = await PageObjects.discover.getSharedUrl();
expect(actualUrl).to.match(re);
});
});
// NOTE: This test has to run immediately after the test above

View file

@ -26,45 +26,41 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['common', 'header', 'discover']);
describe('source filters', function describeIndexTests() {
before(function () {
before(async function () {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';
// delete .kibana index and update configDoc
return kibanaServer.uiSettings.replace({
await kibanaServer.uiSettings.replace({
'dateFormat:tz': 'UTC',
'defaultIndex': 'logstash-*'
})
.then(function loadkibanaIndexPattern() {
log.debug('load kibana index with default index pattern');
return esArchiver.load('visualize_source-filters');
})
defaultIndex: 'logstash-*',
});
log.debug('load kibana index with default index pattern');
await esArchiver.load('visualize_source-filters');
// and load a set of makelogs data
.then(function loadIfEmptyMakelogs() {
return esArchiver.loadIfNeeded('logstash_functional');
})
.then(function () {
log.debug('discover');
return PageObjects.common.navigateToApp('discover');
})
.then(function () {
log.debug('setAbsoluteRange');
return PageObjects.header.setAbsoluteRange(fromTime, toTime);
})
.then(function () {
//After hiding the time picker, we need to wait for
//the refresh button to hide before clicking the share button
return PageObjects.common.sleep(1000);
});
await esArchiver.loadIfNeeded('logstash_functional');
log.debug('discover');
await PageObjects.common.navigateToApp('discover');
log.debug('setAbsoluteRange');
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
//After hiding the time picker, we need to wait for
//the refresh button to hide before clicking the share button
await PageObjects.common.sleep(1000);
});
it('should not get the field referer', function () {
return PageObjects.discover.getAllFieldNames()
.then(function (fieldNames) {
expect(fieldNames).to.not.contain('referer');
const relatedContentFields = fieldNames.filter((fieldName) => fieldName.indexOf('relatedContent') === 0);
expect(relatedContentFields).to.have.length(0);
});
it('should not get the field referer', async function () {
//let fieldNames;
const fieldNames = await PageObjects.discover.getAllFieldNames();
expect(fieldNames).to.not.contain('referer');
const relatedContentFields = fieldNames.filter(
fieldName => fieldName.indexOf('relatedContent') === 0
);
expect(relatedContentFields).to.have.length(0);
});
});
}