From 274921e8b480fe718c3e359e24aa716fc0bdf2f3 Mon Sep 17 00:00:00 2001 From: Vlad Okhrimenko Date: Tue, 7 Jul 2015 11:16:14 +0300 Subject: [PATCH] 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 --- horizon/site_urls.py | 7 +- .../instances.legacy-spec.js} | 39 +++--- .../tests/jasmine/messages.legacy-spec.js | 38 ++++++ .../tests/jasmine/modals.legacy-spec.js | 25 ++++ .../tests/jasmine/tables.legacy-spec.js | 122 ++++++++++++++++++ .../tests/jasmine/templates.legacy-spec.js | 9 ++ horizon/static/horizon/tests/messages.js | 50 ------- horizon/static/horizon/tests/modals.js | 25 ---- horizon/static/horizon/tests/tables.js | 115 ----------------- horizon/static/horizon/tests/templates.js | 11 -- .../templates/horizon/jasmine/jasmine.html | 11 +- .../jasmine_legacy.html} | 73 ++++++----- horizon/test/tests/selenium_tests.py | 17 ++- horizon/test/urls.py | 9 +- openstack_dashboard/static_settings.py | 4 - requirements.txt | 1 - 16 files changed, 276 insertions(+), 280 deletions(-) rename horizon/static/horizon/tests/{instances.js => jasmine/instances.legacy-spec.js} (71%) create mode 100644 horizon/static/horizon/tests/jasmine/messages.legacy-spec.js create mode 100644 horizon/static/horizon/tests/jasmine/modals.legacy-spec.js create mode 100644 horizon/static/horizon/tests/jasmine/tables.legacy-spec.js create mode 100644 horizon/static/horizon/tests/jasmine/templates.legacy-spec.js delete mode 100644 horizon/static/horizon/tests/messages.js delete mode 100644 horizon/static/horizon/tests/modals.js delete mode 100644 horizon/static/horizon/tests/tables.js delete mode 100644 horizon/static/horizon/tests/templates.js rename horizon/templates/horizon/{qunit.html => jasmine/jasmine_legacy.html} (78%) diff --git a/horizon/site_urls.py b/horizon/site_urls.py index 2f3fbaa75..3fa3f6062 100644 --- a/horizon/site_urls.py +++ b/horizon/site_urls.py @@ -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)) diff --git a/horizon/static/horizon/tests/instances.js b/horizon/static/horizon/tests/jasmine/instances.legacy-spec.js similarity index 71% rename from horizon/static/horizon/tests/instances.js rename to horizon/static/horizon/tests/jasmine/instances.legacy-spec.js index bfc2ca64d..384b56206 100644 --- a/horizon/static/horizon/tests/instances.js +++ b/horizon/static/horizon/tests/jasmine/instances.legacy-spec.js @@ -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); + }); +}); \ No newline at end of file diff --git a/horizon/static/horizon/tests/jasmine/messages.legacy-spec.js b/horizon/static/horizon/tests/jasmine/messages.legacy-spec.js new file mode 100644 index 000000000..890eae419 --- /dev/null +++ b/horizon/static/horizon/tests/jasmine/messages.legacy-spec.js @@ -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 here!"; + 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); + }); +}); \ No newline at end of file diff --git a/horizon/static/horizon/tests/jasmine/modals.legacy-spec.js b/horizon/static/horizon/tests/jasmine/modals.legacy-spec.js new file mode 100644 index 000000000..e40812ace --- /dev/null +++ b/horizon/static/horizon/tests/jasmine/modals.legacy-spec.js @@ -0,0 +1,25 @@ +describe("Modals (horizon.modals.js)", function () { + var modal, title, body, confirm; + + beforeEach(function () { + title = "Test Title"; + body = "

Test Body

