summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorddm <ddm@openerp.com>2013-12-12 10:43:06 +0100
committerddm <ddm@openerp.com>2013-12-12 10:43:06 +0100
commit8fe49cf3caee9cbd2a13a033a8b81850db0ab4e7 (patch)
tree4d16360d28e76d3cab3b491ef99d14026c8b4370
parentbdc04dcf445f17f7277f37d536815ca87b9acf7c (diff)
[IMP] Improve resume for automated tests
bzr revid: ddm@openerp.com-20131212094306-marvfv7zewlghiii
-rw-r--r--addons/website/static/src/js/website.tour.js50
1 files changed, 38 insertions, 12 deletions
diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js
index e09366d2b81..2abeec97cda 100644
--- a/addons/website/static/src/js/website.tour.js
+++ b/addons/website/static/src/js/website.tour.js
@@ -217,28 +217,54 @@
},
});
- var TestConsole = website.TestConsole = {
+ var TestConsole = openerp.Class.extend({
tests: [],
+ editor: null,
+ init: function (editor) {
+ if (!editor) {
+ throw new Error("Editor cannot be null or undefined");
+ }
+ this.editor = editor;
+ },
test: function (id) {
return _.find(this.tests, function (tour) {
return tour.id === id;
});
},
+ snippetSelector: function (snippetId) {
+ return '#oe_snippets div.oe_snippet[data-snippet-id="'+snippetId+'"] .oe_snippet_thumbnail';
+ },
+ snippetThumbnail: function (snippetId) {
+ return $(this.snippetSelector(snippetId)).first();
+ },
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, pageY: thumbnailPosition.top+500 }));
- var $dropZone = $(".oe_drop_zone").first();
- var dropPosition = $dropZone.position();
- $dropZone.trigger($.Event("mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top }));
+ function actualDragAndDrop ($thumbnail) {
+ 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, pageY: thumbnailPosition.top+500 }));
+ var $dropZone = $(".oe_drop_zone").first();
+ var dropPosition = $dropZone.position();
+ $dropZone.trigger($.Event("mouseup", { which: 1, pageX: dropPosition.left, pageY: dropPosition.top }));
+ }
+ if (this.snippetThumbnail(snippetId).length === 0) {
+ this.editor.on('rte:ready', this, function () {
+ actualDragAndDrop(this.snippetThumbnail(snippetId));
+ });
+ } else {
+ actualDragAndDrop(this.snippetThumbnail(snippetId));
+ }
},
- };
+ });
website.EditorBar.include({
tours: [],
+ init: function () {
+ var result = this._super();
+ website.TestConsole = new TestConsole(this);
+ return result;
+ },
start: function () {
+
$('.tour-backdrop').click(function (e) {
e.stopImmediatePropagation();
e.preventDefault();
@@ -288,7 +314,7 @@
});
var $element = $(step.element);
if (step.snippet && step.trigger === 'drag') {
- TestConsole.dragAndDropSnippet(step.snippet);
+ website.TestConsole.dragAndDropSnippet(step.snippet);
} else if (step.trigger.id === 'change') {
var currentValue = $element.val();
var options = $element[0].options;
@@ -322,7 +348,7 @@
window.localStorage.removeItem(testId);
},
};
- TestConsole.tests.push(test);
+ website.TestConsole.tests.push(test);
if (window.localStorage.getItem(testId)) {
test.run();
}