diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 5aabaa869789..eced6ad88137 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -93,6 +93,19 @@ define(function (require) { .catch(common.handleError(this)); }); + bdd.it('should show the correct hit count', function () { + var expectedHitCount = '14,004'; + return common.tryForTime(20 * 1000, function tryingForTime() { + return discoverPage.getHitCount() + .then(function compareData(hitCount) { + expect(hitCount).to.be(expectedHitCount); + }); + }) + .catch(common.handleError(this)); + }); + + + bdd.it('should show the correct bar chart', function () { var expectedBarChartData = [ '0', '0', '0', '0', '0', '0', '2.7056249999999977', '14.771249999999995', '54.112500000000004', diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js new file mode 100644 index 000000000000..e50f65678ca2 --- /dev/null +++ b/test/functional/apps/discover/_field_data.js @@ -0,0 +1,268 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var HeaderPage = require('../../../support/pages/HeaderPage'); + var SettingsPage = require('../../../support/pages/settings_page'); + var DiscoverPage = require('../../../support/pages/DiscoverPage'); + var expect = require('intern/dojo/node!expect.js'); + + return function (bdd, scenarioManager) { + bdd.describe('discover app', function describeIndexTests() { + var common; + var headerPage; + var settingsPage; + var discoverPage; + + bdd.before(function () { + common = new Common(this.remote); + headerPage = new HeaderPage(this.remote); + settingsPage = new SettingsPage(this.remote); + discoverPage = new DiscoverPage(this.remote); + var fromTime = '2015-09-19 06:31:44.000'; + var toTime = '2015-09-23 18:31:44.000'; + + // start each test with an empty kibana index + return scenarioManager.reload('emptyKibana') + // and load a set of makelogs data + .then(function loadIfEmptyMakelogs() { + return scenarioManager.loadIfEmpty('logstashFunctional'); + }) + .then(function (navigateTo) { + common.debug('navigateTo'); + return settingsPage.navigateTo(); + }) + .then(function () { + common.debug('createIndexPattern'); + return settingsPage.createIndexPattern(); + }) + .then(function () { + common.debug('discover'); + return common.navigateToApp('discover'); + }) + .then(function () { + common.debug('setAbsoluteRange'); + return headerPage.setAbsoluteRange(fromTime, toTime); + }) + .catch(common.handleError(this)); + }); + + + bdd.describe('field data', function () { + var queryName1 = 'Query # 1'; + var fromTimeString = 'September 19th 2015, 06:31:44.000'; + var toTimeString = 'September 23rd 2015, 18:31:44.000'; + + + bdd.it('search php should show the correct hit count', function () { + var expectedHitCount = '445'; + return discoverPage.query('php') + .then(function () { + return common.tryForTime(20 * 1000, function tryingForTime() { + return discoverPage.getHitCount() + .then(function compareData(hitCount) { + expect(hitCount).to.be(expectedHitCount); + }); + }); + }) + .catch(common.handleError(this)); + }); + + bdd.it('the search term should be highlighted in the field data', function () { + // marks is the style that highlights the text in yellow + return discoverPage.getMarks() + .then(function (marks) { + expect(marks.length).to.be(50); + expect(marks.indexOf('php')).to.be(0); + }) + .catch(common.handleError(this)); + }); + + + bdd.it('search _type:apache should show the correct hit count', function () { + var expectedHitCount = '11,156'; + return discoverPage.query('_type:apache') + .then(function () { + return common.tryForTime(20 * 1000, function tryingForTime() { + return discoverPage.getHitCount() + .then(function compareData(hitCount) { + expect(hitCount).to.be(expectedHitCount); + }); + }); + }) + .catch(common.handleError(this)); + }); + + bdd.it('doc view should show Time and _source columns', function () { + var expectedHeader = 'Time _source'; + return discoverPage.getDocHeader() + .then(function (header) { + expect(header).to.be(expectedHeader); + }) + .catch(common.handleError(this)); + }); + + bdd.it('doc view should show oldest time first', function () { + // Note: Could just check the timestamp, but might as well check that the whole doc is as expected. + var ExpectedDoc = + 'September 22nd 2015, 23:50:13.253 index:logstash-2015.09.22 @timestamp:September 22nd 2015, 23:50:13.253' + + ' ip:238.171.34.42 extension:jpg response:200 geo.coordinates:{ "lat": 38.66494528, "lon": -88.45299556' + + ' } geo.src:FR geo.dest:KH geo.srcdest:FR:KH @tags:success, info utc_time:September 22nd 2015,' + + ' 23:50:13.253 referer:http://twitter.com/success/nancy-currie agent:Mozilla/4.0 (compatible; MSIE 6.0;' + + ' Windows NT 5.1; SV1; .NET CLR 1.1.4322) clientip:238.171.34.42 bytes:7,124' + + ' host:media-for-the-masses.theacademyofperformingartsandscience.org request:/uploads/karl-henize.jpg' + + ' url:https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/karl-henize.jpg' + + ' @message:238.171.34.42 - - [2015-09-22T23:50:13.253Z] "GET /uploads/karl-henize.jpg HTTP/1.1" 200 7124' + + ' "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" spaces:this is a' + + ' thing with lots of spaces wwwwoooooo xss:' + + ' headings:

alexander-viktorenko

, http://nytimes.com/warning/michael-massimino' + + ' links:@www.slate.com, http://www.slate.com/security/frederick-w-leslie, www.www.slate.com' + + ' relatedContent:{ "url": "http://www.laweekly.com/music/bjork-at-the-nokia-theatre-12-12-2408191",' + + ' "og:type": "article", "og:title": "Bjork at the Nokia Theatre, 12/12", "og:description": "Bjork at the' + + ' Nokia Theater, December 12 By Randall Roberts Last night’s Bjork show at the Dystopia –' + + ' er, I mean Nokia -- Theatre downtown di...", "og:url": "' + + 'http://www.laweekly.com/music/bjork-at-the-nokia-theatre-12-12-2408191", "article:published_time":' + + ' "2007-12-13T12:19:35-08:00", "article:modified_time": "2014-11-27T08:28:42-08:00", "article:section":' + + ' "Music", "og:image": "' + + 'http://IMAGES1.laweekly.com/imager/bjork-at-the-nokia-theatre-12-12/u/original/2470701/bjorktn003.jpg",' + + ' "og:image:height": "334", "og:image:width": "480", "og:site_name": "LA Weekly", "twitter:title":' + + ' "Bjork at the Nokia Theatre, 12/12", "twitter:description": "Bjork at the Nokia Theater, December 12' + + ' By Randall Roberts Last night’s Bjork show at the Dystopia – er, I mean Nokia -- Theatre' + + ' downtown di...", "twitter:card": "summary", "twitter:image": "' + + 'http://IMAGES1.laweekly.com/imager/bjork-at-the-nokia-theatre-12-12/u/original/2470701/bjorktn003.jpg",' + + ' "twitter:site": "@laweekly" }, { "url": "' + + 'http://www.laweekly.com/music/the-rapture-at-the-mayan-7-25-2401011", "og:type": "article", "og:title":' + + ' "The Rapture at the Mayan, 7/25", "og:description": "If you haven’t yet experienced the' + + ' phenomenon of people walk-dancing, apparently the best place to witness this is at a Rapture show.' + + ' Here’s...", "og:url": "http://www.laweekly.com/music/the-rapture-at-the-mayan-7-25-2401011",' + + ' "article:published_time": "2007-07-26T12:42:30-07:00", "article:modified_time":' + + ' "2014-11-27T08:00:51-08:00", "article:section": "Music", "og:image": "' + + 'http://IMAGES1.laweekly.com/imager/the-rapture-at-the-mayan-7-25/u/original/2463272/rapturetn05.jpg",' + + ' "og:image:height": "321", "og:image:width": "480", "og:site_name": "LA Weekly", "twitter:title": "The' + + ' Rapture at the Mayan, 7/25", "twitter:description": "If you haven’t yet experienced the' + + ' phenomenon of people walk-dancing, apparently the best place to witness this is at a Rapture show.' + + ' Here’s...", "twitter:card": "summary", "twitter:image": "' + + 'http://IMAGES1.laweekly.com/imager/the-rapture-at-the-mayan-7-25/u/original/2463272/rapturetn05.jpg",' + + ' "twitter:site": "@laweekly" } machine.os:win 7 machine.ram:7,516,192,768 _id:AU_x3_g4GFA8no6QjkYX' + + ' _type:apache _index:logstash-2015.09.22 _score: relatedContent.article:modified_time:November 27th' + + ' 2014, 16:00:51.000, November 27th 2014, 16:28:42.000 relatedContent.article:published_time:July 26th' + + ' 2007, 19:42:30.000, December 13th 2007, 20:19:35.000'; + return discoverPage.getDocTableIndex(1) + .then(function (rowData) { + expect(rowData).to.be(ExpectedDoc); + }) + .catch(common.handleError(this)); + }); + + bdd.it('doc view should sort ascending', function () { + // Note: Could just check the timestamp, but might as well check that the whole doc is as expected. + var ExpectedDoc = + 'September 20th 2015, 00:00:00.000 index:logstash-2015.09.20 @timestamp:September 20th 2015, 00:00:00.000' + + ' ip:143.84.142.7 extension:jpg response:200 geo.coordinates:{ "lat": 38.68407028, "lon": -120.9871642 }' + + ' geo.src:ES geo.dest:US geo.srcdest:ES:US @tags:error, info utc_time:September 20th 2015, 00:00:00.000' + + ' referer:http://www.slate.com/success/vladimir-kovalyonok agent:Mozilla/4.0 (compatible; MSIE 6.0;' + + ' Windows NT 5.1; SV1; .NET CLR 1.1.4322) clientip:143.84.142.7 bytes:1,623' + + ' host:media-for-the-masses.theacademyofperformingartsandscience.org request:/uploads/steven-hawley.jpg' + + ' url:https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/steven-hawley.jpg' + + ' @message:143.84.142.7 - - [2015-09-20T00:00:00.000Z] "GET /uploads/steven-hawley.jpg HTTP/1.1" 200' + + ' 1623 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" spaces:this is a' + + ' thing with lots of spaces wwwwoooooo xss:' + + ' headings:

kimiya-yui

, http://www.slate.com/success/koichi-wakata' + + ' links:thomas-marshburn@twitter.com, http://www.slate.com/info/michael-p-anderson, www.twitter.com' + + ' relatedContent:{ "url":' + + ' "http://www.laweekly.com/music/jay-electronica-much-better-than-his-name-would-suggest-2412364",' + + ' "og:type": "article", "og:title": "Jay Electronica: Much Better Than His Name Would Suggest",' + + ' "og:description": "You may not know who Jay Electronica is yet, but I'm willing to bet that you' + + ' would had he chosen a better name. Jay Electronica does not sound like the ...", "og:url":' + + ' "http://www.laweekly.com/music/jay-electronica-much-better-than-his-name-would-suggest-2412364",' + + ' "article:published_time": "2008-04-04T16:00:00-07:00", "article:modified_time":' + + ' "2014-11-27T08:01:03-08:00", "article:section": "Music", "og:site_name": "LA Weekly", "twitter:title":' + + ' "Jay Electronica: Much Better Than His Name Would Suggest", "twitter:description": "You may not know' + + ' who Jay Electronica is yet, but I'm willing to bet that you would had he chosen a better name.' + + ' Jay Electronica does not sound like the ...", "twitter:card": "summary", "twitter:site": "@laweekly"' + + ' }, { "url": "http://www.laweekly.com/news/mandoe-on-gower-near-fountain-2368123", "og:type":' + + ' "article", "og:title": "MANDOE On Gower Near Fountain", "og:description": "MANDOE has a stunner on a' + + ' wall north of an east-west street crossing Gower around Fountain (but not on Fountain). MADNOE, PROSE' + + ' and FUKM are listed on t...", "og:url": "' + + 'http://www.laweekly.com/news/mandoe-on-gower-near-fountain-2368123", "article:published_time":' + + ' "2008-04-25T07:26:41-07:00", "article:modified_time": "2014-10-28T15:00:08-07:00", "article:section":' + + ' "News", "og:image": "' + + 'http://images1.laweekly.com/imager/mandoe-on-gower-near-fountain/u/original/2430891/img_6648.jpg",' + + ' "og:image:height": "640", "og:image:width": "480", "og:site_name": "LA Weekly", "twitter:title": ' + + '"MANDOE On Gower Near Fountain", "twitter:description": "MANDOE has a stunner on a wall north of an' + + ' east-west street crossing Gower around Fountain (but not on Fountain). MADNOE, PROSE and FUKM are' + + ' listed on t...", "twitter:card": "summary", "twitter:image": "' + + 'http://images1.laweekly.com/imager/mandoe-on-gower-near-fountain/u/original/2430891/img_6648.jpg", ' + + '"twitter:site": "@laweekly" }, { "url": "http://www.laweekly.com/arts/meghan-finds-the-love-2373346",' + + ' "og:type": "article", "og:title": "Meghan Finds The Love", "og:description": "LA Weekly is the' + + ' definitive source of information for news, music, movies, restaurants, reviews, and events in Los' + + ' Angeles.", "og:url": "http://www.laweekly.com/arts/meghan-finds-the-love-2373346",' + + ' "article:published_time": "2005-10-20T18:10:25-07:00", "article:modified_time":' + + ' "2014-11-25T19:52:35-08:00", "article:section": "Arts", "og:site_name": "LA Weekly", "twitter:title":' + + ' "Meghan Finds The Love", "twitter:description": "LA Weekly is the definitive source of information for' + + ' news, music, movies, restaurants, reviews, and events in Los Angeles.", "twitter:card": "summary",' + + ' "twitter:site": "@laweekly" }, { "url": "http://www.laweekly.com/arts/these-clowns-are-with-me-2371051' + + '", "og:type": "article", "og:title": "These Clowns Are With Me", "og:description": "    I' + + ' didn't mean to blow off all my responsibilities yesterday, but when a schmoozy Hollywood luncheon' + + ' turns into a full-on party by 3pm, and...", "og:url": "' + + 'http://www.laweekly.com/arts/these-clowns-are-with-me-2371051", "article:published_time": ' + + '"2006-03-04T17:03:42-08:00", "article:modified_time": "2014-11-25T17:05:47-08:00", "article:section":' + + ' "Arts", "og:image": "' + + 'http://images1.laweekly.com/imager/these-clowns-are-with-me/u/original/2434556/e4b8scd.jpg",' + + ' "og:image:height": "375", "og:image:width": "500", "og:site_name": "LA Weekly", "twitter:title":' + + ' "These Clowns Are With Me", "twitter:description": "    I didn't mean to blow off all' + + ' my responsibilities yesterday, but when a schmoozy Hollywood luncheon turns into a full-on party by' + + ' 3pm, and...", "twitter:card": "summary", "twitter:image": "' + + 'http://images1.laweekly.com/imager/these-clowns-are-with-me/u/original/2434556/e4b8scd.jpg",' + + ' "twitter:site": "@laweekly" }, { "url": "http://www.laweekly.com/arts/shopping-daze-2373807",' + + ' "og:type": "article", "og:title": "Shopping Daze", "og:description": "LA Weekly is the definitive ' + + 'source of information for news, music, movies, restaurants, reviews, and events in Los Angeles.",' + + ' "og:url": "http://www.laweekly.com/arts/shopping-daze-2373807", "article:published_time":' + + ' "2006-12-13T12:12:04-08:00", "article:modified_time": "2014-11-25T20:15:21-08:00", "article:section":' + + ' "Arts", "og:site_name": "LA Weekly", "twitter:title": "Shopping Daze", "twitter:description": "LA' + + ' Weekly is the definitive source of information for news, music, movies, restaurants, reviews, and' + + ' events in Los Angeles.", "twitter:card": "summary", "twitter:site": "@laweekly" } machine.os:osx' + + ' machine.ram:15,032,385,536 _id:AU_x3_g3GFA8no6QjkFm _type:apache _index:logstash-2015.09.20 _score:' + + ' relatedContent.article:modified_time:October 28th 2014, 22:00:08.000, November 26th 2014,' + + ' 01:05:47.000, November 26th 2014, 03:52:35.000, November 26th 2014, 04:15:21.000, November 27th 2014,' + + ' 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 discoverPage.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 common.sleep(2000); + }) + .then(function () { + return common.tryForTime(20 * 1000, function tryingForTime() { + return discoverPage.getDocTableIndex(1) + .then(function (rowData) { + expect(rowData).to.be(ExpectedDoc); + }); + }); + }) + .catch(common.handleError(this)); + }); + + + bdd.it('a bad syntax query should show an error message', function () { + var expectedHitCount = '1011,156'; + var expectedError = 'Discover: Failed to parse query [xxx(yyy]'; + return discoverPage.query('xxx(yyy') + .then(function () { + return headerPage.getToastMessage(); + }) + .then(function (toastMessage) { + expect(toastMessage).to.be(expectedError); + }) + .then(function () { + return headerPage.clickToastOK(); + }) + .catch(common.handleError(this)); + }); + + + }); + }); + }; +}); diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index c2677dd248a3..eef3af445e9a 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -4,6 +4,7 @@ define(function (require) { var url = require('intern/dojo/node!url'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); var discoverTest = require('./_discover'); + var fieldData = require('./_field_data'); bdd.describe('discover app', function () { var scenarioManager; @@ -22,5 +23,7 @@ define(function (require) { discoverTest(bdd, scenarioManager); + fieldData(bdd, scenarioManager); + }); }); diff --git a/test/support/pages/DiscoverPage.js b/test/support/pages/DiscoverPage.js index 91c643d4be5f..cbaa0073f43a 100644 --- a/test/support/pages/DiscoverPage.js +++ b/test/support/pages/DiscoverPage.js @@ -127,8 +127,55 @@ define(function (require) { .findByCssSelector('option[label="' + interval + '"]') .click(); }); - } + }, + getHitCount: function getHitCount() { + return thisTime + .findByCssSelector('strong.discover-info-hits') + .getVisibleText(); + }, + + query: function query(queryString) { + return thisTime + .findByCssSelector('input[aria-label="Search input"]') + .clearValue() + .type(queryString) + .then(function () { + return thisTime + .findByCssSelector('button[aria-label="Search"]') + .click(); + }); + }, + + getDocHeader: function getDocHeader() { + return thisTime + .findByCssSelector('thead.ng-isolate-scope > tr:nth-child(1)') + .getVisibleText(); + }, + + getDocTableIndex: function getDocTableIndex(index) { + return thisTime + .findByCssSelector('tr.discover-table-row:nth-child(' + (index) + ')') + .getVisibleText(); + }, + + clickDocSortDown: function clickDocSortDown() { + return thisTime + .findByCssSelector('.fa-sort-down') + .click(); + }, + + clickDocSortUp: function clickDocSortUp() { + return thisTime + .findByCssSelector('.fa-sort-up') + .click(); + }, + + getMarks: function getMarks() { + return thisTime + .findAllByCssSelector('mark') + .getVisibleText(); + } }; diff --git a/test/support/pages/HeaderPage.js b/test/support/pages/HeaderPage.js index c1e8767baf56..5a78ebb7736e 100644 --- a/test/support/pages/HeaderPage.js +++ b/test/support/pages/HeaderPage.js @@ -137,6 +137,13 @@ define(function (require) { }); }, + clickToastOK: function clickToastOK() { + return this.remote + .setFindTimeout(defaultTimeout) + .findByCssSelector('button[ng-if="notif.accept"]') + .click(); + }, + getSpinnerDone: function getSpinnerDone() { var self = this; return this.remote