Drop QUnit JS tests in favor of Jasmine

Add `Instance`, `Tables`, `Templates`, `Messages`,
`Modals` Jasmine tests. Removed corresponding `Qunit`
javascript tests and dependencies on qunit library.

Partial-Bug: #1475387
Implements: blueprint replace-qunit-tests-with-jasmine
Change-Id: Ia415b65fb7b6299934c99e62a8c1f7225b93b03b
This commit is contained in:
Vlad Okhrimenko 2015-07-07 11:16:14 +03:00 committed by Timur Sufiev
parent 8ede6555af
commit 274921e8b4
16 changed files with 276 additions and 280 deletions

View File

@ -44,7 +44,8 @@ urlpatterns += patterns(
if settings.DEBUG:
urlpatterns += patterns(
'',
url(r'^qunit/$',
TemplateView.as_view(template_name="horizon/qunit.html"),
name='qunit_tests'),
url(r'^jasmine-legacy/$',
TemplateView.as_view(
template_name="horizon/jasmine/jasmine_legacy.html"),
name='jasmine_tests'),
url(r'^jasmine/.*?$', jasmine.dispatcher))

View File

@ -1,8 +1,6 @@
module("Instances (horizon.instances.js)");
test("decrypt password ", function () {
var encPassword, privateKey, password;
encPassword = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
describe('Instances (horizon.instances.js)', function () {
var password;
var enc_password = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
"i8Bo64WOspsgjBQwC9onGX5pHwbgZdtintG1QNiDTafNbtNNbRoZQwO" +
"4Zm3Liiw9ymDdiy1GNwMduFiRP9WG5N4QE3TP3ChnWnVGYQE/QoHqa/" +
"7e43LXYvLULQA7tQ7JxhJruRZVt/tskPJGEbgpyjiA3gECjFi12BAKD" +
@ -10,7 +8,7 @@ test("decrypt password ", function () {
"LXZhGaZgMRVKnKREkkTxfmLWtdY5lsWP4dnvHama+k9Ku8LQ+n4qB07" +
"jFVAUmRkpbdDPJ9Nxtlep0g==";
privateKey = "-----BEGIN RSA PRIVATE KEY-----" +
var private_key_1 = "-----BEGIN RSA PRIVATE KEY-----" +
"MIIEpAIBAAKCAQEAtY2Be8SoiE5XD/p7WaO2dKUES5iI4l4YAJ1FfpLGsT5mkC1t" +
"7Zl0QTMVMdUNYH7ERIKNv8OSZ/wmm716iStiYPzwjyXUA8uVQuoprUr8hPOeNeHK" +
"f1Nt7F87EPHk/n0VkLsUGZnwxVV1X3hgKS/f2gyPjkKwC+LOTMx81k65kp0a0Qt4" +
@ -38,21 +36,7 @@ test("decrypt password ", function () {
"3ns5u8JfZ0JobJ5JxiKHS3UOqfe9DV2pvVSyF3nLl8I0WPMgoEXrLw==" +
"-----END RSA PRIVATE KEY-----";
password = horizon.instances.decrypt_password(encPassword, privateKey);
ok(password === "kLhfIDlK5e7v12");
});
test("decrypt password fake key", function () {
var encPassword, privateKey, password;
encPassword = "dusPDCoY0u7PqDgVE6M+XicV+8V1qQkuPipM+KoCJ5cS" +
"i8Bo64WOspsgjBQwC9onGX5pHwbgZdtintG1QNiDTafNbtNNbRoZQwO" +
"4Zm3Liiw9ymDdiy1GNwMduFiRP9WG5N4QE3TP3ChnWnVGYQE/QoHqa/" +
"7e43LXYvLULQA7tQ7JxhJruRZVt/tskPJGEbgpyjiA3gECjFi12BAKD" +
"3RKF2dA+kMzv65ZeKi/ux/2cTQEu83hk1kgWihx2jl0+5rnWSOrl6WR" +
"LXZhGaZgMRVKnKREkkTxfmLWtdY5lsWP4dnvHama+k9Ku8LQ+n4qB07" +
"jFVAUmRkpbdDPJ9Nxtlep0g==";
privateKey = "-----BEGIN RSA PRIVATE KEY-----" +
var private_key_2 = "-----BEGIN RSA PRIVATE KEY-----" +
"MIIEpAIBAAKCAQEAtY2Be8SoiE5XD/p7WaO2dKUES5iI4l4YAJ1FfpLGsT5mkC1t" +
"Lq3//CLBSnm7gWdOsdU4rBn1khGKrlNdpvIjwkbMYtGlhjbvtwX3JbLlC8If9U00" +
"NbobtwKBgQCxp5+NmeU+NHXeG4wFLyT+hkZncapmV8QvlYmqMuEC6G2rjmplobgX" +
@ -60,6 +44,13 @@ test("decrypt password fake key", function () {
"3ns5u8JfZ0JobJ5JxiKHS3UOqfe9DV2pvVSyF3nLl8I0WPMgoEXrLw==" +
"-----END RSA PRIVATE KEY-----";
password = horizon.instances.decrypt_password(encPassword, privateKey);
ok(password === false || password === null);
});
it("decrypt password", function () {
password = horizon.instances.decrypt_password(enc_password, private_key_1);
expect(password).toEqual("kLhfIDlK5e7v12");
});
it("decrypt password fake key", function () {
password = horizon.instances.decrypt_password(enc_password, private_key_2);
expect(password).toBe(false);
});
});

View File

@ -0,0 +1,38 @@
describe("Messages (horizon.messages.js)", function () {
var message, message2;
it("Basic Alert", function () {
message = horizon.alert("success", "A message!");
expect(message.hasClass("alert-success")).toBe(true);
expect($('#main_content .messages .alert').length).toEqual(1);
horizon.clearAllMessages();
expect($('#main_content .messages .alert').length).toEqual(0);
});
it("Multiple Alerts", function () {
message = horizon.alert("error", "An error!");
expect(message.hasClass("alert-danger")).toBe(true);
message2 = horizon.alert("success", "Another message");
expect($('#main_content .messages .alert').length).toEqual(2);
horizon.clearErrorMessages();
expect($('#main_content .messages .alert-danger').length).toEqual(0);
expect($('#main_content .messages .alert').length).toEqual(1);
horizon.clearSuccessMessages();
expect($('#main_content .messages .alert-success').length).toEqual(0);
expect($('#main_content .messages .alert').length).toEqual(0);
});
it("Alert With HTML Tag", function () {
var safe_string = "A safe message <a>here</a>!";
message = horizon.alert("success", safe_string, "safe");
expect(message.length).toEqual(1);
expect(message.html().indexOf(safe_string)).not.toEqual(-1);
expect($('#main_content .messages .alert').length).toEqual(1);
horizon.clearAllMessages();
expect($('#main_content .messages .alert').length).toEqual(0);
});
});

View File

@ -0,0 +1,25 @@
describe("Modals (horizon.modals.js)", function () {
var modal, title, body, confirm;
beforeEach(function () {
title = "Test Title";
body = "<p>Test Body</p>";
confirm = "Test Confirm";
});
it("Modal Creation", function () {
modal = horizon.modals.create(title, body, confirm);
expect(modal.length).toEqual(1);
modal = $("#modal_wrapper .modal");
modal.modal();
expect(modal.length).toEqual(1);
expect(modal.hasClass("in")).toBe(true);
expect(modal.find("h3").text()).toEqual(title);
expect(modal.find(".modal-body").text().trim()).toEqual(body);
expect(modal.find(".modal-footer .btn-primary").text()).toEqual(confirm);
modal.find(".modal-footer .cancel").click();
expect(modal.hasClass("in")).toBe(false);
});
});

View File

@ -0,0 +1,122 @@
describe("Tables (horizon.tables.js)", function () {
describe("can hide or reveal column,", function () {
var fixture, table;
beforeEach(function () {
fixture = $("#jasmine-fixture");
table = fixture.find("#table2");
});
it("with a default behaviour.", function () {
expect(table.find(".cat").is(":hidden")).toBe(false);
expect(table.find(":not(.cat)").is(":hidden")).toBe(true);
});
it("by activating a filter.", function () {
$("#button_dogs").trigger("click");
expect(table.find(".dog").is(":hidden")).toBe(false);
expect(table.find(":not(.dog)").is(":hidden")).toBe(true);
$("#button_big").trigger("click");
expect(table.find(".big").is(":hidden")).toBe(false);
expect(table.find(":not(.big)").is(":hidden")).toBe(true);
$("#button_cats").trigger("click");
expect(table.find(".cat").is(":hidden")).toBe(false);
expect(table.find(":not(.cat)").is(":hidden")).toBe(true);
});
});
describe("can provide a footer counter,", function () {
var table, tbody, table_count, rows;
beforeEach(function () {
table = $("#table1");
tbody = table.find('tbody');
table_count = table.find("span.table_count");
rows = tbody.find('tr');
});
it("which count the number of items.", function () {
horizon.datatables.update_footer_count(table);
expect(table_count.text()).toContain('4 items');
});
it("which can be updated", function () {
rows.first().hide();
rows.first().next().hide();
horizon.datatables.update_footer_count(table);
expect(table_count.text()).toContain('2 items');
rows.first().next().show();
horizon.datatables.update_footer_count(table);
expect(table_count.text()).toContain('3 items');
$('<tr><td>cat3</td></tr>"').appendTo(tbody);
$('<tr><td>cat4</td></tr>"').appendTo(tbody);
horizon.datatables.update_footer_count(table);
expect(table_count.text()).toContain('5 items');
});
});
describe("Formset rows:", function () {
var html, table, input, row, empty_row_html, x;
beforeEach(function () {
html = $('#formset');
table = html.find('table');
row = table.find('tbody tr').first();
});
it("reenumerate", function () {
input = table.find('tbody tr#flavors__row__14 input').first();
input.attr('id', 'id_flavors-3-name');
horizon.formset_table.reenumerate_rows(table, 'flavors');
expect(input.attr('id')).toEqual('id_flavors-0-name');
input.attr('id', 'id_flavors-__prefix__-name');
horizon.formset_table.reenumerate_rows(table, 'flavors');
expect(input.attr('id')).toEqual('id_flavors-0-name');
});
it("delete", function () {
input = row.find('input#id_flavors-0-DELETE');
expect(row.css("display")).toEqual('table-row');
expect(input.attr('checked')).toEqual(undefined);
horizon.formset_table.replace_delete(row);
x = input.next('a');
horizon.formset_table.delete_row.call(x);
expect(row.css("display")).toEqual('none');
expect(input.attr('checked')).toEqual('checked');
});
it("add", function () {
empty_row_html = '<tr><td><input id="id_flavors-__prefix__-name" name="flavors-__prefix__-name"></td></tr>';
expect(table.find('tbody tr').length).toEqual(3);
expect(html.find('#id_flavors-TOTAL_FORMS').val()).toEqual("3");
horizon.formset_table.add_row(table, 'flavors', empty_row_html);
expect(table.find('tbody tr').length).toEqual(4);
expect(table.find('tbody tr:last input').attr('id')).toEqual('id_flavors-3-name');
expect(html.find('#id_flavors-TOTAL_FORMS').val()).toEqual("4");
});
});
describe("Init formset table", function () {
var html, table;
beforeEach(function () {
html = $('#formset');
table = html.find('table');
});
it("add row", function () {
horizon.formset_table.init('flavors', '', 'Add row');
expect(table.find('tfoot tr a').html()).toEqual('Add row');
});
it("no add row", function () {
$('tfoot tr a').remove();
horizon.formset_table.init('flavors', '', '');
expect(table.find('tfoot tr a').length).toEqual(0);
});
});
});

View File

@ -0,0 +1,9 @@
describe("Client-Side Templating (horizon.templates.js)", function () {
it("Compiled templates list should not be empty.", function () {
var size = 0;
angular.forEach(horizon.templates.compiled_templates, function () {
size = size + 1;
});
expect(size).toBeGreaterThan(0);
});
});

View File

@ -1,50 +0,0 @@
horizon.addInitFunction(function () {
module("Messages (horizon.messages.js)");
var message, message2;
test("Basic Alert", function () {
message = horizon.alert("success", "A message!");
ok(message, "Create a success message.");
ok(message.hasClass("alert-success"),
'Verify the message has the "alert-success" class.');
equal($('#main_content .messages .alert').length, 1,
"Verify our message was added to the DOM.");
horizon.clearAllMessages();
equal($('#main_content .messages .alert').length, 0,
"Verify our message was removed.");
});
test("Multiple Alerts", function () {
message = horizon.alert("error", "An error!");
ok(message.hasClass("alert-danger"),
'Verify the first message has the "alert-danger" class.');
message2 = horizon.alert("success", "Another message");
equal($('#main_content .messages .alert').length, 2,
"Verify two messages have been added to the DOM.");
horizon.clearErrorMessages();
equal($('#main_content .messages .alert-danger').length, 0,
"Verify our error message was removed.");
equal($('#main_content .messages .alert').length, 1,
"Verify one message remains.");
horizon.clearSuccessMessages();
equal($('#main_content .messages .alert-success').length, 0,
"Verify our success message was removed.");
equal($('#main_content .messages .alert').length, 0,
"Verify no messages remain.");
});
test("Alert With HTML Tag", function () {
var safeString = "A safe message <a>here</a>!";
message = horizon.alert("success", safeString, "safe");
ok(message, "Create a message with extra tag.");
ok((message.html().indexOf(safeString) !== -1),
"Verify the message with HTML tag was not escaped.");
equal($('#main_content .messages .alert').length, 1,
"Verify our message was added to the DOM.");
horizon.clearAllMessages();
equal($('#main_content .messages .alert').length, 0,
"Verify our message was removed.");
});
});

View File

@ -1,25 +0,0 @@
horizon.addInitFunction(function () {
module("Modals (horizon.modals.js)");
test("Modal Creation", function () {
var modal;
var title = "Test Title";
var body = "<p>Test Body</p>";
var confirm = "Test Confirm";
modal = horizon.modals.create(title, body, confirm);
ok(modal, "Verify our modal was created.");
modal = $("#modal_wrapper .modal");
modal.modal();
equal(modal.length, 1, "Verify our modal was added to the DOM.");
ok(modal.hasClass("in"), "Verify our modal is not hidden.");
equal(modal.find("h3").text(), title,
"Verify the title was added correctly.");
equal(modal.find(".modal-body").text().trim(), body,
"Verify the body was added correctly.");
equal(modal.find(".modal-footer .btn-primary").text(), confirm,
"Verify the footer confirm button was added correctly.");
modal.find(".modal-footer .cancel").click();
ok(!modal.hasClass("in"), "Verify our modal is hidden.");
});
});

View File

@ -1,115 +0,0 @@
module("Tables (horizon.tables.js)");
test("Row filtering (fixed)", function () {
var fixture = $("#qunit-fixture");
var table = fixture.find("#table2");
ok(!table.find(".cat").is(":hidden"), "Filtering cats: cats visible by default");
ok(table.find(":not(.cat)").is(":hidden"), "Filtering cats: non-cats hidden by default");
$("#button_cats").trigger("click");
ok(!table.find(".cat").is(":hidden"), "Filtering cats: cats visible");
ok(table.find(":not(.cat)").is(":hidden"), "Filtering cats: non-cats hidden");
$("#button_dogs").trigger("click");
ok(!table.find(".dog").is(":hidden"), "Filtering dogs: dogs visible");
ok(table.find(":not(.dog)").is(":hidden"), "Filtering dogs: non-dogs hidden");
$("#button_big").trigger("click");
ok(!table.find(".big").is(":hidden"), "Filtering big animals: big visible");
ok(table.find(":not(.big)").is(":hidden"), "Filtering big animals: non-big hidden");
});
test("Footer count update", function () {
var fixture = $("#qunit-fixture");
var table = fixture.find("#table1");
var tbody = table.find('tbody');
var tableCount = table.find("span.table_count");
var rows = tbody.find('tr');
// The following function returns the first set of consecutive numbers.
// This is allows you to match an inner numeric value regardless of
// the language and regardless of placement within the phrase.
// If you want to match '4' for your numeric value, the following are ok:
// "there are 4 lights", "4 lights there are", "lights there are 4" but
// not "there are 14 lights".
var getConsecNums = function(str) { return (str.match(/\d+/) || [""])[0]; };
horizon.datatables.update_footer_count(table);
equal(getConsecNums(tableCount.text()), '4', "Initial count is correct");
// hide rows
rows.first().hide();
rows.first().next().hide();
horizon.datatables.update_footer_count(table);
equal(getConsecNums(tableCount.text()), '2', "Count correct after hiding two rows");
// show a row
rows.first().next().show();
horizon.datatables.update_footer_count(table);
equal(getConsecNums(tableCount.text()), '3', "Count correct after showing one row");
// add rows
$('<tr><td>cat3</td></tr>"').appendTo(tbody);
$('<tr><td>cat4</td></tr>"').appendTo(tbody);
horizon.datatables.update_footer_count(table);
equal(getConsecNums(tableCount.text()), '5', "Count correct after adding two rows");
});
test("Formset reenumerate rows", function () {
var html = $('#formset');
var table = html.find('table');
var input = table.find('tbody tr#flavors__row__14 input').first();
input.attr('id', 'id_flavors-3-name');
horizon.formset_table.reenumerate_rows(table, 'flavors');
equal(input.attr('id'), 'id_flavors-0-name', "Enumerate old rows ids");
input.attr('id', 'id_flavors-__prefix__-name');
horizon.formset_table.reenumerate_rows(table, 'flavors');
equal(input.attr('id'), 'id_flavors-0-name', "Enumerate new rows ids");
});
test("Formset delete row", function () {
var html = $('#formset');
var table = html.find('table');
var row = table.find('tbody tr').first();
var input = row.find('input#id_flavors-0-DELETE');
equal(row.css("display"), 'table-row');
equal(input.attr('checked'), undefined);
horizon.formset_table.replace_delete(row);
var x = input.next('a');
horizon.formset_table.delete_row.call(x);
equal(row.css("display"), 'none');
equal(input.attr('checked'), 'checked');
});
test("Formset add row", function() {
var html = $('#formset');
var table = html.find('table');
var emptyRowHtml = '<tr><td><input id="id_flavors-__prefix__-name" ' +
'name="flavors-__prefix__-name"></td></tr>';
equal(table.find('tbody tr').length, 3);
equal(html.find('#id_flavors-TOTAL_FORMS').val(), 3);
horizon.formset_table.add_row(table, 'flavors', emptyRowHtml);
equal(table.find('tbody tr').length, 4);
equal(table.find('tbody tr:last input').attr('id'), 'id_flavors-3-name');
equal(html.find('#id_flavors-TOTAL_FORMS').val(), 4);
});
test("Init formset table", function() {
var html = $('#formset');
var table = html.find('table');
horizon.formset_table.init('flavors', '', 'Add row');
equal(table.find('tfoot tr a').html(), 'Add row');
});
test("Init formset table -- no add", function() {
var html = $('#formset');
var table = html.find('table');
horizon.formset_table.init('flavors', '', '');
equal(table.find('tfoot tr a').length, 0);
});

View File

@ -1,11 +0,0 @@
horizon.addInitFunction(function () {
module("Client-Side Templating (horizon.templates.js)");
test("Template Compilation", function () {
var size = 0;
angular.forEach(horizon.templates.compiled_templates, function () {
size = size + 1;
});
ok(size > 0, "Compiled templates list should not be empty.");
});
});

View File

@ -40,10 +40,15 @@
<!-- Magic Search library must be after magic-search override widget -->
<script src="{{ STATIC_URL }}horizon/lib/magic_search/magic_search.js"></script>
{% block source %}
{% endblock %}
<!-- test files - mock and spec -->
{% for file in HORIZON_CONFIG.js_spec_files %}
<script src='{{ STATIC_URL }}{{ file }}'></script>
{% endfor %}
{% block spec %}
{% for file in HORIZON_CONFIG.js_spec_files %}
<script src='{{ STATIC_URL }}{{ file }}'></script>
{% endfor %}
{% endblock %}
</head>
<body>

View File

@ -1,31 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Horizon QUnit Test Suite</title>
<link rel="stylesheet" href="{{ STATIC_URL }}horizon/lib/qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="{{ STATIC_URL }}horizon/lib/jquery/jquery.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/lib/qunit/qunit.js"></script>
{% include "horizon/_conf.html" %}
{% extends "horizon/jasmine/jasmine.html" %}
{% comment %}Load test modules here.{% endcomment %}
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/modals.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/templates.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/tables.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/instances.js"></script>
{% comment %}End test modules.{% endcomment %}
{% block source %}
<!-- Instead include all "horizon/_scripts.html" -->
{% include "horizon/_script_i18n.html" %}
{% include "horizon/_scripts.html" %}
</head>
<body ng-app="hz">
<h1 id="qunit-header">Horizon JavaScript Tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<script src="{{ STATIC_URL }}bootstrap/js/bootstrap.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/jquery/jquery.tablesorter.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/hogan.js"></script>
<script src='{{ STATIC_URL }}horizon/lib/jsencrypt/jsencrypt.js'></script>
<script src="{{ STATIC_URL }}horizon/js/horizon.templates.js"></script>
<script src="{{ STATIC_URL }}horizon/js/horizon.instances.js"></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.tabs.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.forms.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.formset_table.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.messages.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.modals.js'></script>
<script src='{{ STATIC_URL }}horizon/js/horizon.tables.js'></script>
{% include "horizon/client_side/templates.html" %}
<script>
// Call init on DOM ready.
$(document).ready(horizon.init);
</script>
<!-- The end -->
{% endblock %}
{% block spec %}
<!-- test files -->
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/jasmine/modals.legacy-spec.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/jasmine/templates.legacy-spec.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/jasmine/tables.legacy-spec.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/jasmine/instances.legacy-spec.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}horizon/tests/jasmine/messages.legacy-spec.js"></script>
{% endblock %}
{% block content %}
<div id="jasmine-fixture">
<!-- Test markup; will be hidden. -->
<div id="main_content">
<div class="messages"></div>
<div id="modal_wrapper"></div>
@ -55,9 +67,9 @@
</div></th></tr></thead>
<tbody>
<tr class="category-cat"><td>cat1</td></tr>
<tr class="category-big category-dog"><td>dog1</td></tr>
<tr class="category-big category-cat"><td>cat2</td></tr>
<tr class="category-dog"><td>dog2</td></tr>
<tr class="category-big category-dog" style="display: none"><td>dog1</td></tr>
<tr class="category-big category-cat" style="display: none"><td>cat2</td></tr>
<tr class="category-dog" style="display: none"><td>dog2</td></tr>
</tbody>
<tfoot>
<tr>
@ -226,7 +238,6 @@
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</body>
</html>
{% endblock %}

View File

@ -18,17 +18,16 @@ from horizon.test import helpers as test
class BrowserTests(test.SeleniumTestCase):
def test_qunit(self):
self.selenium.get("%s%s" % (self.live_server_url, "/qunit/"))
wait = self.ui.WebDriverWait(self.selenium, 120)
def test_jasmine_legacy(self):
self.selenium.get("%s%s" % (self.live_server_url,
"/jasmine-legacy/"))
wait = self.ui.WebDriverWait(self.selenium, 30)
def qunit_done(driver):
text = driver.find_element_by_id("qunit-testresult").text
return "Tests completed" in text
def jasmine_legacy_done(driver):
failures = driver.find_element_by_class_name("bar").text
return failures
wait.until(qunit_done)
failed = self.selenium.find_element_by_class_name("failed")
self.assertEqual(int(failed.text), 0)
self.assertTrue('0 failures' in wait.until(jasmine_legacy_done))
@override_settings(

View File

@ -37,10 +37,11 @@ urlpatterns = patterns(
{'template_name': "auth/login.html"},
name='login'),
url(r'auth/', include('django.contrib.auth.urls')),
url(r'^qunit/$',
TemplateView.as_view(template_name="horizon/qunit.html"),
name='qunit_tests'),
url(r'^jasmine/.*?$', jasmine.dispatcher)
url(r'^jasmine/.*?$', jasmine.dispatcher),
url(r'^jasmine-legacy/$',
TemplateView.as_view(
template_name="horizon/jasmine/jasmine_legacy.html"),
name='jasmine_tests'),
)
urlpatterns += staticfiles_urlpatterns()

View File

@ -38,7 +38,6 @@ import xstatic.pkg.jquery_tablesorter
import xstatic.pkg.jquery_ui
import xstatic.pkg.jsencrypt
import xstatic.pkg.magic_search
import xstatic.pkg.qunit
import xstatic.pkg.rickshaw
import xstatic.pkg.spin
import xstatic.pkg.termjs
@ -99,9 +98,6 @@ def get_staticfiles_dirs(webroot='/'):
('horizon/lib/magic_search',
xstatic.main.XStatic(xstatic.pkg.magic_search,
root_url=webroot).base_dir),
('horizon/lib/qunit',
xstatic.main.XStatic(xstatic.pkg.qunit,
root_url=webroot).base_dir),
('horizon/lib',
xstatic.main.XStatic(xstatic.pkg.rickshaw,
root_url=webroot).base_dir),

View File

@ -59,7 +59,6 @@ XStatic-JQuery.TableSorter>=2.14.5.1 # MIT License
XStatic-jquery-ui>=1.10.1 # MIT License
XStatic-JSEncrypt>=2.0.0.2 # MIT License
XStatic-Magic-Search>=0.2.5.1 # Apache 2.0 License
XStatic-QUnit>=1.14.0.2 # MIT License
XStatic-Rickshaw>=1.5.0 # BSD License (prior)
XStatic-smart-table>=1.4.5.3 # MIT License
XStatic-Spin>=1.2.5.2 # MIT License