From e8964f896c4b23b0b8c1a5722f4576c5a7201bcc Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 6 Feb 2014 15:07:46 +0100 Subject: [PATCH] [FIX] website: tour, test and test_runner bzr revid: chm@openerp.com-20140206140746-jmeyx8q9qxv7sz1j --- addons/website/static/src/js/website.tests.js | 40 ------- addons/website/static/src/js/website.tour.js | 109 +++++++++--------- .../static/src/js/website.tour.test.js | 27 +++++ addons/website/tests/test_ui.py | 10 +- .../website/tests/ui_suite/ui_test_runner.js | 57 ++++++++- addons/website/views/website_templates.xml | 6 + .../website_blog/tests/ui_suite/post_test.js | 16 +-- .../tests/ui_suite/event_test.js | 16 +-- .../static/src/js/website.tour.event_sale.js | 80 +++++++++++++ addons/website_event_sale/tests/__init__.py | 1 + addons/website_event_sale/tests/test_ui.py | 10 ++ .../tests/ui_suite/website_event_sale_test.js | 7 ++ .../static/src/js/website.tour.sale.js | 95 +++++++++++++++ .../static/src/js/website_sale.js | 7 +- addons/website_sale/tests/test_ui.py | 10 +- .../ui_suite/website_sale-add_product-test.js | 3 + .../website_sale-sale_process-test-2.js | 17 --- .../website_sale-sale_process-test.js | 20 +--- 18 files changed, 365 insertions(+), 166 deletions(-) delete mode 100644 addons/website/static/src/js/website.tests.js create mode 100644 addons/website/static/src/js/website.tour.test.js create mode 100644 addons/website_event_sale/static/src/js/website.tour.event_sale.js create mode 100644 addons/website_event_sale/tests/__init__.py create mode 100644 addons/website_event_sale/tests/test_ui.py create mode 100644 addons/website_event_sale/tests/ui_suite/website_event_sale_test.js create mode 100644 addons/website_sale/static/src/js/website.tour.sale.js create mode 100644 addons/website_sale/tests/ui_suite/website_sale-add_product-test.js delete mode 100644 addons/website_sale/tests/ui_suite/website_sale-sale_process-test-2.js diff --git a/addons/website/static/src/js/website.tests.js b/addons/website/static/src/js/website.tests.js deleted file mode 100644 index 977dc8e1848..00000000000 --- a/addons/website/static/src/js/website.tests.js +++ /dev/null @@ -1,40 +0,0 @@ -var tests = {}; -var droptest = function () { - var errors = []; - for (var snippet_id in tests) { - if (!tests[snippet_id]['activated'] || !tests[snippet_id]['dropped']){ - console.log("Can't dropped or activated snippet: " + snippet_id); - } - } - if (errors.length) { - console.log(tests); - throw new Error("Can't dropped or activated at least one snippet"); - } - $("#oe_snippets").off('snippet-activated snippet-dropped'); -}; -var droptesttime = setTimeout(droptest,0); - -$("#oe_snippets").off('snippet-activated snippet-dropped') - .on('snippet-activated', function (event, dom) { - tests[$(dom).data('src-snippet-id')]['activated'] = true; - clearTimeout(droptesttime); - droptesttime = setTimeout(droptest,0); - }) - .on('snippet-dropped', function (event, dom, src_snipped_id) { - tests[$(dom).data('src-snippet-id')]['dropped'] = true; - clearTimeout(droptesttime); - droptesttime = setTimeout(droptest,0); - }); -var $thumbnails = $('#oe_snippets div.oe_snippet[data-snippet-id] .oe_snippet_thumbnail'); -$thumbnails.each(function () { - var $thumbnail = $(this); - tests[$thumbnail.parent().data('snippet-id')] = {}; - var position = $thumbnail.position(); - $thumbnail.trigger( $.Event( "mousedown", { which: 1, pageX: position.left, pageY: position.top } ) ); - $thumbnail.trigger( $.Event( "mousemove", { which: 1, pageX: position.left+100, pageY: position.top+100 } ) ); - $first_drop = $(".oe_drop_zone").first(); - position = $first_drop.position(); - $first_drop.trigger( $.Event( "mouseup", { which: 1, pageX: position.left+20, pageY: position.top+20 } ) ); - clearTimeout(droptesttime); - droptesttime = setTimeout(droptest,0); -}); diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 1db813e4cd4..4285656e39a 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -4,6 +4,7 @@ var website = openerp.website; website.add_template_file('/website/static/src/xml/website.tour.xml'); +if (website.EditorBar) website.EditorBar.include({ tours: [], start: function () { @@ -17,31 +18,11 @@ website.EditorBar.include({ }); menu.append($menuItem); }); - - this.waitRTEReady = false; - this.on('rte:called', this, function () {self.waitRTEReady = true; }); - this.on('rte:ready', this, function () {self.waitRTEReady = false;}); - - var res = this._super(); - website.Tour.waitReady.call(this, this.testRunning); - return res; + return this._super(); }, registerTour: function (tour) { website.Tour.add(tour); this.tours.push(tour); - }, - testRunning: function () { - if (this.waitRTEReady) { - this.on('rte:ready', this, function () { - website.Tour.each(function () { - this.running(); - }); - }); - } else { - website.Tour.each(function () { - this.running(); - }); - } } }); @@ -78,23 +59,12 @@ $.ajaxSetup({ } }); - website.Tour = openerp.Class.extend({ steps: [], defaultDelay: 50, //ms + defaultOverLaps: 5000, //ms localStorage: window.localStorage, - init: function (url) { - this.tour = new Tour({ - name: this.id, - storage: this.tourStorage, - keyboard: false, - template: this.popover(), - onHide: function () { - window.scrollTo(0, 0); - } - }); - this.registerSteps(); - }, + init: function () {}, run: function (automatic) { this.reset(); @@ -143,14 +113,11 @@ website.Tour = openerp.Class.extend({ }, _running: function () { var stepId = this.localStorage.getItem("tour-"+this.id+"-test"); - var automatic = !!this.localStorage.getItem("tour-"+this.id+"-test-automatic"); - + if (stepId != null) { - if (!this.check(this.step(stepId))) { - var step = this.next(stepId); - stepId = step ? step.stepId : stepId; - } - this.nextStep(stepId, automatic ? this.autoNextStep : null, automatic ? 5000 : null); + this.automatic = !!this.localStorage.getItem("tour-"+this.id+"-test-automatic"); + this.registerTour(); + this.nextStep(stepId, this.automatic ? this.autoNextStep : null, this.automatic ? this.defaultOverLaps : null); } }, @@ -187,6 +154,18 @@ website.Tour = openerp.Class.extend({ } }, + registerTour: function () { + this.tour = new Tour({ + name: this.id, + storage: this.tourStorage, + keyboard: false, + template: this.popover(), + onHide: function () { + window.scrollTo(0, 0); + } + }); + this.registerSteps(); + }, registerSteps: function () { for (var index=0, len=this.steps.length; index + +