From 35829f203124c0b333df29b2583d5b7863a94dae Mon Sep 17 00:00:00 2001 From: Gorash Date: Mon, 26 Aug 2019 15:26:00 +0000 Subject: [PATCH] [FIX] website: the rte tour was undeterministic The tour try to click on the language dropdown before the reloading of the page if the server is slow. To fix it, we avoid the reloading by the rte, and trigger the reload in '_reload' method of editor menu who add the class 'o_wait_reload'. We add a selector and trigger in the test to avoid undeterministic error. closes odoo/odoo#36098 Signed-off-by: David Monjoie (dmo) --- addons/website/static/src/js/editor/editor_menu.js | 2 +- addons/website/static/src/js/editor/wysiwyg_multizone.js | 2 +- addons/website/static/tests/tours/rte.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/website/static/src/js/editor/editor_menu.js b/addons/website/static/src/js/editor/editor_menu.js index 72c2e6bee81..87422efdb1f 100644 --- a/addons/website/static/src/js/editor/editor_menu.js +++ b/addons/website/static/src/js/editor/editor_menu.js @@ -113,7 +113,7 @@ var EditorMenu = Widget.extend({ save: function (reload) { var self = this; this.trigger_up('edition_will_stopped'); - return this.wysiwyg.save(true).then(function (result) { + return this.wysiwyg.save(false).then(function (result) { var $wrapwrap = $('#wrapwrap'); self.editable($wrapwrap).removeClass('o_editable'); if (result.isDirty && reload !== false) { diff --git a/addons/website/static/src/js/editor/wysiwyg_multizone.js b/addons/website/static/src/js/editor/wysiwyg_multizone.js index 79612937b2c..3453f2d3fb9 100644 --- a/addons/website/static/src/js/editor/wysiwyg_multizone.js +++ b/addons/website/static/src/js/editor/wysiwyg_multizone.js @@ -91,7 +91,7 @@ var WysiwygMultizone = Wysiwyg.extend({ save: function () { if (this.isDirty()) { return this._restoreMegaMenus() - .then(() => this.editor.save()) + .then(() => this.editor.save(false)) .then(() => ({isDirty: true})); } else { return {isDirty: false}; diff --git a/addons/website/static/tests/tours/rte.js b/addons/website/static/tests/tours/rte.js index 912cb6832e0..3d0c43a524d 100644 --- a/addons/website/static/tests/tours/rte.js +++ b/addons/website/static/tests/tours/rte.js @@ -70,7 +70,7 @@ tour.register('rte_translator', { }, { content : "click language dropdown", trigger : '.js_language_selector .dropdown-toggle', - extra_trigger: 'body:not(.o_wait_reload):not(:has(.note-editor))', + extra_trigger: 'body:not(.o_wait_reload):not(:has(.note-editor)) a[data-action="edit"]', }, { content: "click on french version", trigger: '.js_language_selector a[data-url_code="fr_BE"]', @@ -91,6 +91,7 @@ tour.register('rte_translator', { action_helper.text('translated french text'); Wysiwyg.setRange(this.$anchor.contents()[0], 22); this.$anchor.trigger($.Event( "keyup", {key: '_', keyCode: 95})); + this.$anchor.trigger('input'); }, }, { content: "translate text with special char", @@ -100,6 +101,7 @@ tour.register('rte_translator', { this.$anchor.prepend('<{translated}>'); Wysiwyg.setRange(this.$anchor.contents()[0], 0); this.$anchor.trigger($.Event( "keyup", {key: '_', keyCode: 95})); + this.$anchor.trigger('input'); }, }, { content: "click on input", @@ -120,6 +122,7 @@ tour.register('rte_translator', { }, { content: "check: content is translated", trigger: '#wrap p font:first:contains(translated french text)', + extra_trigger: 'body:not(.o_wait_reload):not(:has(.note-editor)) a[data-action="edit_master"]', run: function () {}, // it's a check }, { content: "check: content with special char is translated", @@ -168,7 +171,7 @@ tour.register('rte_translator', { }, { content : "click language dropdown", trigger : '.js_language_selector .dropdown-toggle', - extra_trigger: 'body:not(.o_wait_reload):not(:has(.note-editor))', + extra_trigger: 'body:not(.o_wait_reload):not(:has(.note-editor)) a[data-action="edit"]', }, { content: "return in french", trigger : 'html[lang="en-US"] .js_language_selector .js_change_lang[data-url_code="fr_BE"]',