Merge pull request #7132 from LeeDr/consoleTest

2 new simple Console functional tests
This commit is contained in:
Lee Drengenberg 2016-05-06 11:19:06 -05:00
commit 8b8b3bdbe4
8 changed files with 166 additions and 4 deletions

View file

@ -0,0 +1,68 @@
import {
bdd,
scenarioManager,
common,
// settingsPage,
// headerPage,
consolePage
} from '../../../support';
(function () {
var expect = require('expect.js');
(function () {
bdd.describe('console app', function describeIndexTests() {
bdd.before(function () {
common.debug('navigateTo console');
return common.navigateToApp('console', false)
.catch(common.handleError(this));
});
bdd.it('should show the default request', function () {
var expectedRequest = [
'GET _search',
'{',
' "query": {',
' "match_all": {}',
' }',
'}',
''
];
// collapse the help pane because we only get the VISIBLE TEXT, not the part that is scrolled
return consolePage.collapseHelp()
.then(function () {
return common.try(function () {
return consolePage.getRequest()
.then(function (actualRequest) {
expect(actualRequest).to.eql(expectedRequest);
});
});
})
.catch(common.handleError(this));
});
bdd.it('default request reponse should contain .kibana' , function () {
var expectedResponseContains = '"_index": ".kibana",';
var elasticsearch = common.getEsHostPort();
return consolePage.setServer(elasticsearch)
.then(function () {
return consolePage.clickPlay();
})
.then(function () {
return common.try(function () {
return consolePage.getResponse()
.then(function (actualResponse) {
common.debug(actualResponse);
expect(actualResponse).to.contain(expectedResponseContains);
});
});
})
.catch(common.handleError(this));
});
});
}());
}());

View file

@ -0,0 +1,17 @@
import { bdd, remote, scenarioManager, defaultTimeout } from '../../../support';
(function () {
bdd.describe('console app', function () {
this.timeout = defaultTimeout;
bdd.before(function () {
return remote.setWindowSize(1200,800);
});
bdd.after(function unloadMakelogs() {
return scenarioManager.unload('logstashFunctional');
});
require('./_console');
});
}());

View file

@ -12,10 +12,8 @@ import {
(function () {
bdd.describe('discover tab', function describeIndexTests() {
var baseUrl;
bdd.before(function () {
baseUrl = common.getHostPort();
var fromTime = '2015-09-19 06:31:44.000';
var toTime = '2015-09-23 18:31:44.000';
@ -26,7 +24,7 @@ import {
.then(function loadIfEmptyMakelogs() {
return scenarioManager.loadIfEmpty('logstashFunctional');
})
.then(function (navigateTo) {
.then(function () {
common.debug('navigateTo');
return settingsPage.navigateTo();
})

View file

@ -23,7 +23,8 @@ define(function (require) {
'intern/dojo/node!./apps/discover',
'intern/dojo/node!./status_page',
'intern/dojo/node!./apps/settings',
'intern/dojo/node!./apps/visualize'
'intern/dojo/node!./apps/visualize',
'intern/dojo/node!./apps/console'
], function () {});
});
});

View file

@ -41,6 +41,9 @@ module.exports = {
settings: {
pathname: kibanaURL,
hash: '/settings'
},
console: {
pathname: 'app/console',
}
}
};

View file

@ -6,6 +6,7 @@ import SettingsPage from './pages/settings_page';
import HeaderPage from './pages/header_page';
import VisualizePage from './pages/visualize_page';
import ShieldPage from './pages/shield_page';
import ConsolePage from './pages/console_page';
const kbnInternVars = global.__kibana__intern__;
@ -23,6 +24,7 @@ defineDelayedExport('headerPage', () => new HeaderPage());
defineDelayedExport('settingsPage', () => new SettingsPage());
defineDelayedExport('visualizePage', () => new VisualizePage());
defineDelayedExport('shieldPage', () => new ShieldPage());
defineDelayedExport('consolePage', () => new ConsolePage());
// creates an export for values that aren't actually avaialable until
// until tests start to run. These getters will throw errors if the export

View file

@ -53,6 +53,10 @@ export default (function () {
return getUrl.baseUrl(config.servers.kibana);
},
getEsHostPort: function getHostPort() {
return getUrl.baseUrl(config.servers.elasticsearch);
},
navigateToApp: function (appName, testStatusPage) {
var self = this;
// navUrl includes user:password@ for use with Shield

View file

@ -0,0 +1,69 @@
import { remote, defaultFindTimeout } from '../';
// in test/support/pages/shield_page.js
export default (function (require) {
// the page object is created as a constructor
// so we can provide the remote Command object
// at runtime
var thisTime;
function ConsolePage() {
this.remote = remote;
thisTime = this.remote.setFindTimeout(defaultFindTimeout);
}
ConsolePage.prototype = {
constructor: ConsolePage,
getServer: function getServer() {
return thisTime
.findByCssSelector('#kibana-body > div.content > div > div')
.getVisibleText();
},
setServer: function setServer(server) {
return thisTime
.findByCssSelector('input[aria-label="Server Name"]')
.clearValue()
.type(server);
},
getRequest: function getRequest() {
return thisTime
.findAllByCssSelector('div.ace_line_group')
.then(function (editorData) {
function getEditorData(line) {
return line.getVisibleText();
}
var getEditorDataPromises = editorData.map(getEditorData);
return Promise.all(getEditorDataPromises);
});
},
getResponse: function getResponse() {
return thisTime
.findByCssSelector('#output > div.ace_scroller > div')
.getVisibleText();
},
clickPlay: function clickPlay() {
return thisTime
.findByCssSelector('#editor_actions > span.ng-scope > a > i')
.click();
},
collapseHelp: function collapseHelp() {
return thisTime
.findByCssSelector('div.config-close.remove > i')
.click();
}
};
return ConsolePage;
}());