From a315678884f8e8d8ab976bf3fa4b3f42f9fe4b95 Mon Sep 17 00:00:00 2001 From: ddm Date: Tue, 10 Dec 2013 12:28:28 +0100 Subject: [PATCH] [IMP] Banner tour can be automated bzr revid: ddm@openerp.com-20131210112828-s2kxs2dy64gjewt9 --- .../static/src/js/website.tour.banner.js | 6 +-- addons/website/static/src/js/website.tour.js | 38 +++++++++++++------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index 9bea6b223da..f0b9043f20f 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -92,18 +92,18 @@ }, { stepId: 'activate-text-block-title', - element: '#wrap [data-snippet-id=three-columns]:first .text-center[data-snippet-id=colmd]', + element: '#wrap [data-snippet-id=three-columns] .text-center[data-snippet-id=colmd]', placement: 'top', title: "Edit an Area", content: "Select any area of the page to modify it. Click on this subtitle.", trigger: { - emitter: '#wrap [data-snippet-id=three-columns]:first .text-center[data-snippet-id=colmd]', + emitter: '#wrap [data-snippet-id=three-columns] .text-center[data-snippet-id=colmd]', id: 'snippet-activated', }, }, { stepId: 'remove-text-block-title', - element: '.ui-draggable.oe_active .oe_snippet_remove', + element: '.oe_active .oe_snippet_remove', placement: 'top', title: "Delete the Title", content: "From this toolbar you can move, duplicate or delete the selected zone. Click on the trash can to delete the title.", diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 3ea5626009f..6a025d0c299 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -223,11 +223,11 @@ var selector = '#oe_snippets div.oe_snippet[data-snippet-id="'+snippetId+'"] .oe_snippet_thumbnail'; var $thumbnail = $(selector).first(); var thumbnailPosition = $thumbnail.position(); - $thumbnail.trigger($.Event( "mousedown", { which: 1, pageX: thumbnailPosition.left, pageY: thumbnailPosition.top })); - $thumbnail.trigger($.Event( "mousemove", { which: 1, pageX: thumbnailPosition.left+100, pageY: thumbnailPosition.top+700 })); + $thumbnail.trigger($.Event("mousedown", { which: 1, pageX: thumbnailPosition.left, pageY: thumbnailPosition.top })); + $thumbnail.trigger($.Event("mousemove", { which: 1, pageX: thumbnailPosition.left+100, pageY: thumbnailPosition.top+700 })); var $dropZone = $(".oe_drop_zone").first(); var dropPosition = $dropZone.position(); - $dropZone.trigger($.Event( "mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top })); + $dropZone.trigger($.Event("mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top })); }, tests: [], }; @@ -256,6 +256,7 @@ return this._super(); }, registerTour: function (tour) { + var testId = 'test_'+tour.id+'_tour'; this.tours.push(tour); TestConsole.tests.push({ id: tour.id, @@ -263,22 +264,35 @@ var actionSteps = _.filter(tour.steps, function (step) { return step.trigger; }); - var currentIndex = 0; function executeStep (step) { - var $element = $(step.element); + window.localStorage.setItem(testId, step.stepId); step.triggers(function () { - currentIndex = currentIndex + 1; - executeStep(actionSteps[currentIndex]); + var nextStep = actionSteps.shift(); + if (nextStep) { + setTimeout(function () { + executeStep(nextStep); + }, 10); + } }); if (step.snippet && step.trigger === 'drag') { - setTimeout(function () { - TestConsole.dragAndDropSnippet(step.snippet); - }, 50); + TestConsole.dragAndDropSnippet(step.snippet); } else { - $element.click(); + var $element = $(step.element); + console.log($element); + $element.trigger($.Event("click", { srcElement: $element })); } } - executeStep(actionSteps[currentIndex]); + var lastStepId = window.localStorage.getItem(testId); + var currentStep = actionSteps.shift(); + if (lastStepId) { + while (currentStep && lastStepId !== currentStep.stepId) { + currentStep = actionSteps.shift(); + } + } + executeStep(currentStep); + }, + reset: function () { + window.localStorage.removeItem(testId); }, }); },