summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
authorddm <ddm@openerp.com>2013-12-09 12:25:34 +0100
committerddm <ddm@openerp.com>2013-12-09 12:25:34 +0100
commit5f0fcfb9be0695a2e0fba5e4ea85c449b7f5af8b (patch)
treec3c2c4a7e1b66c5c368052634f7f186b412fcd64 /addons/website/static/src
parent3aeff809690ecb6d0093bddc0d9d10232282d657 (diff)
[IMP] Tour improvements => automated tests
bzr revid: ddm@openerp.com-20131209112534-3ysihjgm20jj3d9k
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js3
-rw-r--r--addons/website/static/src/js/website.tour.banner.js7
-rw-r--r--addons/website/static/src/js/website.tour.js42
3 files changed, 38 insertions, 14 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index ef4c029280e..e605bba3d1b 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -246,6 +246,9 @@
this.snippet_focus($snippet);
}
$("#oe_snippets").trigger('snippet-activated', $snippet);
+ if ($snippet) {
+ $snippet.trigger('snippet-activated', $snippet);
+ }
},
create_overlay: function ($snippet) {
if (typeof $snippet.data("snippet-editor") === 'undefined') {
diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js
index 70c5dd9dc38..9bea6b223da 100644
--- a/addons/website/static/src/js/website.tour.banner.js
+++ b/addons/website/static/src/js/website.tour.banner.js
@@ -46,7 +46,7 @@
},
{
stepId: 'drag-banner',
- element: '#website-top-navbar [data-snippet-id=carousel].ui-draggable',
+ snippet: 'carousel',
placement: 'bottom',
title: "Drag & Drop a Banner",
content: "Drag the Banner block and drop it in your page.",
@@ -84,7 +84,7 @@
},
{
stepId: 'drag-three-columns',
- element: '#website-top-navbar [data-snippet-id=three-columns].ui-draggable',
+ snippet: 'three-columns',
placement: 'bottom',
title: "Drag & Drop a Block",
content: "Drag the <em>'3 Columns'</em> block and drop it below the banner.",
@@ -97,7 +97,8 @@
title: "Edit an Area",
content: "Select any area of the page to modify it. Click on this subtitle.",
trigger: {
- id: 'snippet-activated'
+ emitter: '#wrap [data-snippet-id=three-columns]:first .text-center[data-snippet-id=colmd]',
+ id: 'snippet-activated',
},
},
{
diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js
index 90f2f8a3d21..3ea5626009f 100644
--- a/addons/website/static/src/js/website.tour.js
+++ b/addons/website/static/src/js/website.tour.js
@@ -27,6 +27,9 @@
if (!step.element) {
step.orphan = true;
}
+ if (step.snippet) {
+ step.element = '#oe_snippets div.oe_snippet[data-snippet-id="'+step.snippet+'"] .oe_snippet_thumbnail';
+ }
if (step.trigger) {
if (step.trigger === 'click') {
step.triggers = function (callback) {
@@ -48,8 +51,9 @@
};
} else {
step.triggers = function (callback) {
- var emitter = step.trigger.emitter || $(step.element);
- emitter.one(step.trigger.id, function customHandler () {
+ var emitter = _.isString(step.trigger.emitter) ? $(step.trigger.emitter) : (step.trigger.emitter || $(step.element));
+ emitter.on(step.trigger.id, function customHandler () {
+ console.log(arguments);
(callback || self.moveToNextStep).apply(self, arguments);
});
};
@@ -164,7 +168,7 @@
$('.popover.tour').remove();
function advance () {
if (_.isFunction(callback)) {
- callback.call(self);
+ callback.apply(self);
}
}
$(document.body).one('mouseup', advance);
@@ -215,7 +219,17 @@
});
var TestConsole = website.TestConsole = {
- tests: []
+ dragAndDropSnippet: function (snippetId) {
+ 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 }));
+ var $dropZone = $(".oe_drop_zone").first();
+ var dropPosition = $dropZone.position();
+ $dropZone.trigger($.Event( "mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top }));
+ },
+ tests: [],
};
website.EditorBar.include({
@@ -247,16 +261,22 @@
id: tour.id,
run: function runTest () {
var actionSteps = _.filter(tour.steps, function (step) {
- return step.triggers;
+ return step.trigger;
});
var currentIndex = 0;
function executeStep (step) {
- var $element = $(step.element);
- step.triggers(function () {
- currentIndex = currentIndex + 1;
- executeStep(actionSteps[currentIndex]);
- });
- $element.click();
+ var $element = $(step.element);
+ step.triggers(function () {
+ currentIndex = currentIndex + 1;
+ executeStep(actionSteps[currentIndex]);
+ });
+ if (step.snippet && step.trigger === 'drag') {
+ setTimeout(function () {
+ TestConsole.dragAndDropSnippet(step.snippet);
+ }, 50);
+ } else {
+ $element.click();
+ }
}
executeStep(actionSteps[currentIndex]);
},