From a1fb3239f1636045701c4425457586d28597a53e Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 29 Aug 2016 18:46:39 -0700 Subject: [PATCH] remove config.set() call to avoid race 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. --- .../__tests__/directives/field_chooser.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js b/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js index 8f555b96b90d2..bbe845cf9a338 100644 --- a/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js +++ b/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js @@ -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); @@ -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 () { @@ -56,7 +50,21 @@ describe('discover field chooser directives', function () { '' ); - 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);