diff options
| author | Xavier Morel <xmo@openerp.com> | 2014-02-03 13:05:53 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2014-02-03 13:05:53 +0100 |
| commit | 5de043e044ae34d84832fceeb3ca3090f75f730b (patch) | |
| tree | b9eed13a8001640ca58063a22fecf5e92cfa04a3 /addons/web/static/src | |
| parent | 0aa0bbd539be03b90670906d8e21f2cc45f8e72f (diff) | |
| parent | e9a3d8bcec151937fd983b0d658a1ed9144d7ff4 (diff) | |
[FIX] various issues with JS tests
bzr revid: xmo@openerp.com-20140203120553-foe2jutor33j1b8q
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/testing.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index f607b278437..c4f5aeebd60 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -15,6 +15,37 @@ openerp.testing = {}; list_editable: ['list', 'form', 'data'], }; + var initialized = []; + /** + * openerp.init is a broken-ass piece of shit, makes it impossible to + * progressively add modules, using it, retarded openerp_inited flag + * means the first tests being run get their dependencies loaded + * (basically just base and web), and for *every other module* the tests + * run without the dependencies being correctly loaded + */ + function init(modules) { + if (!initialized.length) { + openerp.init(modules); + initialized = openerp._modules.slice(); + return; + } + var to_initialize = _.difference(modules, initialized); + for (var i = 0; i < to_initialize.length; i++) { + var modname = to_initialize[i]; + var fct = openerp[modname]; + if (typeof fct === 'function') { + var module = openerp[modname] = {}; + for(var k in fct) { + if (!fct.hasOwnProperty(k)) { continue; } + module[k] = fct[k]; + } + fct(openerp, module) + } + initialized.push(modname); + openerp._modules.push(modname); + } + } + testing.dependencies = window['oe_all_dependencies'] || []; testing.current_module = null; testing.templates = { }; @@ -165,8 +196,6 @@ openerp.testing = {}; }); }; - var openerp_inited = false; - var db = window['oe_db_info']; testing.section = function (name, options, body) { if (_.isFunction(options)) { @@ -243,10 +272,7 @@ openerp.testing = {}; QUnit.test(name, function () { var instance = openerp; - if (!openerp_inited) { - openerp.init(module_deps); - openerp_inited = true; - } + init(module_deps); instance.session = new instance.web.Session(); instance.session.uid = 42; if (_.isNumber(opts.asserts)) { |
