Merge branch 'master' of github.com:elastic/kibana into implement/uiExportsInjectVars
This commit is contained in:
commit
80ba79dbc5
|
@ -146,7 +146,8 @@ Run the tests for just your particular plugin. Assuming you plugin lives outside
|
|||
|
||||
#### Running browser automation tests:
|
||||
|
||||
*The Selenium server that is started currently only runs the tests in Firefox*
|
||||
*The Selenium server that is started currently only runs the tests in a recent version of Firefox.*
|
||||
*You can use the `PATH` environment variable to specify which version of Firefox to use.*
|
||||
|
||||
The following will start Kibana, Elasticsearch and Selenium for you. To run the functional UI tests use the following commands
|
||||
|
||||
|
@ -177,7 +178,7 @@ npm run test:ui:runner
|
|||
- These tests have been developed and tested with Chrome and Firefox browser. In theory, they should work on all browsers (that's the benefit of Intern using Leadfoot).
|
||||
- These tests should also work with an external testing service like https://saucelabs.com/ or https://www.browserstack.com/ but that has not been tested.
|
||||
- https://theintern.github.io/
|
||||
- https://theintern.github.io/leadfoot/Element.html
|
||||
- https://theintern.github.io/leadfoot/module-leadfoot_Element.html
|
||||
|
||||
#### Building OS packages
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import ingest from './server/routes/api/ingest';
|
||||
import search from './server/routes/api/search';
|
||||
|
||||
module.exports = function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
|
@ -44,6 +45,7 @@ module.exports = function (kibana) {
|
|||
|
||||
init: function (server, options) {
|
||||
ingest(server);
|
||||
search(server);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import _ from 'lodash';
|
||||
import handleESError from '../../../../lib/handle_es_error';
|
||||
|
||||
export default function registerCount(server) {
|
||||
server.route({
|
||||
path: '/api/kibana/{id}/_count',
|
||||
method: ['POST', 'GET'],
|
||||
handler: function (req, reply) {
|
||||
const boundCallWithRequest = _.partial(server.plugins.elasticsearch.callWithRequest, req);
|
||||
|
||||
boundCallWithRequest('count', {
|
||||
allowNoIndices: false,
|
||||
index: req.params.id
|
||||
})
|
||||
.then(
|
||||
function (res) {
|
||||
reply({count: res.count});
|
||||
},
|
||||
function (error) {
|
||||
reply(handleESError(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
5
src/plugins/kibana/server/routes/api/search/index.js
Normal file
5
src/plugins/kibana/server/routes/api/search/index.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import registerCount from './count/register_count';
|
||||
|
||||
export default function (server) {
|
||||
registerCount(server);
|
||||
}
|
|
@ -4,7 +4,6 @@ import Status from '../status';
|
|||
import ServerStatus from '../server_status';
|
||||
|
||||
describe('Status class', function () {
|
||||
|
||||
var server;
|
||||
var serverStatus;
|
||||
|
||||
|
@ -59,6 +58,34 @@ describe('Status class', function () {
|
|||
expect(json.message).to.eql('Ready');
|
||||
});
|
||||
|
||||
it('should call on handler if status is already matched', function (done) {
|
||||
var status = serverStatus.create('test');
|
||||
var msg = 'Test Ready';
|
||||
status.green(msg);
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
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 (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();
|
||||
});
|
||||
});
|
||||
|
||||
function testState(color) {
|
||||
it(`should change the state to ${color} when #${color}() is called`, function () {
|
||||
var status = serverStatus.create('test');
|
||||
|
|
|
@ -36,6 +36,22 @@ class Status extends EventEmitter {
|
|||
since: this.since
|
||||
};
|
||||
}
|
||||
|
||||
on(eventName, handler) {
|
||||
super.on(eventName, handler);
|
||||
|
||||
if (eventName === this.state) {
|
||||
setImmediate(() => handler(this.state, this.message));
|
||||
}
|
||||
}
|
||||
|
||||
once(eventName, handler) {
|
||||
if (eventName === this.state) {
|
||||
setImmediate(() => handler(this.state, this.message));
|
||||
} else {
|
||||
super.once(eventName, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states.all.forEach(function (state) {
|
||||
|
|
|
@ -36,5 +36,10 @@ describe('chrome nav apis', function () {
|
|||
const chrome = getChrome();
|
||||
expect(chrome.addBasePath('http://github.com/elastic/kibana')).to.be('http://github.com/elastic/kibana');
|
||||
});
|
||||
|
||||
it('includes the query string', function () {
|
||||
const chrome = getChrome();
|
||||
expect(chrome.addBasePath('/app/kibana?a=b')).to.be(`${basePath}/app/kibana?a=b`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,6 +16,13 @@
|
|||
ng-class="'btn-' + notif.type"
|
||||
ng-click="notif.showStack = true"
|
||||
>More Info</button>
|
||||
<button
|
||||
type="button"
|
||||
ng-if="notif.stack && notif.showStack"
|
||||
class="btn"
|
||||
ng-class="'btn-' + notif.type"
|
||||
ng-click="notif.showStack = false"
|
||||
>Less Info</button>
|
||||
<button
|
||||
type="button"
|
||||
ng-if="notif.accept"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
define({
|
||||
suites: [
|
||||
'test/unit/api/ingest/index'
|
||||
'test/unit/api/ingest/index',
|
||||
'test/unit/api/search/index'
|
||||
],
|
||||
excludeInstrumentation: /(fixtures|node_modules)\//,
|
||||
loaderOptions: {
|
||||
|
|
72
test/unit/api/search/_count.js
Normal file
72
test/unit/api/search/_count.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
define(function (require) {
|
||||
var Promise = require('bluebird');
|
||||
var _ = require('intern/dojo/node!lodash');
|
||||
var expect = require('intern/dojo/node!expect.js');
|
||||
|
||||
return function (bdd, scenarioManager, request) {
|
||||
bdd.describe('Count API', function postIngest() {
|
||||
|
||||
bdd.before(function () {
|
||||
return scenarioManager.client.create({
|
||||
index: 'foo-1',
|
||||
type: 'bar',
|
||||
id: '1',
|
||||
body: {
|
||||
foo: 'bar'
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
return scenarioManager.client.create({
|
||||
index: 'foo-2',
|
||||
type: 'bar',
|
||||
id: '2',
|
||||
body: {
|
||||
foo: 'bar'
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
return scenarioManager.client.indices.refresh({
|
||||
index: ['foo-1', 'foo-2']
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
bdd.after(function () {
|
||||
return scenarioManager.reload('emptyKibana')
|
||||
.then(function () {
|
||||
scenarioManager.client.indices.delete({
|
||||
index: 'foo*'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should return 200 with a document count for existing indices', function () {
|
||||
return request.post('/kibana/foo-*/_count')
|
||||
.expect(200)
|
||||
.then(function (response) {
|
||||
expect(response.body.count).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should support GET requests as well', function () {
|
||||
return request.get('/kibana/foo-*/_count')
|
||||
.expect(200)
|
||||
.then(function (response) {
|
||||
expect(response.body.count).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should return 404 if a pattern matches no indices', function () {
|
||||
return request.post('/kibana/doesnotexist-*/_count')
|
||||
.expect(404);
|
||||
});
|
||||
|
||||
bdd.it('should return 404 if a concrete index does not exist', function () {
|
||||
return request.post('/kibana/concrete/_count')
|
||||
.expect(404);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
});
|
23
test/unit/api/search/index.js
Normal file
23
test/unit/api/search/index.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
define(function (require) {
|
||||
var bdd = require('intern!bdd');
|
||||
var serverConfig = require('intern/dojo/node!../../../server_config');
|
||||
var ScenarioManager = require('intern/dojo/node!../../../fixtures/scenario_manager');
|
||||
var request = require('intern/dojo/node!supertest-as-promised');
|
||||
var url = require('intern/dojo/node!url');
|
||||
var count = require('./_count');
|
||||
|
||||
bdd.describe('search API', function () {
|
||||
var scenarioManager = new ScenarioManager(url.format(serverConfig.servers.elasticsearch));
|
||||
request = request(url.format(serverConfig.servers.kibana) + '/api');
|
||||
|
||||
bdd.before(function () {
|
||||
return scenarioManager.load('emptyKibana');
|
||||
});
|
||||
|
||||
bdd.after(function () {
|
||||
return scenarioManager.unload('emptyKibana');
|
||||
});
|
||||
|
||||
count(bdd, scenarioManager, request);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue