diff --git a/Gruntfile.js b/Gruntfile.js index 0da0bf8161..b337ad3baa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,7 +12,9 @@ module.exports = function(grunt) { 'loadImages=false' ] }, - all: ['www/scripts/tests/index.html'] + all: [ + 'www/scripts/tests/*.html' + ] }, qunit: { all: ['www/include/js/tests/*.html'] diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php index c14f39476b..ca6df75ffa 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php @@ -146,7 +146,6 @@ class TaskManager implements ControllerProviderInterface ]); } - public function getScheduler(Application $app, Request $request) { if ($request->getRequestFormat() !== "json") { diff --git a/templates/web/admin/task-manager/index.html.twig b/templates/web/admin/task-manager/index.html.twig index 92767eacf6..ce3ee4755c 100644 --- a/templates/web/admin/task-manager/index.html.twig +++ b/templates/web/admin/task-manager/index.html.twig @@ -120,8 +120,6 @@ -{##} - + + + + + diff --git a/www/scripts/tests/baseTest.js b/www/scripts/tests/baseTest.js deleted file mode 100644 index f2334f6b83..0000000000 --- a/www/scripts/tests/baseTest.js +++ /dev/null @@ -1,4 +0,0 @@ -define(["chai"], function (shai) { - window.expect = shai.expect; - window.assert = shai.assert; -}); diff --git a/www/scripts/tests/index.html b/www/scripts/tests/index.html deleted file mode 100644 index 210c8440be..0000000000 --- a/www/scripts/tests/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Mocha Spec Runner - - - -
- - - - - - - diff --git a/www/scripts/tests/login.html b/www/scripts/tests/login.html new file mode 100644 index 0000000000..375ac93d51 --- /dev/null +++ b/www/scripts/tests/login.html @@ -0,0 +1,88 @@ + + + + + Mocha Spec Runner + + + +
+ + + + + + diff --git a/www/scripts/tests/main.js b/www/scripts/tests/main.js deleted file mode 100644 index 81eabd2722..0000000000 --- a/www/scripts/tests/main.js +++ /dev/null @@ -1,72 +0,0 @@ -require.config({ - baseUrl: "../../scripts", - paths: { - specs: "tests/specs", - chai: "../../tmp-assets/chai/chai", - fixtures: "../../tmp-assets/js-fixtures/fixtures", - jquery: "../assets/jquery/jquery", - jqueryui: "../assets/jquery.ui/jquery-ui", - backbone: "../assets/backbone-amd/backbone", - i18n: "../assets/i18next/i18next.amd-1.6.3", - bootstrap: "../assets/bootstrap/js/bootstrap.min", - sinonchai: "../../tmp-assets/sinon-chai/lib/sinon-chai", - squire: "../../tmp-assets/squire/src/Squire", - "jquery.ui": "../assets/jquery.ui/jquery-ui", - underscore: "../assets/underscore-amd/underscore", - "jquery.ui.widget": "../assets/jquery-file-upload/jquery.ui.widget", - "jquery.cookie": "../assets/jquery.cookie/jquery.cookie", - "jquery.treeview": "../assets/jquery.treeview/jquery.treeview", - "jquery.tooltip": "../assets/jquery.tooltip/jquery.tooltip", - "blueimp.loadimage" : "../assets/blueimp-load-image/load-image", - "jfu.iframe-transport": "../assets/jquery-file-upload/jquery.iframe-transport", - "jfu.fileupload": "../assets/jquery-file-upload/jquery.fileupload", - }, - shim: { - jqueryui: { - deps: ["jquery"] - }, - "jquery.treeview": { - deps: ['jquery', 'jquery.cookie'], - exports: '$.fn.treeview' - }, - bootstrap:{ - deps: ['jquery'] - }, - "jquery.cookie": { - deps: ["jquery"], - exports: '$.fn.cookie' - }, - "jquery.tooltip": { - deps: ["jquery"], - exports: '$.fn.tooltip' - }, - "jquery.ui": { - deps: ["jquery"] - }, - "jquery.ui.widget": { - deps: ["jquery"] - }, - "jfu.fileupload": { - deps: ["jquery.ui.widget"] - } - } -}); - -mocha.setup({ - ui: "bdd", - ignoreLeaks: true, - globals: ['js-fixtures'] -}); - -console = window.console || function () { -}; - -window.notrack = true; - -var runMocha = function () { - if (window.mochaPhantomJS) { - mochaPhantomJS.run(); - } else { - mocha.run(); - } -}; diff --git a/www/scripts/tests/model.html b/www/scripts/tests/model.html new file mode 100644 index 0000000000..9ace48eeef --- /dev/null +++ b/www/scripts/tests/model.html @@ -0,0 +1,88 @@ + + + + + Mocha Spec Runner + + + +
+ + + + + + diff --git a/www/scripts/tests/specs/admin/main.js b/www/scripts/tests/specs/admin/main.js index 2e73101e3d..59326bc811 100644 --- a/www/scripts/tests/specs/admin/main.js +++ b/www/scripts/tests/specs/admin/main.js @@ -2,18 +2,16 @@ define([ 'chai', 'fixtures', 'jquery', - 'squire', 'apps/admin/main/app', 'apps/admin/main/views/leftPanel', 'apps/admin/main/views/rightPanel' -], function (chai, fixtures, $, Squire, App, LeftPanel, RightPanel) { +], function (chai, fixtures, $, App, LeftPanel, RightPanel) { var expect = chai.expect; var assert = chai.assert; var should = chai.should(); fixtures.path = 'fixtures'; $("body").append(fixtures.read('admin/main/left-panel.html')); - $("right-view").append(fixtures.read('admin/main/right-panel.html')); App.create(); @@ -25,6 +23,14 @@ define([ }); describe("Views", function () { + beforeEach(function() { + this.xhr = sinon.useFakeXMLHttpRequest(); + this.server = sinon.fakeServer.create(); + }); + afterEach(function() { + this.xhr.restore(); + this.server.restore(); + }); describe("leftView", function () { it("should throw an exception if 'event manager' is missing", function () { expect(function () { @@ -37,28 +43,23 @@ define([ }); it("should make ajax request if we reload", function () { - var xhr = sinon.useFakeXMLHttpRequest(); var requests = []; - xhr.onCreate = function (req) { requests.push(req); }; + this.xhr.onCreate = function (req) { requests.push(req); }; var leftP = new LeftPanel({eventManager : AdminApp.eventManager, treeUrl: "/admin/tree/"}); leftP.reloadTree(); assert.equal(requests.length, 1); assert.equal(requests[0].url, "/admin/tree/"); - - xhr.restore(); }); it("should make ajax request if we click link", function () { - var xhr = sinon.useFakeXMLHttpRequest(); var requests = []; - xhr.onCreate = function (req) { requests.push(req); }; + this.xhr.onCreate = function (req) { requests.push(req); }; var leftP = new LeftPanel({eventManager : AdminApp.eventManager, el:$(".left-view"), treeUrl: "toto"}); leftP.$('a[target=right]:first').trigger("click"); - assert.equal(requests.length, 1); - xhr.restore(); + assert.ok(requests.length > 0); }); it("triggers right view", function () { @@ -67,18 +68,15 @@ define([ trigger = true; }); var leftP = new LeftPanel({eventManager : AdminApp.eventManager, el:$(".left-view"), treeUrl: "toto"}); - var rightP = new RightPanel({eventManager : AdminApp.eventManager, el:$(".right-view")}); - var server = sinon.fakeServer.create(); leftP.activeTree(); leftP.$('a[target=right]:first').trigger("click"); - server.requests[0].respond( + this.server.requests[0].respond( 200, { "Content-Type": "application/json" }, '' ); assert.ok(trigger); - server.restore(); }); }); @@ -90,14 +88,21 @@ define([ }); it("should make ajax request if we click link", function () { - var xhr = sinon.useFakeXMLHttpRequest(); var requests = []; - xhr.onCreate = function (req) { requests.push(req); }; - + this.xhr.onCreate = function (req) { requests.push(req); }; + $(".right-view").html('test'); var rightP = new RightPanel({eventManager : AdminApp.eventManager, el:$(".right-view")}); - rightP.$('a:not(.no-ajax)').trigger("click"); - assert.equal(requests.length, 1); - xhr.restore(); + rightP.$('a').trigger('click'); + assert.ok(requests.length > 0); + }); + + it("should make ajax request if we click form", function () { + var requests = []; + this.xhr.onCreate = function (req) { requests.push(req); }; + $(".right-view").html('
'); + var rightP = new RightPanel({eventManager : AdminApp.eventManager, el:$(".right-view")}); + rightP.$('form:first').trigger('submit'); + assert.ok(requests.length > 0); }); }); }); diff --git a/www/scripts/tests/specs/admin/taskmanager.js b/www/scripts/tests/specs/admin/taskmanager.js index db9f54f060..9d2b3470f3 100644 --- a/www/scripts/tests/specs/admin/taskmanager.js +++ b/www/scripts/tests/specs/admin/taskmanager.js @@ -56,7 +56,7 @@ define([ this.collection = new TaskCollection([]); this.view = new TasksView({ collection: this.collection, - el: AdminFieldApp.$tasksListView + el: TaskManagerApp.$tasksListView }); }); @@ -75,7 +75,7 @@ define([ this.view = new TasksView({ collection: this.collection, - el: AdminFieldApp.$tasksListView + el: TaskManagerApp.$tasksListView }); }); diff --git a/www/scripts/tests/specs/websockets/connection.js b/www/scripts/tests/specs/websockets/connection.js index 69ddce49de..1e0a831e2c 100644 --- a/www/scripts/tests/specs/websockets/connection.js +++ b/www/scripts/tests/specs/websockets/connection.js @@ -84,5 +84,3 @@ define([ }); }); }); - - diff --git a/www/scripts/tests/specs/websockets/subscriberManager.js b/www/scripts/tests/specs/websockets/subscriberManager.js index 7588b3a19b..b767f90e75 100644 --- a/www/scripts/tests/specs/websockets/subscriberManager.js +++ b/www/scripts/tests/specs/websockets/subscriberManager.js @@ -9,50 +9,65 @@ define([ var should = chai.should(); chai.use(sinonchai); - describe("SubscriberManager", function () { - var i; - beforeEach(function () { - var $this = this; - $this.connection = {}; - $this.connection.subscribe = sinon.spy(); - $this.connection.unsubscribe = sinon.spy(); - $this.injector = new Squire(); - }); + (function () { + describe("SubscriberManager", function () { + beforeEach(function () { + var $this = this; + $this.connection = {}; + $this.connection.subscribe = sinon.spy(); + $this.connection.unsubscribe = sinon.spy(); - it("should call subscribe", function () { - var $this = this; - $this.injector.mock( - ["common/websockets/connection"], $this.connection - ).require(['common/websockets/subscriberManager'], function(manager) { - manager.register('topic'); - expect($this.connection.subscribe.should.have.callCount(1)).to.be.ok; - assert.ok(manager.hasCallbacks()); + }); + + it("should call subscribe", function () { + var $this = this; + var injector = new Squire(); + injector.mock( + ["common/websockets/connection"], $this.connection + ).require(['common/websockets/subscriberManager'], function(manager) { + manager.register('topic'); + expect($this.connection.subscribe.should.have.callCount(1)).to.be.ok; + assert.ok(manager.hasCallbacks()); + }); + + try{ + injector.remove(); + } catch(e) { + } + }); + + it("should call unsubscribe", function () { + var $this = this; + var injector = new Squire(); + injector.mock( + ["common/websockets/connection"], $this.connection + ).require(['common/websockets/subscriberManager'], function(manager) { + manager.register('topic'); + manager.unregister(); + expect($this.connection.unsubscribe.should.have.callCount(1)).to.be.ok; + assert.ok(!manager.hasCallbacks()); + }); + try{ + injector.remove(); + } catch(e) { + } + }); + + it("should add callbacks", function () { + var $this = this; + var injector = new Squire(); + injector.mock( + ["common/websockets/connection"], $this.connection + ).require(['common/websockets/subscriberManager'], function(manager) { + assert.ok(!manager.hasCallbacks()); + manager.pushCallback(function(){return null;}); + assert.ok(manager.hasCallbacks()); + }); + try{ + injector.remove(); + } catch(e) { + } }); }); - - it("should call unsubscribe", function () { - var $this = this; - $this.injector.mock( - ["common/websockets/connection"], $this.connection - ).require(['common/websockets/subscriberManager'], function(manager) { - manager.register('topic'); - manager.unregister(); - expect($this.connection.unsubscribe.should.have.callCount(1)).to.be.ok; - assert.ok(!manager.hasCallbacks()); - }); - }); - - it("should add callbacks", function () { - var $this = this; - $this.injector.mock( - ["common/websockets/connection"], $this.connection - ).require(['common/websockets/subscriberManager'], function(manager) { - assert.ok(!manager.hasCallbacks()); - manager.pushCallback(function(){return null;}); - assert.ok(manager.hasCallbacks()); - }); - }); - }); + })(); }); - - diff --git a/www/scripts/tests/validator.html b/www/scripts/tests/validator.html new file mode 100644 index 0000000000..099a69a3fe --- /dev/null +++ b/www/scripts/tests/validator.html @@ -0,0 +1,88 @@ + + + + + Mocha Spec Runner + + + +
+ + + + + + diff --git a/www/scripts/tests/websocket.html b/www/scripts/tests/websocket.html new file mode 100644 index 0000000000..8cf0acb7c9 --- /dev/null +++ b/www/scripts/tests/websocket.html @@ -0,0 +1,89 @@ + + + + + Mocha Spec Runner + + + +
+ + + + + +