From 5387a51ca6ff3f984ad0ca1458a38204d7e8bd0b Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Mon, 3 Jan 2022 17:08:39 +0000 Subject: [PATCH] [FIX] website: fix race condition on snippet drag and drop tour A mega-tour was introduced with [1] to test every single snippet. This tour, despite being very useful as it tests the core behavior of the website builder, is creating a lot of race conditions. This commit should prevent one of those race condition: When the step was removing the snippet, it was then clicking on the "Blocks" tab to get ready to drag and drop the next snippet. The issue was that in some cases, it would click on the "Blocks" tab before the snippet removal process was fully done. Basically, when the race condition happened, it was the same as doing: ``` $('we-button.oe_snippet_remove:first').click(); $('.o_we_add_snippet_btn').click(); ``` which, when done in the browser console, will result in the same visual than the screenshots on the failing runbot builds. [1]: https://github.com/odoo/odoo/commit/460d5ecb926c13a79ba363f8f86442433d91bf6f task-2726529 closes odoo/odoo#82214 X-original-commit: 49c7bd39826b428430c08c5faedca51dde9e2359 Signed-off-by: Romain Derie (rde) --- .../tests/tours/snippets_all_drag_and_drop.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/addons/website/static/tests/tours/snippets_all_drag_and_drop.js b/addons/website/static/tests/tours/snippets_all_drag_and_drop.js index 03c4c9045eb..7ab93e6f71b 100644 --- a/addons/website/static/tests/tours/snippets_all_drag_and_drop.js +++ b/addons/website/static/tests/tours/snippets_all_drag_and_drop.js @@ -1,6 +1,15 @@ odoo.define("website.tour.snippets_all_drag_and_drop", async function (require) { "use strict"; +const snippetsEditor = require('web_editor.snippet.editor'); + +snippetsEditor.SnippetEditor.include({ + removeSnippet: async function (shouldRecordUndo = true) { + await this._super(...arguments); + $('body').attr('test-dd-snippet-removed', true); + }, +}); + const tour = require("web_tour.tour"); let snippetsNames = (new URL(document.location.href)).searchParams.get('snippets_names') || ''; @@ -25,13 +34,11 @@ for (const snippet of snippetsNames) { trigger: "we-button.oe_snippet_remove:last" }, { content: `click on 'BLOCKS' tab (${snippet})`, + extra_trigger: 'body[test-dd-snippet-removed]', trigger: ".o_we_add_snippet_btn", run: function (actions) { - // FIXME cannot find the reason why this setTimeout is needed to - // after reverting ab7508393376075f95d6dd5925e7f4462936d2, to check - // (this commit is however reverted temporarily until a better - // solution is found). - setTimeout(() => actions.auto(), 0); + $('body').removeAttr('test-dd-snippet-removed'); + actions.auto(); }, }];