From 89efd7f6f6bc91fb3f0f92abbfdd8a3c00b6d6ba Mon Sep 17 00:00:00 2001 From: Cindy Lu Date: Fri, 29 Jul 2016 14:46:05 -0700 Subject: [PATCH] Fix jasmine test failures due to missing ngRoute, schema-form dep Resource Browser panel 2 jasmine test failure. Fix 2 tests with no expectation for http.spec.js. Remove undefined magic_search.js path in jasmine.html. Fix missing expectations in create.action.service.spec.js. Fix some formatting. Open up console for localhost:/jasmine/ before and after this patch to see the errors. Change-Id: I0ebd25dc50c2310e23ce8fed8f2a1adebc64ad15 Closes-Bug: #1615055 --- horizon/static/framework/util/http/http.spec.js | 16 ++++++++++++++-- .../framework/widgets/form/decorator.spec.js | 3 --- horizon/templates/horizon/jasmine/jasmine.html | 3 --- .../dashboard/developer/developer.module.js | 4 ++-- .../resource-browser/resource-browser.module.js | 7 ++++--- .../images/actions/create.action.service.spec.js | 5 ++++- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/horizon/static/framework/util/http/http.spec.js b/horizon/static/framework/util/http/http.spec.js index 35dc1c2b4b..5773e07e84 100644 --- a/horizon/static/framework/util/http/http.spec.js +++ b/horizon/static/framework/util/http/http.spec.js @@ -97,16 +97,28 @@ describe('WEBROOT handling', function() { it('respects WEBROOT by default', function() { var expectedUrl = WEBROOT + 'good'; + var $scope = {}; $httpBackend.when('GET', expectedUrl).respond(200, ''); $httpBackend.expect('GET', expectedUrl); - api.get('/good'); + api.get('/good').success(function() { + $scope.success = true; + }); + + $httpBackend.flush(); + expect($scope.success).toBe(true); }); it('ignores WEBROOT with external = true flag', function() { var expectedUrl = '/good'; + var $scope = {}; $httpBackend.when('GET', expectedUrl).respond(200, ''); $httpBackend.expect('GET', expectedUrl); - api.get('/good', {external: true}); + api.get('/good', {external: true}).success(function() { + $scope.success = true; + }); + + $httpBackend.flush(); + expect($scope.success).toBe(true); }); }); diff --git a/horizon/static/framework/widgets/form/decorator.spec.js b/horizon/static/framework/widgets/form/decorator.spec.js index 39072c45ed..2568ffa91f 100644 --- a/horizon/static/framework/widgets/form/decorator.spec.js +++ b/horizon/static/framework/widgets/form/decorator.spec.js @@ -31,9 +31,6 @@ expect(angular.module('schemaForm')).toBeDefined(); }); - it('should build tabs correctly', function() { - }); - it('should define messages for all the error codes', function() { // We don't need to check the specifics of each message in a test, // but we should check they all exist diff --git a/horizon/templates/horizon/jasmine/jasmine.html b/horizon/templates/horizon/jasmine/jasmine.html index 584471d64f..28684c470b 100644 --- a/horizon/templates/horizon/jasmine/jasmine.html +++ b/horizon/templates/horizon/jasmine/jasmine.html @@ -29,9 +29,6 @@ {% endfor %} - - - {% block source %} {% endblock %} diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js index 6f280a81a9..f94e0c1cb2 100644 --- a/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js @@ -40,7 +40,7 @@ * @description Base path for the developer dashboard */ function config($provide, $windowProvider) { - var path = $windowProvider.$get().STATIC_URL + 'dashboard/developer/'; - $provide.constant('horizon.dashboard.developer.basePath', path); + var path = $windowProvider.$get().STATIC_URL + 'dashboard/developer/'; + $provide.constant('horizon.dashboard.developer.basePath', path); } })(); diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/resource-browser/resource-browser.module.js b/openstack_dashboard/contrib/developer/static/dashboard/developer/resource-browser/resource-browser.module.js index 286adc8530..eede62e4c8 100644 --- a/openstack_dashboard/contrib/developer/static/dashboard/developer/resource-browser/resource-browser.module.js +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/resource-browser/resource-browser.module.js @@ -24,8 +24,9 @@ * Dashboard module for the resource-browser panel. */ angular - .module('horizon.dashboard.developer.resource-browser', [], config) - .constant('horizon.dashboard.developer.resource-browser.BASE_ROUTE', 'developer/resource_browser/'); + .module('horizon.dashboard.developer.resource-browser', ['ngRoute', 'schemaForm'], config) + .constant('horizon.dashboard.developer.resource-browser.BASE_ROUTE', + 'developer/resource_browser/'); config.$inject = [ '$windowProvider', @@ -43,4 +44,4 @@ }); } -})(); \ No newline at end of file +})(); diff --git a/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js b/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js index 97b8af7c44..188f6be661 100644 --- a/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js +++ b/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js @@ -199,7 +199,7 @@ source_type: 'url', image_url: 'http://somewhere'}); }); - it('should raise event even if update meta data fails', function() { + it('should raise event even if update metadata fails', function() { var image = { name: 'Test', id: '2' }; var failedPromise = function() { return { @@ -225,6 +225,9 @@ var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); $scope.$apply(); + + expect($scope.$emit).toHaveBeenCalledWith( + 'horizon.app.core.images.IMAGE_METADATA_CHANGED', undefined); }); it('should destroy the event watchers', function() {