From b531c15f9f0140768652a089777edba978737e2a Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Wed, 3 Feb 2016 16:04:05 -0700 Subject: [PATCH 01/19] add tests immediate fire on register --- src/server/status/__tests__/Status.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/server/status/__tests__/Status.js b/src/server/status/__tests__/Status.js index 8563500a34af..2068e7519375 100644 --- a/src/server/status/__tests__/Status.js +++ b/src/server/status/__tests__/Status.js @@ -59,6 +59,18 @@ describe('Status class', function () { expect(json.message).to.eql('Ready'); }); + it('should call handler if status is already matched', function (done) { + var status = serverStatus.create('test'); + var msg = 'Test Ready'; + status.green(msg); + + status.on('green', function () { + expect(arguments.length).to.equal(0); + expect(status.message).to.equal(msg); + done(); + }); + }); + function testState(color) { it(`should change the state to ${color} when #${color}() is called`, function () { var status = serverStatus.create('test'); From bc7183ad0c77ebf9366648c43a96149f6b4fd6b9 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Wed, 3 Feb 2016 16:04:30 -0700 Subject: [PATCH 02/19] make tests pass --- src/server/status/Status.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/server/status/Status.js b/src/server/status/Status.js index 430d44d0a114..bf9f10d6ca2b 100644 --- a/src/server/status/Status.js +++ b/src/server/status/Status.js @@ -36,6 +36,14 @@ class Status extends EventEmitter { since: this.since }; } + + on(eventName, handler) { + super.on(eventName, handler); + + if (eventName === this.state) { + setImmediate(handler); + } + } } states.all.forEach(function (state) { From 582937871a081e37e941a8f580ce352d95ea8879 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Wed, 3 Feb 2016 16:19:51 -0700 Subject: [PATCH 03/19] add once handler as well --- src/server/status/Status.js | 8 ++++++++ src/server/status/__tests__/Status.js | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/server/status/Status.js b/src/server/status/Status.js index bf9f10d6ca2b..9e11cf6bc190 100644 --- a/src/server/status/Status.js +++ b/src/server/status/Status.js @@ -44,6 +44,14 @@ class Status extends EventEmitter { setImmediate(handler); } } + + once(eventName, handler) { + if (eventName === this.state) { + setImmediate(handler); + } else { + super.once(eventName, handler); + } + } } states.all.forEach(function (state) { diff --git a/src/server/status/__tests__/Status.js b/src/server/status/__tests__/Status.js index 2068e7519375..727befb31389 100644 --- a/src/server/status/__tests__/Status.js +++ b/src/server/status/__tests__/Status.js @@ -59,7 +59,7 @@ describe('Status class', function () { expect(json.message).to.eql('Ready'); }); - it('should call handler if status is already matched', function (done) { + it('should call on handler if status is already matched', function (done) { var status = serverStatus.create('test'); var msg = 'Test Ready'; status.green(msg); @@ -71,6 +71,18 @@ describe('Status class', function () { }); }); + it('should call once handler if status is already matched', function (done) { + var status = serverStatus.create('test'); + var msg = 'Test Ready'; + status.green(msg); + + status.once('green', function () { + expect(arguments.length).to.equal(0); + expect(status.message).to.equal(msg); + done(); + }); + }); + function testState(color) { it(`should change the state to ${color} when #${color}() is called`, function () { var status = serverStatus.create('test'); From 14061b814e7cb7e5c97379b71c4b5eace534f069 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 8 Mar 2016 08:53:57 -0700 Subject: [PATCH 04/19] Update error timeout and test --- src/ui/public/notify/__tests__/notifier.js | 4 ++-- src/ui/public/notify/notifier.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/public/notify/__tests__/notifier.js b/src/ui/public/notify/__tests__/notifier.js index a7febe7c5b93..60630b5df951 100644 --- a/src/ui/public/notify/__tests__/notifier.js +++ b/src/ui/public/notify/__tests__/notifier.js @@ -43,8 +43,8 @@ describe('Notifier', function () { expect(notify('error').title).to.equal('Error'); }); - it('sets lifetime to Infinity', function () { - expect(notify('error').lifetime).to.equal(Infinity); + it('sets lifetime to 5 minutes', function () { + expect(notify('error').lifetime).to.equal(300000); }); it('allows reporting', function () { diff --git a/src/ui/public/notify/notifier.js b/src/ui/public/notify/notifier.js index 332961e94e41..e2ff33b3901e 100644 --- a/src/ui/public/notify/notifier.js +++ b/src/ui/public/notify/notifier.js @@ -229,7 +229,7 @@ Notifier.prototype.error = function (err, cb) { content: formatMsg(err, this.from), icon: 'warning', title: 'Error', - lifetime: Infinity, + lifetime: 300000, actions: ['report', 'accept'], stack: formatStack(err) }, cb); From fe0ced0f735db96a1d17ca3e8b75a00fb59a0ab1 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 11 Mar 2016 14:16:15 -0800 Subject: [PATCH 05/19] Closes #6516. Fixes issue with query string not being added to base path. --- src/ui/public/chrome/api/nav.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/public/chrome/api/nav.js b/src/ui/public/chrome/api/nav.js index 297df1543be3..0b630a2eccd1 100644 --- a/src/ui/public/chrome/api/nav.js +++ b/src/ui/public/chrome/api/nav.js @@ -18,7 +18,7 @@ export default function (chrome, internals) { var isUrl = url && isString(url); if (!isUrl) return url; - var parsed = parse(url); + var parsed = parse(url, true); if (!parsed.host && parsed.pathname) { if (parsed.pathname[0] === '/') { parsed.pathname = chrome.getBasePath() + parsed.pathname; From c7d2f89cbcbc3e2150a5efc834c05958dc9333bd Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 11 Mar 2016 16:01:49 -0700 Subject: [PATCH 06/19] [cli/serve] expand dot-notated keys in yaml arrays --- src/cli/serve/read_yaml_config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli/serve/read_yaml_config.js b/src/cli/serve/read_yaml_config.js index 0c28635eddc7..d5d4c2800af0 100644 --- a/src/cli/serve/read_yaml_config.js +++ b/src/cli/serve/read_yaml_config.js @@ -48,7 +48,14 @@ module.exports = function (path) { _.forOwn(val, function (subVal, subKey) { apply(config, subVal, key + '.' + subKey); }); - } else { + } + else if (_.isArray(val)) { + config[key] = []; + val.forEach((subVal, i) => { + apply(config, subVal, key + '.' + i); + }); + } + else { _.set(config, key, val); } } From 89aff0210ff00bd24e0c915cecb98c5104ff43d7 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 14 Mar 2016 14:40:53 -0500 Subject: [PATCH 07/19] Changes to methods for getting more specific chart data to cover integration testing. --- test/functional/apps/visualize/_area_chart.js | 2 +- test/functional/apps/visualize/_line_chart.js | 2 +- test/support/pages/visualize_page.js | 124 ++++++++++++------ 3 files changed, 84 insertions(+), 44 deletions(-) diff --git a/test/functional/apps/visualize/_area_chart.js b/test/functional/apps/visualize/_area_chart.js index a456dfec3ed7..4770acd3d726 100644 --- a/test/functional/apps/visualize/_area_chart.js +++ b/test/functional/apps/visualize/_area_chart.js @@ -150,7 +150,7 @@ define(function (require) { expect(labels).to.eql(yAxisLabels); }) .then(function getAreaChartData() { - return visualizePage.getAreaChartData(); + return visualizePage.getAreaChartData('count'); }) .then(function (paths) { common.debug('expectedAreaChartData = ' + expectedAreaChartData); diff --git a/test/functional/apps/visualize/_line_chart.js b/test/functional/apps/visualize/_line_chart.js index 539758e69bb6..823a34acc51f 100644 --- a/test/functional/apps/visualize/_line_chart.js +++ b/test/functional/apps/visualize/_line_chart.js @@ -122,7 +122,7 @@ define(function (require) { // sleep a bit before trying to get the chart data return common.sleep(3000) .then(function () { - return visualizePage.getLineChartData() + return visualizePage.getLineChartData('fill="#57c17b"') .then(function showData(data) { var tolerance = 10; // the y-axis scale is 10000 so 10 is 0.1% for (var x = 0; x < data.length; x++) { diff --git a/test/support/pages/visualize_page.js b/test/support/pages/visualize_page.js index 2ac4fbb2484d..b7cea331c958 100644 --- a/test/support/pages/visualize_page.js +++ b/test/support/pages/visualize_page.js @@ -327,22 +327,71 @@ define(function (require) { }); }, - // saved visualizations are paginated 5 to a page! - loadSavedVisualization: function loadSavedVisualization(vizName) { - var self = this; + + clickLoadSavedVisButton: function clickLoadSavedVisButton() { return this.remote .setFindTimeout(defaultTimeout) .findByCssSelector('button.ng-scope[aria-label="Load Saved Visualization"]') - .click() - .then(function findVizByLinkedText() { - common.debug('Load Saved Vis button clicked'); + .click(); + }, + + filterVisByName: function filterVisByName(vizName) { + var self = this; + return this.remote + .findByCssSelector('input[name="filter"]') + .then(function (filter) { + return self.remote.moveMouseTo(filter); + }) + .then (function () { + return self.remote + .findByCssSelector('input[name="filter"]') + .click() + .type(vizName.replace('-',' ')); + }) + .then (function () { + common.sleep(3000); + }); + }, + + clickVisualizationByLinkText: function clickVisualizationByLinkText(vizName) { + var self = this; + common.debug('clickVisualizationByLinkText(' + vizName + ')'); + return this.remote + .setFindTimeout(defaultTimeout) + .findByLinkText(vizName) + .then(function (link) { + return self.remote.moveMouseTo(link); + }) + .then (function () { return self.remote - .setFindTimeout(defaultTimeout) .findByLinkText(vizName) .click(); }); }, + // this starts by clicking the Load Saved Viz button, not from the + // bottom half of the "Create a new visualization Step 1" page + loadSavedVisualization: function loadSavedVisualization(vizName) { + var self = this; + return this.clickLoadSavedVisButton() + .then(function filterVisualization() { + return self.filterVisByName(vizName); + }) + .then(function clickDashboardByLinkedText() { + return self.clickVisualizationByLinkText(vizName); + }); + }, + + // this starts on the + // bottom half of the "Create a new visualization Step 1" page + openSavedVisualization: function openSavedVisualization(vizName) { + var self = this; + return self.filterVisByName(vizName) + .then(function clickDashboardByLinkedText() { + return self.clickVisualizationByLinkText(vizName); + }); + }, + getXAxisLabels: function getXAxisLabels() { return this.remote .setFindTimeout(defaultTimeout) @@ -385,7 +434,7 @@ define(function (require) { ** This method gets the chart data and scales it based on chart height and label. ** Returns an array of height values */ - getAreaChartData: function getAreaChartData() { + getAreaChartData: function getAreaChartData(aggregateName) { var self = this.remote; var chartData = []; @@ -404,7 +453,7 @@ define(function (require) { return y.getVisibleText(); }) .then(function (yLabel) { - yAxisLabel = yLabel.replace(',', ''); + yAxisLabel = yLabel.replace(',', '').replace('%',''); common.debug('yAxisLabel = ' + yAxisLabel); return yLabel; }) @@ -423,43 +472,27 @@ define(function (require) { }) .then(function () { return self.setFindTimeout(defaultTimeout * 2) - .findAllByCssSelector('path') - .then(function (chartTypes) { - - function getChartType(chart) { - return chart - .getAttribute('data-label') - .then(function (chartString) { - //common.debug('data-label = ' + chartString); - if (chartString === 'Count') { - return chart.getAttribute('d') - .then(function (data) { - common.debug(data); - tempArray = data.split('L'); - chartSections = tempArray.length / 2; - common.debug('chartSections = ' + chartSections + ' height = ' + yAxisHeight + ' yAxisLabel = ' + yAxisLabel); - chartData[0] = Math.round((yAxisHeight - tempArray[0].split(',')[1]) / yAxisHeight * yAxisLabel); - common.debug('chartData[0] =' + chartData[0]); - for (var i = 1; i < chartSections; i++) { - chartData[i] = Math.round((yAxisHeight - tempArray[i].split(',')[1]) / yAxisHeight * yAxisLabel); - common.debug('chartData[i] =' + chartData[i]); - } - return chartData; - }); - } - }); - } - var getChartTypesPromises = chartTypes.map(getChartType); - return Promise.all(getChartTypesPromises); - }); + .findByCssSelector('path[data-label="' + aggregateName + '"]'); }) - .then(function (chartData) { - return chartData[1]; // MAGIC NUMBER - we find multiple 'path's and only one of them is the right one. + .then(function (chart) { + return chart.getAttribute('d'); + }) + .then(function (data) { + common.debug(data); + tempArray = data.replace('M','').split('L'); + chartSections = tempArray.length / 2; + common.debug('chartSections = ' + chartSections + ' height = ' + yAxisHeight + ' yAxisLabel = ' + yAxisLabel); + for (var i = 0; i < chartSections; i++) { + chartData[i] = Math.round((yAxisHeight - tempArray[i].split(',')[1]) / yAxisHeight * yAxisLabel); + common.debug('chartData[i] =' + chartData[i]); + } + return chartData; }); }, + // The current test shows dots, not a line. This function gets the dots and normalizes their height. - getLineChartData: function getLineChartData() { + getLineChartData: function getLineChartData(cssPart) { var self = this.remote; var yAxisLabel = 0; var yAxisHeight; @@ -502,7 +535,7 @@ define(function (require) { // 5). for each chart element, find the green circle, then the cy position function getChartType(chart) { return chart - .findByCssSelector('circle[fill="#57c17b"]') + .findByCssSelector('circle[' + cssPart + ']') .then(function (circleObject) { // common.debug('circleObject = ' + circleObject + ' yAxisHeight= ' + yAxisHeight + ' yAxisLabel= ' + yAxisLabel); return circleObject @@ -636,6 +669,13 @@ define(function (require) { .getVisibleText(); }, + getMarkdownData: function getMarkdownData() { + return this.remote + .setFindTimeout(defaultTimeout) + .findByCssSelector('visualize.ng-isolate-scope') + .getVisibleText(); + }, + clickColumns: function clickColumns() { return this.remote .setFindTimeout(defaultTimeout) From e1168c52194536405568576aba59b5a777bb3399 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 14 Mar 2016 15:23:49 -0700 Subject: [PATCH 08/19] match arguments of state emit --- src/server/status/Status.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/status/Status.js b/src/server/status/Status.js index 9e11cf6bc190..2ae32749b958 100644 --- a/src/server/status/Status.js +++ b/src/server/status/Status.js @@ -41,13 +41,13 @@ class Status extends EventEmitter { super.on(eventName, handler); if (eventName === this.state) { - setImmediate(handler); + setImmediate(() => handler(this.state, this.message)); } } once(eventName, handler) { if (eventName === this.state) { - setImmediate(handler); + setImmediate(() => handler(this.state, this.message)); } else { super.once(eventName, handler); } From 8b3416e269ad7d997f126ec30821a147e3074f2b Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 14 Mar 2016 15:24:16 -0700 Subject: [PATCH 09/19] update tests, check for listener arguments --- src/server/status/__tests__/Status.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/server/status/__tests__/Status.js b/src/server/status/__tests__/Status.js index 727befb31389..080cfb41163d 100644 --- a/src/server/status/__tests__/Status.js +++ b/src/server/status/__tests__/Status.js @@ -4,7 +4,6 @@ var Status = require('../Status'); var ServerStatus = require('../ServerStatus'); describe('Status class', function () { - var server; var serverStatus; @@ -64,8 +63,10 @@ describe('Status class', function () { var msg = 'Test Ready'; status.green(msg); - status.on('green', function () { - expect(arguments.length).to.equal(0); + status.on('green', function (prev, prevMsg) { + expect(arguments.length).to.equal(2); + expect(prev).to.be('green'); + expect(prevMsg).to.be(msg); expect(status.message).to.equal(msg); done(); }); @@ -76,8 +77,10 @@ describe('Status class', function () { var msg = 'Test Ready'; status.green(msg); - status.once('green', function () { - expect(arguments.length).to.equal(0); + status.once('green', function (prev, prevMsg) { + expect(arguments.length).to.equal(2); + expect(prev).to.be('green'); + expect(prevMsg).to.be(msg); expect(status.message).to.equal(msg); done(); }); From aeecf17b552da91ba93e0ae633c3bb0289e938ae Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Tue, 15 Mar 2016 13:43:51 -0300 Subject: [PATCH 10/19] [ui/toast] Added a "Less Info" button to toast messages. Fixes #5190 --- src/ui/public/notify/partials/toaster.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/public/notify/partials/toaster.html b/src/ui/public/notify/partials/toaster.html index 52a2e83a067d..b1679f1082a2 100644 --- a/src/ui/public/notify/partials/toaster.html +++ b/src/ui/public/notify/partials/toaster.html @@ -16,6 +16,13 @@ ng-class="'btn-' + notif.type" ng-click="notif.showStack = true" >More Info +