Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced Settings test merge to 4.3 #5600

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"whatwg-fetch": "0.9.0"
},
"devDependencies": {
"@spalger/test-subj-selector": "0.2.1",
"Nonsense": "0.1.2",
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/kibana/public/settings/app.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="app-container">
<nav class="navbar navbar-default navbar-static-top subnav">
<nav class="navbar navbar-default navbar-static-top subnav" data-test-subj="settingsNav">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li ng-repeat="section in sections" ng-class="section.class">
<a class="navbar-link" kbn-href="{{section.url}}">{{section.display}}</a>
<a class="navbar-link" kbn-href="{{section.url}}" data-test-subj="{{section.name}}">{{section.display}}</a>
</li>
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tr ng-class="conf.value === undefined ? 'default' : 'custom'">
<tr ng-class="conf.value === undefined ? 'default' : 'custom'" data-test-subj="advancedSetting {{conf.name}}" >
<td class="name">
<b>{{conf.name}}</b>
<span class="smaller" ng-show="!conf.isCustom && conf.value !== undefined">
Expand Down Expand Up @@ -59,12 +59,13 @@
name="conf.name"
ng-model="conf.unsavedValue"
ng-options="option as option for option in conf.options"
class="form-control">
class="form-control"
data-test-subj="selectInput">
</select>
</form>

<!-- Setting display formats -->
<span ng-if="!conf.editting">
<span ng-if="!conf.editting" data-test-subj="currentValue">
<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.bool">{{conf.value === undefined ? conf.defVal : conf.value}}</span>
Expand All @@ -77,7 +78,8 @@
ng-click="edit(conf)"
class="btn btn-default"
ng-disabled="conf.tooComplex"
aria-label="Edit">
aria-label="Edit"
data-test-subj="editButton">
<span class="sr-only">Edit</span>
<i aria-hidden="true" class="fa fa-pencil"></i>
</button>
Expand All @@ -87,7 +89,8 @@
ng-click="save(conf)"
class="btn btn-success"
ng-disabled="conf.loading || conf.tooComplex || forms.configEdit.$invalid"
aria-label="Save">
aria-label="Save"
data-test-subj="saveButton">
<span class="sr-only">Save</span>
<i aria-hidden="true" ng-if="!conf.loading" class="fa fa-save"></i>
<i aria-hidden="true" ng-if="conf.loading" class="fa fa-spinner"></i>
Expand All @@ -98,7 +101,8 @@
ng-click="clear(conf)"
ng-hide="conf.value === undefined"
class="btn btn-danger"
aria-label="Clear">
aria-label="Clear"
data-test-subj="clearButton">
<span class="sr-only">Clear</span>
<i aria-hidden="true" class="fa fa-trash-o"></i>
</button>
Expand All @@ -107,7 +111,8 @@
ng-if="conf.editting"
ng-click="cancelEdit(conf)"
class="btn btn-default"
aria-label="Cancel edit">
aria-label="Cancel edit"
data-test-subj="cancelButton">
<span class="sr-only">Cancel Edit</span>
<i aria-hidden="true" class="fa fa-times"></i>
</button>
Expand Down
24 changes: 5 additions & 19 deletions src/ui/public/jquery/findTestSubject.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var testSubjSelector = require('@spalger/test-subj-selector');

module.exports = function bindToJquery($) {

/**
Expand Down Expand Up @@ -41,28 +43,12 @@ module.exports = function bindToJquery($) {
*/
$.fn.findTestSubject = findTestSubject;

function findTestSubject(/* ...subjectSelectors */) {
var subjectSelectors = [].slice.apply(arguments);
function findTestSubject(...subjectSelectors) {
var $els = $();
var $context = this;

subjectSelectors.forEach(function (subjectSelector) {
var cssSelectors = [];
var terms = subjectSelector
.replace(/\s*&\s*/g, '&') // remove all whitespace around joins
.split(/\s+/);

function termToCssSelector(term) {
return term ? '[data-test-subj~="' + term + '"]' : '';
}

while (terms.length) {
var term = terms.shift();
// split each term by joins/& and map to css selectors
cssSelectors.push(term.split('&').map(termToCssSelector).join(''));
}

$els = $els.add($context.find(cssSelectors.join(' ')));
subjectSelectors.forEach(function (selector) {
$els = $els.add($context.find(testSubjSelector(selector)));
});

return $els;
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/discover/_discover.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var HeaderPage = require('../../../support/pages/HeaderPage');
var SettingsPage = require('../../../support/pages/SettingsPage');
var SettingsPage = require('../../../support/pages/settings_page');
var DiscoverPage = require('../../../support/pages/DiscoverPage');
var expect = require('intern/dojo/node!expect.js');

Expand Down
45 changes: 45 additions & 0 deletions test/functional/apps/settings/_advanced_settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js');
var Promise = require('bluebird');

return function (bdd, scenarioManager) {
bdd.describe('creating and deleting default index', function describeIndexTests() {
var common;
var settingsPage;

bdd.before(function () {
common = new Common(this.remote);
settingsPage = new SettingsPage(this.remote);

return scenarioManager.reload('emptyKibana')
.then(function () {
return settingsPage.navigateTo();
});
});

bdd.describe('index pattern creation', function indexPatternCreation() {
bdd.before(function () {
return settingsPage.createIndexPattern();
});

bdd.it('should allow setting advanced settings', function () {
return settingsPage.clickAdvancedTab()
.then(function TestCallSetAdvancedSettingsForTimezone() {
common.log('calling setAdvancedSetting');
return settingsPage.setAdvancedSettings('dateFormat:tz', 'America/Phoenix');
})
.then(function GetAdvancedSetting() {
return settingsPage.getAdvancedSettings('dateFormat:tz');
})
.then(function (advancedSetting) {
expect(advancedSetting).to.be('America/Phoenix');
})
.catch(common.handleError(this));
});

});
});
};
});
2 changes: 1 addition & 1 deletion test/functional/apps/settings/_creation_form_changes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/SettingsPage');
var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js');

return function (bdd, scenarioManager) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/SettingsPage');
var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js');
var Promise = require('bluebird');

Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/settings/_index_pattern_popularity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/SettingsPage');
var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js');
//var Promise = require('bluebird');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
var config = require('intern').config;
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/SettingsPage');
var SettingsPage = require('../../../support/pages/settings_page');
var expect = require('intern/dojo/node!expect.js');
var Promise = require('bluebird');

Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/settings/_initial_state.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
var expect = require('intern/dojo/node!expect.js');
var Common = require('../../../support/pages/Common');
var SettingsPage = require('../../../support/pages/SettingsPage');
var SettingsPage = require('../../../support/pages/settings_page');

return function (bdd, scenarioManager) {
bdd.describe('initial state', function () {
Expand Down
2 changes: 2 additions & 0 deletions test/functional/apps/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define(function (require) {
var indexPatternCreateDeleteTest = require('./_index_pattern_create_delete');
var indexPatternResultsSortTest = require('./_index_pattern_results_sort');
var indexPatternPopularityTest = require('./_index_pattern_popularity');
var advancedSettingsTest = require('./_advanced_settings');

bdd.describe('settings app', function () {
var scenarioManager = new ScenarioManager(url.format(config.servers.elasticsearch));
Expand All @@ -30,6 +31,7 @@ define(function (require) {
});
});

advancedSettingsTest(bdd, scenarioManager);
initialStateTest(bdd, scenarioManager);
creationChangesTest(bdd, scenarioManager);
indexPatternCreateDeleteTest(bdd, scenarioManager);
Expand Down
6 changes: 6 additions & 0 deletions test/support/pages/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ define(function (require) {
var config = require('intern').config;
var Promise = require('bluebird');
var moment = require('moment');
var testSubjSelector = require('intern/dojo/node!@spalger/test-subj-selector');
var getUrl = require('intern/dojo/node!../../utils/getUrl');
var fs = require('intern/dojo/node!fs');
var path = require('intern/dojo/node!path');
Expand Down Expand Up @@ -199,6 +200,11 @@ define(function (require) {
.catch(function (err) {
self.log('SCREENSHOT FAILED: ' + err);
});
},

findTestSubject: function findTestSubject(selector) {
this.debug('in findTestSubject: ' + selector);
return this.remote.findByCssSelector(testSubjSelector(selector));
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// in test/support/pages/SettingsPage.js
// in test/support/pages/settings_page.js
define(function (require) {
var config = require('intern').config;
var Promise = require('bluebird');
Expand All @@ -7,13 +7,39 @@ define(function (require) {
var defaultTimeout = config.timeouts.default;
var common;

function SettingsPage(remote) {
function settingsPage(remote) {
this.remote = remote;
common = new Common(this.remote);
}

SettingsPage.prototype = {
constructor: SettingsPage,
settingsPage.prototype = {
constructor: settingsPage,

clickAdvancedTab: function () {
common.debug('in clickAdvancedTab');
return common.findTestSubject('settingsNav advanced').click();
},

setAdvancedSettings: function setAdvancedSettings(propertyName, propertyValue) {
var self = this;
return common.findTestSubject('advancedSetting&' + propertyName + ' editButton')
.click()
.then(function setAdvancedSettingsClickPropertyValue(selectList) {
return self.remote.findByCssSelector('option[label="' + propertyValue + '"]')
.click();
})
.then(function setAdvancedSettingsClickSaveButton() {
return common.findTestSubject('advancedSetting&' + propertyName + ' saveButton')
.click();
});
},

getAdvancedSettings: function getAdvancedSettings(propertyName) {
common.debug('in setAdvancedSettings');
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},


navigateTo: function () {
return common.navigateToApp('settings');
Expand Down Expand Up @@ -295,5 +321,5 @@ define(function (require) {
}
};

return SettingsPage;
return settingsPage;
});