Skip to content

Commit

Permalink
remove config.set() call to avoid race
Browse files Browse the repository at this point in the history
Several tests have been failing recently with "Error: Unexpected request: POST /api/kibana/settings/shortDots:enable, No more request expected" which seems to be caused by the field chooser tests calling `config.set('shortDots:enable', origValue)` in the test cleanup task. Rather than investigate it further I avoided the need to call `config.set()` by stubbing the `config.get()` method.
  • Loading branch information
spalger committed Aug 30, 2016
1 parent 5bbe02e commit a1fb323
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta

let $parentScope;
let $scope;
let config;
let hits;
let indexPattern;
let indexPatternList;
let shortDotsValue;

// Sets up the directive, take an element, and a list of properties to attach to the parent scope.
const init = function ($elem, props) {
ngMock.inject(function ($rootScope, $compile, $timeout, _config_) {
shortDotsValue = _config_.get('shortDots:enable');
config = _config_;
config.set('shortDots:enable', false);
ngMock.inject(function ($rootScope, $compile, $timeout) {
$parentScope = $rootScope;
_.assign($parentScope, props);
$compile($elem)($parentScope);
Expand All @@ -39,7 +34,6 @@ const init = function ($elem, props) {
const destroy = function () {
$scope.$destroy();
$parentScope.$destroy();
config.set('shortDots:enable', shortDotsValue);
};

describe('discover field chooser directives', function () {
Expand All @@ -56,7 +50,21 @@ describe('discover field chooser directives', function () {
'</disc-field-chooser>'
);

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.module('kibana', ($provide) => {
$provide.decorator('config', ($delegate) => {
// disable shortDots for these tests
$delegate.get = _.wrap($delegate.get, function (origGet, name) {
if (name === 'shortDots:enable') {
return false;
} else {
return origGet.call(this, name);
}
});

return $delegate;
});
}));

beforeEach(ngMock.inject(function (Private) {
hits = Private(FixturesHitsProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
Expand Down

0 comments on commit a1fb323

Please sign in to comment.