Skip to content

Commit

Permalink
[FIX] website: fix race condition on snippet drag and drop tour
Browse files Browse the repository at this point in the history
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]: odoo@460d5ec

task-2726529

closes odoo#82169

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
  • Loading branch information
rdeodoo committed Jan 4, 2022
1 parent 6f6ace0 commit 49c7bd3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions addons/website/static/tests/tours/snippets_all_drag_and_drop.js
Original file line number Diff line number Diff line change
@@ -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') || '';
Expand All @@ -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();
},
}];

Expand Down

0 comments on commit 49c7bd3

Please sign in to comment.