From 99743cae437d60220b475030e4f206f8709d535c Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 31 Jan 2014 12:07:48 +0100 Subject: [PATCH 01/37] [REM] useless comment the database password is necessary to duplicate databases bzr revid: xmo@openerp.com-20140131110748-nfguxwjysgbn6y3y --- addons/web/tests/test_js.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/web/tests/test_js.py b/addons/web/tests/test_js.py index b37c082739f..a126ce4b2f3 100644 --- a/addons/web/tests/test_js.py +++ b/addons/web/tests/test_js.py @@ -10,12 +10,6 @@ class WebSuite(QUnitSuite): '/web/tests', 'mod=*&source={db}&supadmin={supadmin}&password={password}'.format( db=tools.config['db_name'], - # al: i dont understand why both are needed, db_password is the - # password for postgres and should not appear here of that i'm - # sure - # - # But runbot provides it with this wrong key so i let it here - # until it's fixed supadmin=tools.config['db_password'] or 'admin', password=tools.config['admin_passwd'] or 'admin'), '' From b78703c12200facabef2cad3e4fa5ec4eb9d57e3 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 31 Jan 2014 16:26:12 +0100 Subject: [PATCH 02/37] [IMP] console.log js output should be piped to stdout during JS tests bzr revid: xmo@openerp.com-20140131152612-rqxkge24w6p95q10 --- addons/web/tests/qunitsuite/suite.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web/tests/qunitsuite/suite.py b/addons/web/tests/qunitsuite/suite.py index 3aed7b133f1..84092c687b4 100644 --- a/addons/web/tests/qunitsuite/suite.py +++ b/addons/web/tests/qunitsuite/suite.py @@ -110,6 +110,8 @@ class QUnitSuite(unittest.TestSuite): self._test.failed = True result.addFailure( self._test, self.failure_to_str(*args[2:])) + elif event_name == 'console': + print args[1] return False From ae3223907b5d33f95c2215824cce1d5a179f6f29 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 31 Jan 2014 16:26:40 +0100 Subject: [PATCH 03/37] [FIX] modules initialization when testing broken "adaptation" to single-instance openerp would only initialize the first set of dependencies, any further module would see its test runs without itself or its dependencies being guaranteed to be initialized/installed into the current openerp instance. bzr revid: xmo@openerp.com-20140131152640-coxqulkdb0xupbvq --- addons/web/static/src/js/testing.js | 38 ++++++++++++++++++++++++----- 1 file 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)) { From 8be916910e29975439c3eef24fcfbe4089c71530 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 31 Jan 2014 16:27:53 +0100 Subject: [PATCH 04/37] [FIX] re-enable web_tests_demo tests bzr revid: xmo@openerp.com-20140131152753-81418oy8wjzxkgmt --- addons/web_tests_demo/static/test/demo.js | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/addons/web_tests_demo/static/test/demo.js b/addons/web_tests_demo/static/test/demo.js index 0ca10ba642c..2ead2902828 100644 --- a/addons/web_tests_demo/static/test/demo.js +++ b/addons/web_tests_demo/static/test/demo.js @@ -1,7 +1,5 @@ -// niv: I desactivate these until the testing framework has been adapted to better use -// the new way to declare JavaScript modules -/*openerp.testing.section('basic section', function (test) { +openerp.testing.section('basic section', function (test) { test('my first test', function () { ok(true, "this test has run"); }); @@ -88,18 +86,18 @@ }); }); -// test('actual RPC', {rpc: 'rpc', asserts: 4}, function (instance) { -// var Model = new instance.web.Model('web_tests_demo.model'); -// return Model.call('create', [{name: "Bob"}]) -// .then(function (id) { -// return Model.call('read', [[id]]); -// }).then(function (records) { -// strictEqual(records.length, 1); -// var record = records[0]; -// strictEqual(record.name, "Bob"); -// strictEqual(record.thing, false); -// // default value -// strictEqual(record.other, 'bob'); -// }); -// }); -});*/ + test('actual RPC', {rpc: 'rpc', asserts: 4}, function (instance) { + var Model = new instance.web.Model('web_tests_demo.model'); + return Model.call('create', [{name: "Bob"}]) + .then(function (id) { + return Model.call('read', [[id]]); + }).then(function (records) { + strictEqual(records.length, 1); + var record = records[0]; + strictEqual(record.name, "Bob"); + strictEqual(record.thing, false); + // default value + strictEqual(record.other, 'bob'); + }); + }); +}); From e9a3d8bcec151937fd983b0d658a1ed9144d7ff4 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 31 Jan 2014 16:41:47 +0100 Subject: [PATCH 05/37] [FIX] enable jsonrpc-auth tests, remove stray log bzr revid: xmo@openerp.com-20140131154147-oi30v8u8h3c3htx7 --- addons/web/static/test/jsonrpc.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/web/static/test/jsonrpc.js b/addons/web/static/test/jsonrpc.js index ef0c1fbc44c..96b10f0fee1 100644 --- a/addons/web/static/test/jsonrpc.js +++ b/addons/web/static/test/jsonrpc.js @@ -156,7 +156,6 @@ ropenerp.testing.section('jsonrpc-auth', { rpc: "rpc", }, function (test) { - return; test('basic-auth', {asserts: 3}, function () { var db = ropenerp.session.db; var session = new openerp.Session(null, null, {override_session: true}); @@ -182,7 +181,6 @@ function (test) { session2 = new openerp.Session(null, null, {session_id: session.session_id}); equal(session2.uid, undefined, "uid should be undefined"); equal(session2.override_session, true, "overwrite_session should be true"); - console.log("session_id", session.session_id); return session2.session_reload(); }).then(function() { equal(session2.uid, session.uid); From d23f8425ad65fcfcbc087892dc6038be7a5ae13c Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 3 Feb 2014 12:28:16 +0100 Subject: [PATCH 06/37] [FIX] website tour: flickering; banner auto run; work with different language bzr revid: chm@openerp.com-20140203112816-c350lxr5pgo9x2li --- addons/website/data/website_data.xml | 2 +- .../static/src/js/website.tour.banner.js | 4 +- addons/website/static/src/js/website.tour.js | 39 +++++++++++-------- .../website_blog/data/website_blog_data.xml | 2 +- .../static/src/js/website.tour.blog.js | 2 +- .../static/src/js/website.tour.event.js | 2 +- .../tests/ui_suite/event_test.js | 2 +- .../website_sale/data/website_sale_data.xml | 2 +- .../static/src/js/website.tour.shop.js | 8 ++-- 9 files changed, 35 insertions(+), 28 deletions(-) diff --git a/addons/website/data/website_data.xml b/addons/website/data/website_data.xml index 50f2d8e381e..4eff1b8a60d 100644 --- a/addons/website/data/website_data.xml +++ b/addons/website/data/website_data.xml @@ -59,7 +59,7 @@ Website With Tutorial - /?tutorial.banner=true + /#tutorial.banner=true self diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index 2c26ae34e98..b079c4a670c 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -13,7 +13,7 @@ website.BannerTour = website.Tour.extend({ id: 'banner', name: "Insert a banner", - path: '/page/website.homepage', + path: '/', init: function (editor) { var self = this; self.steps = [ @@ -52,9 +52,9 @@ placement: 'top', title: "Customize banner's text", content: "Click in the text and start editing it. Click continue once it's done.", + template: self.popover({ next: "Continue" }), }, { - waitNot: '#wrap [data-snippet-id=carousel]:first .carousel-caption:contains("Your Banner Title")', element: '.oe_overlay_options .oe_options', placement: 'left', title: "Customize the banner", diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 39eaa5b7279..1db813e4cd4 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -7,10 +7,6 @@ website.add_template_file('/website/static/src/xml/website.tour.xml'); website.EditorBar.include({ tours: [], start: function () { - // $('.tour-backdrop').click(function (e) { - // e.stopImmediatePropagation(); - // e.preventDefault(); - // }); var self = this; var menu = $('#help-menu'); _.each(this.tours, function (tour) { @@ -113,11 +109,13 @@ website.Tour = openerp.Class.extend({ this.localStorage.setItem("tour-"+this.id+"-test-automatic", true); } - // redirect to begin of the tour if (this.path) { - var path = this.path.split('?'); - window.location.href = path[0] + "?tutorial."+this.id+"=true" + path.slice(1, path.length).join("?"); - return; + // redirect to begin of the tour in function of the language + if (!this.testUrl(this.path+"(#.*)?$")) { + var path = this.path.split('#'); + window.location.href = "/"+this.getLang()+path[0] + "#tutorial."+this.id+"=true&" + path.slice(1, path.length).join("#"); + return; + } } var self = this; @@ -125,12 +123,12 @@ website.Tour = openerp.Class.extend({ website.Tour.waitReady.call(this, function () {self._running();}); }, running: function () { - if (+this.localStorage.getItem("tour-"+this.id+"-test") >= this.steps.length) { + if (+this.localStorage.getItem("tour-"+this.id+"-test") >= this.steps.length-1) { this.endTour(); return; } - if (website.Tour.is_busy() || !this.testUrl()) return; + if (website.Tour.is_busy() || !this.testPathUrl()) return; // launch tour with url this.checkRunningUrl(); @@ -143,7 +141,6 @@ website.Tour = openerp.Class.extend({ var self = this; website.Tour.waitReady.call(this, function () {self._running();}); }, - _running: function () { var stepId = this.localStorage.getItem("tour-"+this.id+"-test"); var automatic = !!this.localStorage.getItem("tour-"+this.id+"-test-automatic"); @@ -174,13 +171,19 @@ website.Tour = openerp.Class.extend({ $('.popover.tour').remove(); }, - testUrl: function () { - return !this.testPath || this.testPath.test(window.location.href); + getLang: function () { + return $("html").attr("lang").replace(/-/, '_'); + }, + testUrl: function (url) { + return new RegExp("(/"+this.getLang()+")?"+url, "i").test(window.location.href); + }, + testPathUrl: function () { + if (!this.testPath || this.testUrl(this.testPath)) return true; }, checkRunningUrl: function () { - if (window.location.search.indexOf("tutorial."+this.id+"=true") > -1) { + if (window.location.hash.indexOf("tutorial."+this.id+"=true") > -1) { this.localStorage.setItem("tour-"+this.id+"-test", 0); - window.location.href = window.location.href.replace(/tutorial.+=true&?/, ''); + window.location.hash = window.location.hash.replace(/tutorial.+=true&?/, ''); } }, @@ -315,7 +318,11 @@ website.Tour = openerp.Class.extend({ } }, endTour: function () { - console.log('{ "event": "success" }'); + if (parseInt(this.localStorage.getItem("tour-"+this.id+"-test"),10) >= this.steps.length-1) { + console.log('{ "event": "success" }'); + } else { + console.log('{ "event": "canceled" }'); + } this.reset(); }, autoNextStep: function () { diff --git a/addons/website_blog/data/website_blog_data.xml b/addons/website_blog/data/website_blog_data.xml index 4eb70186d52..a5a3aa3d8c9 100644 --- a/addons/website_blog/data/website_blog_data.xml +++ b/addons/website_blog/data/website_blog_data.xml @@ -20,7 +20,7 @@ Website Blogs self - + diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js index 1bd9f22fa31..ffbd6e7ecc8 100644 --- a/addons/website_blog/static/src/js/website.tour.blog.js +++ b/addons/website_blog/static/src/js/website.tour.blog.js @@ -13,7 +13,7 @@ website.BlogTour = website.Tour.extend({ id: 'blog', name: "Create a blog post", - testPath: /\/(blog|blogpost)\/[0-9]+\//, + testPath: '/(blog|blogpost)', init: function (editor) { var self = this; self.steps = [ diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js index c449c4209d1..05de73ceffb 100644 --- a/addons/website_event/static/src/js/website.tour.event.js +++ b/addons/website_event/static/src/js/website.tour.event.js @@ -13,7 +13,7 @@ website.EventTour = website.Tour.extend({ id: 'event', name: "Create an event", - testPath: /\/event\/[0-9]+\/register/, + testPath: '/event(/[0-9]+/register)?', init: function (editor) { var self = this; self.steps = [ diff --git a/addons/website_event/tests/ui_suite/event_test.js b/addons/website_event/tests/ui_suite/event_test.js index 12110e11546..06d6dc12b5f 100644 --- a/addons/website_event/tests/ui_suite/event_test.js +++ b/addons/website_event/tests/ui_suite/event_test.js @@ -11,7 +11,7 @@ testRunner.run(function eventTest (page, timeout) { }); }, function executeTest () { page.evaluate(function () { - window.openerp.website.Tour.run_test('event'); + window.openerp.website.Tour.get('event').run(true); }); }, timeout); }); diff --git a/addons/website_sale/data/website_sale_data.xml b/addons/website_sale/data/website_sale_data.xml index 3658ea7bdc6..c2f9144d7e4 100644 --- a/addons/website_sale/data/website_sale_data.xml +++ b/addons/website_sale/data/website_sale_data.xml @@ -16,7 +16,7 @@ Website Shop self - /shop?tutorial.shop=true + /shop#tutorial.shop=true diff --git a/addons/website_sale/static/src/js/website.tour.shop.js b/addons/website_sale/static/src/js/website.tour.shop.js index ebf5c9d00ec..a141e991661 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -14,7 +14,7 @@ website.EditorShopTour = website.Tour.extend({ id: 'shop', name: "Create a product", - testPath: /\/shop\/.*/, + testPath: '/shop', init: function (editor) { var self = this; self.steps = [ @@ -145,7 +145,7 @@ id: 'shop_buy_product', name: "Try to buy products", path: '/shop', - testPath: /\/shop/, + testPath: '/shop', init: function (editor) { var self = this; self.steps = [ @@ -217,10 +217,10 @@ }, { title: "select acquirer", - element: 'input[name="acquirer"]', + element: 'input[name="acquirer"]:first', }, { - title: "confirm", + title: "Pay Now", element: 'button:contains("Pay Now")', }, { From 0aa0bbd539be03b90670906d8e21f2cc45f8e72f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 3 Feb 2014 12:56:33 +0100 Subject: [PATCH 07/37] [FIX] add warning when dbfilter logs out current session bzr revid: xmo@openerp.com-20140203115633-es2o542ywg85d46i --- openerp/http.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openerp/http.py b/openerp/http.py index 8e82beac43e..999a51dfe38 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -972,9 +972,12 @@ class Root(object): def setup_db(self, httprequest): db = httprequest.session.db # Check if session.db is legit - if db and db not in db_filter([db], httprequest=httprequest): - httprequest.session.logout() - db = None + if db: + if db not in db_filter([db], httprequest=httprequest): + _logger.warn("Logged into database '%s', but dbfilter " + "rejects it; logging session out.", db) + httprequest.session.logout() + db = None if not db: httprequest.session.db = db_monodb(httprequest) From 4bf0284d4be510e9822fc28a36552ee957e31c6d Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 3 Feb 2014 13:23:00 +0100 Subject: [PATCH 08/37] [IMP] Cosmetic change for easier debugging bzr revid: fme@openerp.com-20140203122300-pduwmt5z5cprehey --- addons/auth_signup/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 2db1e3dff65..d4232282279 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -30,7 +30,7 @@ from openerp.tools import exception_to_unicode _logger = logging.getLogger(__name__) -class Home(openerp.addons.web.controllers.main.Home): +class AuthSignup(openerp.addons.web.controllers.main.Home): @http.route() def web_login(self, *args, **kw): From 967c9db196100e0aa132bec6c8214c4b547b6bc3 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 3 Feb 2014 13:45:16 +0100 Subject: [PATCH 09/37] [FIX] never let me commit in saas-3 again bzr revid: fme@openerp.com-20140203124516-l8wwu9vdyo2nu2s0 --- addons/auth_signup/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index d4232282279..06c916d9580 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -60,7 +60,7 @@ class AuthSignup(openerp.addons.web.controllers.main.Home): qcontext.update(config) if 'error' in qcontext or mode not in ('reset', 'signup') or (not token and not config[mode]): - response = super(Home, self).web_login(*args, **kw) + response = super(AuthSignup, self).web_login(*args, **kw) if isinstance(response, LazyResponse): response.params['values'].update(config) return response @@ -86,7 +86,7 @@ class AuthSignup(openerp.addons.web.controllers.main.Home): request.cr.commit() except SignupError, e: qcontext['error'] = exception_to_unicode(e) - return super(Home, self).web_login(*args, **kw) + return super(AuthSignup, self).web_login(*args, **kw) return response From 0733d51365a8c85d73dad24126d6020827747c41 Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Mon, 3 Feb 2014 13:47:18 +0100 Subject: [PATCH 10/37] [IMP] Organization microdata bzr revid: ddm@openerp.com-20140203124718-8ogunilwsvm42ikt --- addons/website/views/website_templates.xml | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index c288dbacb93..dda82501da4 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -139,9 +139,9 @@ -
    -
  • -
  • +
      +
    • +

    @@ -637,11 +637,11 @@ Sitemap: sitemap.xml From 319185a1ed45373fcd2bbc9bf34e78a8dd4f0ecb Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Mon, 3 Feb 2014 14:14:54 +0100 Subject: [PATCH 11/37] [FIX] Remove redundant microdata bzr revid: ddm@openerp.com-20140203131454-7h3t2x4ff1z085xi --- addons/website/views/website_templates.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index dda82501da4..b5cfb9a9d7f 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -139,9 +139,9 @@ -
      -
    • -
    • +
        +
      • +

      From e31d566ff0ae50a4a24f017cf9f469155038fd17 Mon Sep 17 00:00:00 2001 From: "ddm@openerp.com" <> Date: Mon, 3 Feb 2014 15:08:29 +0100 Subject: [PATCH 12/37] [IMP] Event microdata support bzr revid: ddm@openerp.com-20140203140829-if35stozydxwk5xw --- addons/website_event/views/website_event.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml index 00469b7ce31..212ba6b5b49 100644 --- a/addons/website_event/views/website_event.xml +++ b/addons/website_event/views/website_event.xml @@ -230,11 +230,11 @@