Add PageObjects facade to support/index.js, allowing us to enable all functional tests during the refactor.

This commit is contained in:
CJ Cenizal 2016-06-23 05:24:00 -07:00
parent 31137131f3
commit 2c7394b033
4 changed files with 44 additions and 23 deletions

View file

@ -14,8 +14,7 @@ bdd.describe('discover app', function () {
});
require('./_discover');
// TODO: Convert the rest of these to use PageObjects.
// require('./_field_data');
// require('./_shared_links');
// require('./_collapse_expand');
require('./_field_data');
require('./_shared_links');
require('./_collapse_expand');
});

View file

@ -1,3 +1,5 @@
'use strict'; // eslint-disable-line
define(function (require) {
require('intern/dojo/node!../support/env_setup');
@ -7,22 +9,26 @@ define(function (require) {
global.__kibana__intern__ = { intern, bdd };
bdd.describe('kibana', function () {
let PageObjects;
let support;
bdd.before(function () {
this.PageObjects.init(this.remote);
PageObjects.init(this.remote);
support.init(this.remote);
});
require([
'intern/dojo/node!../support/page_objects.js',
'intern/dojo/node!../support',
'intern/dojo/node!./apps/discover',
// TODO: Convert the rest of these to use PageObjects.
// 'intern/dojo/node!./status_page',
// 'intern/dojo/node!./apps/management',
// 'intern/dojo/node!./apps/visualize',
// 'intern/dojo/node!./apps/console',
// 'intern/dojo/node!./apps/dashboard'
], PageObjects => {
this.PageObjects = PageObjects;
'intern/dojo/node!./status_page',
'intern/dojo/node!./apps/management',
'intern/dojo/node!./apps/visualize',
'intern/dojo/node!./apps/console',
'intern/dojo/node!./apps/dashboard'
], (loadedPageObjects, loadedSupport) => {
PageObjects = loadedPageObjects;
support = loadedSupport;
});
});
});

View file

@ -4,6 +4,7 @@ import EsClient from './es_client';
import ElasticDump from './elastic_dump';
import BddWrapper from './bdd_wrapper';
import ScenarioManager from '../fixtures/scenario_manager';
import PageObjects from './page_objects';
// Intern values provided via the root index file of the test suite.
const kbnInternVars = global.__kibana__intern__;
@ -21,3 +22,18 @@ exports.scenarioManager =
new ScenarioManager(url.format(config.servers.elasticsearch));
exports.elasticDump = new ElasticDump();
exports.esClient = new EsClient(url.format(config.servers.elasticsearch));
// TODO: We're using this facade to avoid breaking existing functionality as
// we migrate test suites to the PageObject service. Once they're all migrated
// over, we can delete this facade code.
exports.init = function init(remote) {
exports.remote = remote;
exports.common = PageObjects.common;
exports.consolePage = PageObjects.console;
exports.dashboardPage = PageObjects.dashboard;
exports.discoverPage = PageObjects.discover;
exports.headerPage = PageObjects.header;
exports.settingsPage = PageObjects.settings;
exports.shieldPage = PageObjects.shield;
exports.visualizePage = PageObjects.visualize;
};

View file

@ -20,7 +20,7 @@ const visualizePage = new VisualizePage();
export default {
isInitialized: false,
init: function init(remote) {
init(remote) {
this.isInitialized = true;
this.remote = remote;
common.init(remote);
@ -33,7 +33,7 @@ export default {
visualizePage.init(remote);
},
checkInitialization() {
assertInitialized() {
if (this.isInitialized) {
return true;
}
@ -41,34 +41,34 @@ export default {
},
get common() {
return this.checkInitialization() && common;
return this.assertInitialized() && common;
},
get console() {
return this.checkInitialization() && consolePage;
return this.assertInitialized() && consolePage;
},
get dashboard() {
return this.checkInitialization() && dashboardPage;
return this.assertInitialized() && dashboardPage;
},
get discover() {
return this.checkInitialization() && discoverPage;
return this.assertInitialized() && discoverPage;
},
get header() {
return this.checkInitialization() && headerPage;
return this.assertInitialized() && headerPage;
},
get settings() {
return this.checkInitialization() && settingsPage;
return this.assertInitialized() && settingsPage;
},
get shield() {
return this.checkInitialization() && shieldPage;
return this.assertInitialized() && shieldPage;
},
get visualize() {
return this.checkInitialization() && visualizePage;
return this.assertInitialized() && visualizePage;
},
};