Merge branch 'feature/ingest' into filebeatWizard

This commit is contained in:
Matthew Bargar 2016-02-02 13:51:24 -05:00
commit 770b51adb7
52 changed files with 556 additions and 132 deletions

View file

@ -96,8 +96,8 @@ enabled=1
yum install kibana yum install kibana
-------------------------------------------------- --------------------------------------------------
+ +
Configure Kibana to automatically start during bootup. If your distribution is using the System V version of `init`, Configure Kibana to automatically start during bootup. If your distribution is using the System V version of `init`
run the following command: (check with `ps -p 1`), run the following command:
+ +
[source,sh] [source,sh]
-------------------------------------------------- --------------------------------------------------

View file

@ -56,8 +56,8 @@
"elasticsearchWithPlugins": "grunt esvm:withPlugins:keepalive", "elasticsearchWithPlugins": "grunt esvm:withPlugins:keepalive",
"lint": "grunt eslint:source", "lint": "grunt eslint:source",
"lintroller": "grunt eslint:fixSource", "lintroller": "grunt eslint:fixSource",
"mocha": "mocha --compilers js:babel/register", "mocha": "mocha",
"mocha:debug": "mocha --debug-brk --compilers js:babel/register" "mocha:debug": "mocha --debug-brk"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -142,7 +142,7 @@
"Nonsense": "0.1.2", "Nonsense": "0.1.2",
"angular-mocks": "1.4.7", "angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3", "auto-release-sinon": "1.0.3",
"babel-eslint": "4.1.3", "babel-eslint": "4.1.7",
"chokidar": "1.0.5", "chokidar": "1.0.5",
"eslint": "1.5.1", "eslint": "1.5.1",
"eslint-plugin-mocha": "1.0.0", "eslint-plugin-mocha": "1.0.0",

View file

