Fixing Jasmine tests in dashboard
We currently have two jasmine tests, one in horizon and one in dashboard. We currently use two different templates and they are out of sync with each other. Furthermore, we should extend the sources list, not override it, because dashboard modules depends on code in horizon. This patch fixes these issues. Closes-bug: #1452446 Change-Id: I3fcbb1ea30b5e83a16f94fb31959270bd393593a
This commit is contained in:
parent
ef11284817
commit
d833ddb9d4
@ -1,15 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Spec Runner Index</title>
|
||||
</head>
|
||||
<h1>Available tests</h1>
|
||||
<ul>
|
||||
{% for class_name in classes %}
|
||||
<li><a href="{{ class_name }}">{{ class_name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,85 +0,0 @@
|
||||
{% load url from future %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Spec Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}horizon/lib/jasmine/jasmine.css">
|
||||
|
||||
<script src="{% url 'horizon:jsi18n' 'horizon' %}"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/jasmine/jasmine.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/jasmine/jasmine-html.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/jasmine/boot.js"></script>
|
||||
<script src='{{ STATIC_URL }}horizon/lib/jquery/jquery.js'></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/angular.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-mocks.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-cookies.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-bootstrap.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-sanitize.js"></script>
|
||||
<script src="{{ STATIC_URL }}horizon/lib/angular/smart-table.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* Load angular modules extensions list before we include angular/horizon.js */
|
||||
var angularModuleExtension = {{ HORIZON_CONFIG.angular_modules|default:"[]"|safe }};
|
||||
</script>
|
||||
|
||||
<!-- source files -->
|
||||
{% for file in sources %}
|
||||
<script src="{{ STATIC_URL }}{{ file }}"></script>
|
||||
{% endfor %}
|
||||
|
||||
<!-- spec files -->
|
||||
{% for file in specs %}
|
||||
<script src="{{ STATIC_URL }}{{ file }}"></script>
|
||||
{% endfor %}
|
||||
|
||||
<!-- plugin source files -->
|
||||
{% for file in HORIZON_CONFIG.js_files %}
|
||||
<script src='{{ STATIC_URL }}{{ file }}'></script>
|
||||
{% endfor %}
|
||||
|
||||
<!-- plugin spec files -->
|
||||
{% for file in HORIZON_CONFIG.js_spec_files %}
|
||||
<script src='{{ STATIC_URL }}{{ file }}'></script>
|
||||
{% endfor %}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="main_content" class="hidden" style="visibility:hidden; height: 0">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () { 'use strict';
|
||||
|
||||
// Caching all external angular templates
|
||||
|
||||
var templates = [
|
||||
{% for externalTemplate in externalTemplates %}
|
||||
'{{ STATIC_URL }}{{ externalTemplate }}',
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
var tplmodule = angular.module('templates', []);
|
||||
|
||||
templates.forEach(function (template) {
|
||||
cacheTemplate(template, tplmodule);
|
||||
});
|
||||
|
||||
function cacheTemplate(template, tplmodule) {
|
||||
tplmodule.run(function ($templateCache) {
|
||||
$templateCache.put(template, loadSync(template));
|
||||
});
|
||||
}
|
||||
|
||||
function loadSync(url) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, false);
|
||||
xhr.send();
|
||||
return xhr.status === 200 ? xhr.responseText : null;
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -30,7 +30,7 @@ def dispatcher(request, test_name):
|
||||
if not test_name:
|
||||
return django.shortcuts.render(
|
||||
request,
|
||||
"jasmine/index.html",
|
||||
"horizon/jasmine/index.html",
|
||||
{'classes': (cls_name for cls_name, _ in classes)}
|
||||
)
|
||||
else:
|
||||
@ -39,7 +39,7 @@ def dispatcher(request, test_name):
|
||||
template = cls.template_name
|
||||
|
||||
if not template:
|
||||
template = "jasmine/jasmine.html"
|
||||
template = "horizon/jasmine/jasmine.html"
|
||||
|
||||
return django.shortcuts.render(
|
||||
request,
|
||||
|
@ -14,14 +14,16 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from horizon.test import helpers as test
|
||||
from horizon.test.jasmine import jasmine_tests as test
|
||||
|
||||
LAUNCH_INST = "dashboard/launch-instance"
|
||||
|
||||
|
||||
class ServicesTests(test.JasmineTests):
|
||||
# sources would go here
|
||||
sources = [
|
||||
class ServicesTests(test.ServicesTests):
|
||||
|
||||
# We rely on sources from horizon
|
||||
# therefore, we must append the sources
|
||||
dashboard_sources = [
|
||||
'dashboard/dashboard.module.js',
|
||||
'dashboard/workflow/workflow.js',
|
||||
LAUNCH_INST + '/launch-instance.js',
|
||||
@ -33,7 +35,9 @@ class ServicesTests(test.JasmineTests):
|
||||
LAUNCH_INST + '/network/network.js',
|
||||
LAUNCH_INST + '/source/source.js',
|
||||
]
|
||||
# spec files would go here
|
||||
|
||||
# We are only testing dashboard specs here
|
||||
# so we override the parent specs
|
||||
specs = [
|
||||
'dashboard/dashboard.module.js',
|
||||
'dashboard/workflow/workflow.js',
|
||||
@ -46,5 +50,8 @@ class ServicesTests(test.JasmineTests):
|
||||
LAUNCH_INST + '/network/network.spec.js',
|
||||
LAUNCH_INST + '/source/source.spec.js',
|
||||
]
|
||||
externalTemplates = [
|
||||
]
|
||||
externalTemplates = []
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(test.ServicesTests, self).__init__(*args, **kwargs)
|
||||
self.sources = self.sources.extend(self.dashboard_sources)
|
||||
|
Loading…
Reference in New Issue
Block a user