"; + 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); + }); +}); diff --git a/horizon/static/horizon/tests/jasmine/tables.legacy-spec.js b/horizon/static/horizon/tests/jasmine/tables.legacy-spec.js new file mode 100644 index 000000000..6f6ecccc3 --- /dev/null +++ b/horizon/static/horizon/tests/jasmine/tables.legacy-spec.js @@ -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'); + + $('cat3"').appendTo(tbody); + $('cat4"').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 = ''; + 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); + }); + }); +}); \ No newline at end of file diff --git a/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js b/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js new file mode 100644 index 000000000..0b15aea72 --- /dev/null +++ b/horizon/static/horizon/tests/jasmine/templates.legacy-spec.js @@ -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); + }); +}); \ No newline at end of file diff --git a/horizon/static/horizon/tests/messages.js b/horizon/static/horizon/tests/messages.js deleted file mode 100644 index cc7d9f377..000000000 --- a/horizon/static/horizon/tests/messages.js +++ /dev/null @@ -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 here!"; - 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."); - }); -}); diff --git a/horizon/static/horizon/tests/modals.js b/horizon/static/horizon/tests/modals.js deleted file mode 100644 index 36e068cf1..000000000 --- a/horizon/static/horizon/tests/modals.js +++ /dev/null @@ -1,25 +0,0 @@ -horizon.addInitFunction(function () { - module("Modals (horizon.modals.js)"); - - test("Modal Creation", function () { - var modal; - var title = "Test Title"; - var body = "

Test Body

"; - 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."); - }); -}); diff --git a/horizon/static/horizon/tests/tables.js b/horizon/static/horizon/tests/tables.js deleted file mode 100644 index d5c325aa9..000000000 --- a/horizon/static/horizon/tests/tables.js +++ /dev/null @@ -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 - $('cat3"').appendTo(tbody); - $('cat4"').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 = ''; - - 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); -}); diff --git a/horizon/static/horizon/tests/templates.js b/horizon/static/horizon/tests/templates.js deleted file mode 100644 index e36bec36d..000000000 --- a/horizon/static/horizon/tests/templates.js +++ /dev/null @@ -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."); - }); -}); diff --git a/horizon/templates/horizon/jasmine/jasmine.html b/horizon/templates/horizon/jasmine/jasmine.html index 1e20df6aa..963335b5c 100644 --- a/horizon/templates/horizon/jasmine/jasmine.html +++ b/horizon/templates/horizon/jasmine/jasmine.html @@ -40,10 +40,15 @@ + {% block source %} + {% endblock %} + - {% for file in HORIZON_CONFIG.js_spec_files %} - - {% endfor %} + {% block spec %} + {% for file in HORIZON_CONFIG.js_spec_files %} + + {% endfor %} + {% endblock %} diff --git a/horizon/templates/horizon/qunit.html b/horizon/templates/horizon/jasmine/jasmine_legacy.html similarity index 78% rename from horizon/templates/horizon/qunit.html rename to horizon/templates/horizon/jasmine/jasmine_legacy.html index 49e99d1eb..932ced5d9 100644 --- a/horizon/templates/horizon/qunit.html +++ b/horizon/templates/horizon/jasmine/jasmine_legacy.html @@ -1,31 +1,43 @@ - - - - - Horizon QUnit Test Suite - - - - {% include "horizon/_conf.html" %} +{% extends "horizon/jasmine/jasmine.html" %} - {% comment %}Load test modules here.{% endcomment %} - - - - - {% comment %}End test modules.{% endcomment %} +{% block source %} + + {% include "horizon/_script_i18n.html" %} - {% include "horizon/_scripts.html" %} - - -

Horizon JavaScript Tests

-

-
-

-
    -
    + + + + + + + + + + + + + + {% include "horizon/client_side/templates.html" %} + + + +{% endblock %} + +{% block spec %} + + + + + + +{% endblock %} + +{% block content %} +
    -
    @@ -55,9 +67,9 @@
    cat1 - dog1 - cat2 - dog2 + dog1 + cat2 + dog2 @@ -226,7 +238,6 @@ -
    +
    - - +{% endblock %} diff --git a/horizon/test/tests/selenium_tests.py b/horizon/test/tests/selenium_tests.py index 6a16e971d..46410c469 100644 --- a/horizon/test/tests/selenium_tests.py +++ b/horizon/test/tests/selenium_tests.py @@ -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( diff --git a/horizon/test/urls.py b/horizon/test/urls.py index 7a5ebada6..74c14c632 100644 --- a/horizon/test/urls.py +++ b/horizon/test/urls.py @@ -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() diff --git a/openstack_dashboard/static_settings.py b/openstack_dashboard/static_settings.py index 8d573ace0..43c75a1f3 100644 --- a/openstack_dashboard/static_settings.py +++ b/openstack_dashboard/static_settings.py @@ -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), diff --git a/requirements.txt b/requirements.txt index 488cbf3cb..eec16f589 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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