@ -2,15 +2,21 @@ const _ = require('lodash');
const Promise = require('bluebird'); const Promise = require('bluebird');
const Boom = require('boom'); const Boom = require('boom');
const getBasicAuthRealm = require('./get_basic_auth_realm'); const getBasicAuthRealm = require('./get_basic_auth_realm');
const toPath = require('lodash/internal/toPath');
module.exports = (client) => { module.exports = (client) => {
return (req, endpoint, params = {}) => { return (req, endpoint, params = {}) => {
if (req.headers.authorization) { if (req.headers.authorization) {
_.set(params, 'headers.authorization', req.headers.authorization); _.set(params, 'headers.authorization', req.headers.authorization);
} }
const api = _.get(client, endpoint); const path = toPath(endpoint);
const api = _.get(client, path);
let apiContext = _.get(client, path.slice(0, -1));
if (_.isEmpty(apiContext)) {
apiContext = client;
}
if (!api) throw new Error(`callWithRequest called with an invalid endpoint: ${endpoint}`); if (!api) throw new Error(`callWithRequest called with an invalid endpoint: ${endpoint}`);
return api.call(client, params) return api.call(apiContext, params)
.catch((err) => { .catch((err) => {
if (err.status === 401) { if (err.status === 401) {
// TODO: The err.message is temporary until we have support for getting headers in the client. // TODO: The err.message is temporary until we have support for getting headers in the client.

View file

@ -60,11 +60,11 @@ define(function (require) {
}; };
$scope.toggleDisplay = function (field) { $scope.toggleDisplay = function (field) {
// inheritted param to fieldChooser // This is inherited from fieldChooser
$scope.toggle(field.name); $scope.toggle(field.name);
if (field.display) $scope.increaseFieldCounter(field); if (field.display) $scope.increaseFieldCounter(field);
// we are now displaying the field, kill it's details // we are now displaying the field, kill its details
if (field.details) { if (field.details) {
$scope.toggleDetails(field); $scope.toggleDetails(field);
} }

View file

@ -16,7 +16,7 @@
<!-- Settings editors --> <!-- Settings editors -->
<form <form
name="forms.configEdit" name="forms.configEdit"
ng-if="conf.editting" ng-if="conf.editing"
ng-submit="save(conf)" ng-submit="save(conf)"
role="form"> role="form">
@ -65,7 +65,7 @@
</form> </form>
<!-- Setting display formats --> <!-- Setting display formats -->
<span ng-if="!conf.editting" data-test-subj="currentValue"> <span ng-if="!conf.editing" data-test-subj="currentValue">
<span ng-show="(conf.normal || conf.json || conf.select)">{{conf.value || conf.defVal}}</span> <span ng-show="(conf.normal || conf.json || conf.select)">{{conf.value || conf.defVal}}</span>
<span ng-show="conf.array">{{(conf.value || conf.defVal).join(', ')}}</span> <span ng-show="conf.array">{{(conf.value || conf.defVal).join(', ')}}</span>
<span ng-show="conf.bool">{{conf.value === undefined ? conf.defVal : conf.value}}</span> <span ng-show="conf.bool">{{conf.value === undefined ? conf.defVal : conf.value}}</span>
@ -74,7 +74,7 @@
</td> </td>
<td class="actions"> <td class="actions">
<button <button
ng-if="!conf.editting" ng-if="!conf.editing"
ng-click="edit(conf)" ng-click="edit(conf)"
class="btn btn-default" class="btn btn-default"
ng-disabled="conf.tooComplex" ng-disabled="conf.tooComplex"
@ -85,7 +85,7 @@
</button> </button>
<button <button
ng-if="conf.editting" ng-if="conf.editing"
ng-click="save(conf)" ng-click="save(conf)"
class="btn btn-success" class="btn btn-success"
ng-disabled="conf.loading || conf.tooComplex || forms.configEdit.$invalid" ng-disabled="conf.loading || conf.tooComplex || forms.configEdit.$invalid"
@ -97,7 +97,7 @@
</button> </button>
<button <button
ng-if="!conf.editting" ng-if="!conf.editing"
ng-click="clear(conf)" ng-click="clear(conf)"
ng-hide="conf.value === undefined" ng-hide="conf.value === undefined"
class="btn btn-danger" class="btn btn-danger"
@ -108,7 +108,7 @@
</button> </button>
<button <button
ng-if="conf.editting" ng-if="conf.editing"
ng-click="cancelEdit(conf)" ng-click="cancelEdit(conf)"
class="btn btn-default" class="btn btn-default"
aria-label="Cancel edit" aria-label="Cancel edit"

View file

@ -22,12 +22,12 @@ define(function (require) {
// To allow passing form validation state back // To allow passing form validation state back
$scope.forms = {}; $scope.forms = {};
// setup loading flag, run async op, then clear loading and editting flag (just in case) // setup loading flag, run async op, then clear loading and editing flag (just in case)
var loading = function (conf, fn) { var loading = function (conf, fn) {
conf.loading = true; conf.loading = true;
fn() fn()
.finally(function () { .finally(function () {
conf.loading = conf.editting = false; conf.loading = conf.editing = false;
}) })
.catch(notify.fatal); .catch(notify.fatal);
}; };
@ -41,7 +41,7 @@ define(function (require) {
$scope.edit = function (conf) { $scope.edit = function (conf) {
conf.unsavedValue = conf.value == null ? conf.defVal : conf.value; conf.unsavedValue = conf.value == null ? conf.defVal : conf.value;
$scope.configs.forEach(function (c) { $scope.configs.forEach(function (c) {
c.editting = (c === conf); c.editing = (c === conf);
}); });
}; };
@ -56,7 +56,7 @@ define(function (require) {
}; };
$scope.cancelEdit = function (conf) { $scope.cancelEdit = function (conf) {
conf.editting = false; conf.editing = false;
}; };
$scope.clear = function (conf) { $scope.clear = function (conf) {

View file

@ -7,7 +7,7 @@ require('ui/modules').get('apps/settings')
template: require('plugins/kibana/settings/sections/indices/directives/kbn_settings_indices.html'), template: require('plugins/kibana/settings/sections/indices/directives/kbn_settings_indices.html'),
link: function ($scope) { link: function ($scope) {
$scope.showAddNew = !/^\/settings\/indices$/.test($route.current.$$route.originalPath); $scope.showAddNew = !/^\/settings\/indices$/.test($route.current.$$route.originalPath);
$scope.edittingId = $route.current.params.indexPatternId; $scope.editingId = $route.current.params.indexPatternId;
config.$bind($scope, 'defaultIndex'); config.$bind($scope, 'defaultIndex');
$scope.$watch('defaultIndex', function () { $scope.$watch('defaultIndex', function () {
@ -16,7 +16,7 @@ require('ui/modules').get('apps/settings')
return { return {
id: id, id: id,
url: kbnUrl.eval('#/settings/indices/edit/{{id}}', {id: id}), url: kbnUrl.eval('#/settings/indices/edit/{{id}}', {id: id}),
class: 'sidebar-item-title ' + ($scope.edittingId === id ? 'active' : ''), class: 'sidebar-item-title ' + ($scope.editingId === id ? 'active' : ''),
default: $scope.defaultIndex === id default: $scope.defaultIndex === id
}; };
}); });

View file

@ -1,5 +1,5 @@
<kbn-agg-table <kbn-agg-table
table="table" table="table"
export-title="vis.title" export-title="vis.title"
per-page="editableVis.params.spyPerPage"> per-page="spy.params.spyPerPage">
</kbn-agg-table> </kbn-agg-table>

View file

@ -21,8 +21,8 @@ define(function (require) {
if (!$scope.vis || !$scope.esResp) { if (!$scope.vis || !$scope.esResp) {
$scope.table = null; $scope.table = null;
} else { } else {
if (!$scope.editableVis.params.spyPerPage) { if (!$scope.spy.params.spyPerPage) {
$scope.editableVis.params.spyPerPage = PER_PAGE_DEFAULT; $scope.spy.params.spyPerPage = PER_PAGE_DEFAULT;
} }
$scope.table = tabifyAggResponse($scope.vis, $scope.esResp, { $scope.table = tabifyAggResponse($scope.vis, $scope.esResp, {

View file

@ -14,7 +14,7 @@ module.exports = (kibana) => {
}, },
uiExports: { uiExports: {
bundle: async (UiBundle, env, apps) => { bundle: async (UiBundle, env, apps, plugins) => {
let modules = []; let modules = [];
let config = kibana.config; let config = kibana.config;
@ -23,10 +23,15 @@ module.exports = (kibana) => {
modules = union(modules, app.getModules()); modules = union(modules, app.getModules());
} }
let testFiles = await findSourceFiles([ const testGlobs = [
'src/**/public/**/__tests__/**/*.js', 'src/ui/public/**/__tests__/**/*.js',
'installedPlugins/*/public/**/__tests__/**/*.js' ];
]);
for (const plugin of plugins) {
testGlobs.push(`${plugin.publicDir}/**/__tests__/**/*.js`);
}
const testFiles = await findSourceFiles(testGlobs);
for (let f of testFiles) modules.push(f); for (let f of testFiles) modules.push(f);

View file

@ -1,7 +1,7 @@
let _ = require('lodash'); let _ = require('lodash');
let Joi = require('joi'); let Joi = require('joi');
let { attempt, fromNode } = require('bluebird'); let { attempt, fromNode } = require('bluebird');
let { resolve } = require('path'); let { basename, resolve } = require('path');
let { inherits } = require('util'); let { inherits } = require('util');
const defaultConfigSchema = Joi.object({ const defaultConfigSchema = Joi.object({
@ -18,11 +18,23 @@ module.exports = class Plugin {
this.uiExportsSpecs = opts.uiExports || {}; this.uiExportsSpecs = opts.uiExports || {};
this.requiredIds = opts.require || []; this.requiredIds = opts.require || [];
this.version = opts.version || pkg.version; this.version = opts.version || pkg.version;
this.publicDir = opts.publicDir !== false ? resolve(path, 'public') : null;
this.externalCondition = opts.initCondition || _.constant(true); this.externalCondition = opts.initCondition || _.constant(true);
this.externalInit = opts.init || _.noop; this.externalInit = opts.init || _.noop;
this.getConfigSchema = opts.config || _.noop; this.getConfigSchema = opts.config || _.noop;
this.init = _.once(this.init); this.init = _.once(this.init);
if (opts.publicDir === false) {
this.publicDir = null;
}
else if (!opts.publicDir) {
this.publicDir = resolve(this.path, 'public');
}
else {
this.publicDir = opts.publicDir;
if (basename(this.publicDir) !== 'public') {
throw new Error(`publicDir for plugin ${this.id} must end with a "public" directory.`);
}
}
} }
static scoped(kbnServer, path, pkg) { static scoped(kbnServer, path, pkg) {

View file

@ -35,7 +35,7 @@ module.exports = async (kbnServer, server, config) => {
} }
for (let gen of uiExports.getBundleProviders()) { for (let gen of uiExports.getBundleProviders()) {
let bundle = await gen(UiBundle, bundlerEnv, uiExports.getAllApps()); let bundle = await gen(UiBundle, bundlerEnv, uiExports.getAllApps(), kbnServer.plugins);
if (bundle) bundles.add(bundle); if (bundle) bundles.add(bundle);
} }

View file

@ -23,7 +23,7 @@ define(function (require) {
self.fetch(); self.fetch();
}), }),
// begining of full route update, new app will be initialized before // beginning of full route update, new app will be initialized before
// $routeChangeSuccess or $routeChangeError // $routeChangeSuccess or $routeChangeError
$rootScope.$on('$routeChangeStart', function () { $rootScope.$on('$routeChangeStart', function () {
if (self._persistAcrossApps) { if (self._persistAcrossApps) {
@ -136,8 +136,8 @@ define(function (require) {
* @returns {void} * @returns {void}
*/ */
State.prototype.destroy = function () { State.prototype.destroy = function () {
this.off(); // removes all listners this.off(); // removes all listeners
this._cleanUpListeners(); // Removes the $routeUpdate listner this._cleanUpListeners(); // Removes the $routeUpdate listener
}; };
State.prototype.setDefaults = function (defaults) { State.prototype.setDefaults = function (defaults) {

View file

@ -88,9 +88,9 @@ define(function (require) {
/** /**
* Return the current bounds, if we have any. * Return the current bounds, if we have any.
* *
* THIS DOES NOT CLONE THE BOUNDS, so editting them * THIS DOES NOT CLONE THE BOUNDS, so editing them
* may have unexpected side-effects. Always * may have unexpected side-effects. Always
* call bounds.min.clone() before editting * call bounds.min.clone() before editing
* *
* @return {object|undefined} - If bounds are not defined, this * @return {object|undefined} - If bounds are not defined, this
* returns undefined, else it returns the bounds * returns undefined, else it returns the bounds

View file

@ -16,6 +16,7 @@ define(function (require) {
var $container = $el.find('.visualize-spy-container'); var $container = $el.find('.visualize-spy-container');
var fullPageSpy = _.get($scope.spy, 'mode.fill', false); var fullPageSpy = _.get($scope.spy, 'mode.fill', false);
$scope.modes = spyModes; $scope.modes = spyModes;
$scope.spy.params = $scope.spy.params || {};
function getSpyObject(name) { function getSpyObject(name) {
name = _.isUndefined(name) ? $scope.spy.mode.name : name; name = _.isUndefined(name) ? $scope.spy.mode.name : name;

View file

@ -37,7 +37,7 @@ module.exports = function (grunt) {
// use an async iife to store promise for download // use an async iife to store promise for download
// then store platform in active downloads list // then store platform in active downloads list
// which we will read from in the finish task // which we will read from in the finish task
platform.downloadPromise = (async () => { platform.downloadPromise = (async function () {
grunt.file.mkdir(downloadDir); grunt.file.mkdir(downloadDir);
if (platform.name === 'windows') { if (platform.name === 'windows') {
@ -82,4 +82,3 @@ module.exports = function (grunt) {
.nodeify(this.async()); .nodeify(this.async());
}); });
}; };

View file

@ -1,31 +1,33 @@
module.exports = function (grunt) { module.exports = function (grunt) {
let { flatten } = require('lodash'); let { flatten } = require('lodash');
grunt.registerTask('build', flatten([ grunt.registerTask('build', 'Build packages', function (arg) {
'_build:getProps', grunt.task.run(flatten([
'clean:build', '_build:getProps',
'clean:target', 'clean:build',
'_build:downloadNodeBuilds:start', 'clean:target',
'copy:devSource', '_build:downloadNodeBuilds:start',
'babel:build', 'copy:devSource',
'_build:babelOptions', 'babel:build',
'_build:installedPlugins', '_build:babelOptions',
'_build:packageJson', '_build:installedPlugins',
'_build:readme', '_build:packageJson',
'_build:installNpmDeps', '_build:readme',
'_build:removePkgJsonDeps', '_build:installNpmDeps',
'clean:testsFromModules', '_build:removePkgJsonDeps',
'clean:deepModuleBins', 'clean:testsFromModules',
'clean:deepModules', 'clean:deepModuleBins',
'run:optimizeBuild', 'clean:deepModules',
'stop:optimizeBuild', 'run:optimizeBuild',
'_build:downloadNodeBuilds:finish', 'stop:optimizeBuild',
'_build:versionedLinks', '_build:downloadNodeBuilds:finish',
'_build:archives', '_build:versionedLinks',
!grunt.option('os-packages') ? [] : [ '_build:archives',
'_build:pleaseRun', (grunt.option('os-packages') || arg === 'ospackages') ? [
'_build:osPackages', '_build:pleaseRun',
], '_build:osPackages',
'_build:shasums' ] : [],
])); '_build:shasums'
]));
});
}; };

View file

@ -1,3 +1,5 @@
require('../../test/mocha_setup');
module.exports = { module.exports = {
options: { options: {
timeout: 10000, timeout: 10000,

View file

@ -3,7 +3,7 @@ module.exports = function (grunt) {
grunt.registerTask('jenkins', 'Jenkins build script', compact([ grunt.registerTask('jenkins', 'Jenkins build script', compact([
'test', 'test',
process.env.JOB_NAME === 'kibana_core' ? 'build' : null process.env.JOB_NAME === 'kibana_core' ? 'build:ospackages' : null
])); ]));
}; };

View file

@ -2,7 +2,7 @@ var expect = require('expect.js');
var sinon = require('sinon'); var sinon = require('sinon');
var Promise = require('bluebird'); var Promise = require('bluebird');
var ScenarioManager = require('../scenarioManager'); var ScenarioManager = require('../scenario_manager');
describe('scenario manager', function () { describe('scenario manager', function () {
var manager = new ScenarioManager('http://localhost:9200'); var manager = new ScenarioManager('http://localhost:9200');

View file

@ -0,0 +1,128 @@
define(function (require) {
var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/discover_page');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('discover tab', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var baseUrl;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
baseUrl = common.getHostPort();
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('legend', function () {
bdd.it('should initially be collapsed', function () {
return discoverPage.getLegendWidth()
.then(function (actualwidth) {
common.debug('collapsed legend width = ' + actualwidth);
expect(actualwidth < 20).to.be(true);
})
.catch(common.handleError(this));
});
bdd.it('should expand when clicked', function () {
return discoverPage.clickLegendExpand()
.then(function () {
return discoverPage.getLegendWidth();
})
.then(function (actualwidth) {
common.debug('expanded legend width = ' + actualwidth);
expect(actualwidth > 140).to.be(true);
})
.catch(common.handleError(this));
});
bdd.it('should collapse when clicked', function () {
return discoverPage.clickLegendCollapse()
.then(function () {
return discoverPage.getLegendWidth();
})
.then(function (actualwidth) {
expect(actualwidth < 20).to.be(true);
})
.catch(common.handleError(this));
});
});
bdd.describe('field data', function () {
bdd.it('should initially be expanded', function () {
return discoverPage.getSidebarWidth()
.then(function (actualwidth) {
common.debug('expanded sidebar width = ' + actualwidth);
expect(actualwidth > 180).to.be(true);
})
.catch(common.handleError(this));
});
bdd.it('should collapse when clicked', function () {
return discoverPage.clickSidebarCollapse()
.then(function () {
return discoverPage.getSidebarWidth();
})
.then(function (actualwidth) {
common.debug('collapsed sidebar width = ' + actualwidth);
expect(actualwidth < 20).to.be(true);
})
.catch(common.handleError(this));
});
bdd.it('should expand when clicked', function () {
return discoverPage.clickSidebarExpand()
.then(function () {
return discoverPage.getSidebarWidth();
})
.then(function (actualwidth) {
common.debug('expanded sidebar width = ' + actualwidth);
expect(actualwidth > 180).to.be(true);
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -1,8 +1,8 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {
@ -272,7 +272,7 @@ define(function (require) {
var hasFailure = false; var hasFailure = false;
for (var y = 0; y < expectedBarChartData.length; y++) { for (var y = 0; y < expectedBarChartData.length; y++) {
stringResults += y + ': expected = ' + expectedBarChartData[y] + ', actual = ' + paths[y] + stringResults += y + ': expected = ' + expectedBarChartData[y] + ', actual = ' + paths[y] +
', Pass = ' + (Math.abs(expectedBarChartData[y] - paths[y]) < barHeightTolerance); ', Pass = ' + (Math.abs(expectedBarChartData[y] - paths[y]) < barHeightTolerance) + '\n';
if ((Math.abs(expectedBarChartData[y] - paths[y]) > barHeightTolerance)) { if ((Math.abs(expectedBarChartData[y] - paths[y]) > barHeightTolerance)) {
hasFailure = true; hasFailure = true;
}; };

View file

@ -1,8 +1,8 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -0,0 +1,140 @@
define(function (require) {
var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/discover_page');
var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) {
bdd.describe('shared links', function describeIndexTests() {
var common;
var headerPage;
var settingsPage;
var discoverPage;
var baseUrl;
// The message changes for Firefox < 41 and Firefox >= 41
// var expectedToastMessage = 'Share search: URL selected. Press Ctrl+C to copy.';
// var expectedToastMessage = 'Share search: URL copied to clipboard.';
// Pass either one.
var expectedToastMessage = /Share search: URL (selected. Press Ctrl+C to copy.|copied to clipboard.)/;
bdd.before(function () {
common = new Common(this.remote);
headerPage = new HeaderPage(this.remote);
settingsPage = new SettingsPage(this.remote);
discoverPage = new DiscoverPage(this.remote);
baseUrl = common.getHostPort();
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('shared link', function () {
bdd.it('should show "Share a link" caption', function () {
var expectedCaption = 'Share a link';
return discoverPage.clickShare()
.then(function () {
return discoverPage.getShareCaption();
})
.then(function (actualCaption) {
expect(actualCaption).to.be(expectedCaption);
})
.catch(common.handleError(this));
});
bdd.it('should show the correct formatted URL', function () {
var expectedUrl = baseUrl
+ '/app/kibana?_t=1453775307251#'
+ '/discover?_g=(refreshInterval:(display:Off,pause:!f,value:0),time'
+ ':(from:%272015-09-19T06:31:44.000Z%27,mode:absolute,to:%272015-09'
+ '-23T18:31:44.000Z%27))&_a=(columns:!(_source),index:%27logstash-'
+ '*%27,interval:auto,query:(query_string:(analyze_wildcard:!t,query'
+ ':%27*%27)),sort:!(%27@timestamp%27,desc))';
return discoverPage.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'));
})
.catch(common.handleError(this));
});
bdd.it('should show toast message for copy to clipboard', function () {
return discoverPage.clickCopyToClipboard()
.then(function () {
return headerPage.getToastMessage();
})
.then(function (toastMessage) {
expect(toastMessage).to.match(expectedToastMessage);
})
.then(function () {
return headerPage.waitForToastMessageGone();
})
.catch(common.handleError(this));
});
// TODO: verify clipboard contents
bdd.it('shorten URL button should produce a short URL', function () {
var re = new RegExp(baseUrl + '/goto/[0-9a-f]{32}$');
return discoverPage.clickShortenUrl()
.then(function () {
return common.tryForTime(20 * 1000, function tryingForTime() {
return discoverPage.getShortenedUrl()
.then(function (actualUrl) {
expect(actualUrl).to.match(re);
});
});
})
.catch(common.handleError(this));
});
// NOTE: This test has to run immediately after the test above
bdd.it('should show toast message for copy to clipboard', function () {
return discoverPage.clickCopyToClipboard()
.then(function () {
return headerPage.getToastMessage();
})
.then(function (toastMessage) {
expect(toastMessage).to.match(expectedToastMessage);
})
.then(function () {
return headerPage.waitForToastMessageGone();
})
.catch(common.handleError(this));
});
});
});
};
});

View file

@ -2,9 +2,11 @@ define(function (require) {
var bdd = require('intern!bdd'); var bdd = require('intern!bdd');
var config = require('intern').config; var config = require('intern').config;
var url = require('intern/dojo/node!url'); var url = require('intern/dojo/node!url');
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenario_manager');
var discoverTest = require('./_discover'); var discoverTest = require('./_discover');
var fieldData = require('./_field_data'); var fieldData = require('./_field_data');
var sharedLinks = require('./_shared_links');
var collapseExpand = require('./_collapse_expand');
bdd.describe('discover app', function () { bdd.describe('discover app', function () {
var scenarioManager; var scenarioManager;
@ -25,5 +27,9 @@ define(function (require) {
fieldData(bdd, scenarioManager); fieldData(bdd, scenarioManager);
sharedLinks(bdd, scenarioManager);
collapseExpand(bdd, scenarioManager);
}); });
}); });

View file

@ -1,5 +1,5 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');

View file

@ -1,5 +1,5 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');

View file

@ -1,5 +1,5 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');

View file

@ -1,5 +1,5 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');

View file

@ -1,6 +1,6 @@
define(function (require) { define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');

View file

@ -1,6 +1,6 @@
define(function (require) { define(function (require) {
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -2,7 +2,7 @@ define(function (require) {
var bdd = require('intern!bdd'); var bdd = require('intern!bdd');
var config = require('intern').config; var config = require('intern').config;
var url = require('intern/dojo/node!url'); var url = require('intern/dojo/node!url');
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenario_manager');
var initialStateTest = require('./_initial_state'); var initialStateTest = require('./_initial_state');
var creationChangesTest = require('./_creation_form_changes'); var creationChangesTest = require('./_creation_form_changes');

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,7 +1,7 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -1,9 +1,9 @@
define(function (require) { define(function (require) {
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage'); var DiscoverPage = require('../../../support/pages/discover_page');
var VisualizePage = require('../../../support/pages/VisualizePage'); var VisualizePage = require('../../../support/pages/visualize_page');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
return function (bdd, scenarioManager) { return function (bdd, scenarioManager) {

View file

@ -4,9 +4,9 @@ define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var url = require('intern/dojo/node!url'); var url = require('intern/dojo/node!url');
var _ = require('intern/dojo/node!lodash'); var _ = require('intern/dojo/node!lodash');
var Common = require('../../../support/pages/Common'); var Common = require('../../../support/pages/common');
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenario_manager');
var HeaderPage = require('../../../support/pages/HeaderPage'); var HeaderPage = require('../../../support/pages/header_page');
var SettingsPage = require('../../../support/pages/settings_page'); var SettingsPage = require('../../../support/pages/settings_page');
var chartTypeTest = require('./_chart_types'); var chartTypeTest = require('./_chart_types');

View file

@ -2,7 +2,7 @@ define(function (require) {
var bdd = require('intern!bdd'); var bdd = require('intern!bdd');
var expect = require('intern/dojo/node!expect.js'); var expect = require('intern/dojo/node!expect.js');
var config = require('intern').config; var config = require('intern').config;
var Common = require('../../support/pages/Common'); var Common = require('../../support/pages/common');
bdd.describe('status page', function () { bdd.describe('status page', function () {
var common; var common;

1
test/mocha.opts Normal file
View file

@ -0,0 +1 @@
--require test/mocha_setup.js

41
test/mocha_setup.js Normal file
View file

@ -0,0 +1,41 @@
var sinon = require('sinon');
var autoRelease = require('auto-release-sinon');
require('babel/register')(require('../src/optimize/babelOptions').node);
// hook into the global afterEach variable to allow autoReleaseSinon to register
// an afterEach handler before mocha has exposed itself to the test files.
//
// This works by telling autoReleaseSinon to use a fake "afterEach" function.
// Rather than actually record an afterEach handler the function tracks all of
// the calls it received and queues them up in queuedAfterEachArgs.
//
// The global "afterEach" variable is also tracked, and once it is assigned by mocha
// the variable global is reconfigured to point directly to the new value (from mocha)
// and all of the queued invocations are executed.
var queuedAfterEachArgs = [];
Object.defineProperty(global, 'afterEach', {
configurable: true,
get() { return undefined; },
set(afterEach) {
Object.defineProperty(global, 'afterEach', {
configurable: true,
writable: true,
value: afterEach
});
queuedAfterEachArgs.forEach(function (args) {
afterEach.apply(null, args);
});
return global.afterEach;
}
});
autoRelease.setupAutoRelease(sinon, function () {
if (!global.afterEach) {
queuedAfterEachArgs.push(Array.prototype.slice.call(arguments));
} else {
global.afterEach.apply(this, arguments);
}
});

View file

@ -1,4 +1,4 @@
// in test/support/pages/Common.js // in test/support/pages/common.js
define(function (require) { define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var Promise = require('bluebird'); var Promise = require('bluebird');
@ -51,6 +51,10 @@ define(function (require) {
Common.prototype = { Common.prototype = {
constructor: Common, constructor: Common,
getHostPort: function getHostPort() {
return getUrl.baseUrl(config.servers.kibana);
},
navigateToApp: function (appName, testStatusPage) { navigateToApp: function (appName, testStatusPage) {
var self = this; var self = this;
// navUrl includes user:password@ for use with Shield // navUrl includes user:password@ for use with Shield

View file

@ -1,7 +1,7 @@
// in test/support/pages/DiscoverPage.js // in test/support/pages/discover_page.js
define(function (require) { define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var Common = require('./Common'); var Common = require('./common');
var defaultTimeout = config.timeouts.default; var defaultTimeout = config.timeouts.default;
var common; var common;
@ -175,6 +175,78 @@ define(function (require) {
return thisTime return thisTime
.findAllByCssSelector('mark') .findAllByCssSelector('mark')
.getVisibleText(); .getVisibleText();
},
clickShare: function clickShare() {
return thisTime
.findByCssSelector('button[aria-label="Share Search"]')
.click();
},
clickShortenUrl: function clickShortenUrl() {
return thisTime
.findByCssSelector('button.shorten-button')
.click();
},
clickCopyToClipboard: function clickCopyToClipboard() {
return thisTime
.findByCssSelector('button.clipboard-button')
.click();
},
getShareCaption: function getShareCaption() {
return thisTime
.findByCssSelector('div.form-group > label')
.getVisibleText();
},
getSharedUrl: function getSharedUrl() {
return thisTime
.findByCssSelector('.url')
.getProperty('baseURI');
},
getShortenedUrl: function getShortenedUrl() {
return thisTime
.findByCssSelector('.url')
.getProperty('value');
},
clickLegendExpand: function clickLegendExpand() {
return thisTime
.findByCssSelector('.fa-chevron-left')
.click();
},
clickLegendCollapse: function clickLegendCollapse() {
return thisTime
.findByCssSelector('div.legend-toggle > i.fa-chevron-right')
.click();
},
getLegendWidth: function getLegendWidth() {
return thisTime
.findByCssSelector('.legend-col-wrapper')
.getProperty('clientWidth');
},
clickSidebarExpand: function clickSidebarExpand() {
return thisTime
.findByCssSelector('.chevron-cont')
.click();
},
clickSidebarCollapse: function clickSidebarCollapse() {
return thisTime
.findByCssSelector('.chevron-cont')
.click();
},
getSidebarWidth: function getSidebarWidth() {
return thisTime
.findByCssSelector('.sidebar-list')
.getProperty('clientWidth');
} }
}; };

View file

@ -1,7 +1,7 @@
// in test/support/pages/HeaderPage.js // in test/support/pages/header_page.js
define(function (require) { define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var Common = require('./Common'); var Common = require('./common');
var common; var common;

View file

@ -2,7 +2,7 @@
define(function (require) { define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var Promise = require('bluebird'); var Promise = require('bluebird');
var Common = require('./Common'); var Common = require('./common');
var defaultTimeout = config.timeouts.default; var defaultTimeout = config.timeouts.default;
var common; var common;

View file

@ -2,7 +2,7 @@ define(function (require) {
var config = require('intern').config; var config = require('intern').config;
var registerSuite = require('intern!object'); var registerSuite = require('intern!object');
var Common = require('./Common'); var Common = require('./common');
var defaultTimeout = config.timeouts.default; var defaultTimeout = config.timeouts.default;
var common; var common;

View file

@ -1,7 +1,7 @@
define(function (require) { define(function (require) {
var bdd = require('intern!bdd'); var bdd = require('intern!bdd');
var serverConfig = require('intern/dojo/node!../../../serverConfig'); var serverConfig = require('intern/dojo/node!../../../serverConfig');
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenarioManager'); var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenario_manager');
var request = require('intern/dojo/node!supertest-as-promised'); var request = require('intern/dojo/node!supertest-as-promised');
var url = require('intern/dojo/node!url'); var url = require('intern/dojo/node!url');
var _ = require('intern/dojo/node!lodash'); var _ = require('intern/dojo/node!lodash');

View file

@ -8,7 +8,8 @@ var url = require('url');
* { * {
* protocol: 'http', * protocol: 'http',
* hostname: 'localhost', * hostname: 'localhost',
* port: 9220 * port: 9220,
* auth: shield.kibanaUser.username + ':' + shield.kibanaUser.password
* } * }
* @param {object} app The params to append * @param {object} app The params to append
* example: * example:
@ -31,3 +32,7 @@ getUrl.noAuth = function getUrlNoAuth(config, app) {
}); });
return getUrl(config, app); return getUrl(config, app);
}; };
getUrl.baseUrl = function getBaseUrl(config) {
return url.format(_.pick(config, 'protocol', 'hostname', 'port'));
};