Skip to content

Commit 02ce8aa

Browse files
committed
[FIX] website: prevent social media tour to fail sometimes
There is a weird deeper low level misbehavior which makes concurent click to not acts as they should. Depending on the runbot/tour speed, the misbehavior might kick in and makes the tour fail. When you click on multiple options very quick back to back, their click will be registered and processed one by one, waiting for the previous one before considering the next one. You can see that by simply printing a console log in both `renderListItems` and `_computeWidgetState` method from `s_social_media` `options.js` file. Then click quickly on the options related to this snippet like the active toggle and/or remove custom media. Despite respecting the click order and not overlapping, some click results (like hidding or removing) will be rollbacked visually and only the latest click result (starting from the DOM state before the first click) will be applied. Long story short: spam click on every toggle option of all the social media, you will see that all your click will be processed one by one: - The first media you toggled off will be toggled off - Then the second media you toggled off will be toggled off but the first one will be back to toggle on. It seems to be correctly applying the click result one after the other, but always starting from the initial DOM state/option widget state (before the clicks), and not as it should: process the second click based on the state of things altered by the previous click. This will need a deeper and longer investigation to fix the root cause. In the meantime, as this tour is failing multiple times a day, this commit introduce a workaround to avoid this error in the tour. task-3212519 (later fix) runbot-16628 closes odoo#114589 X-original-commit: e9bd676 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Signed-off-by: Romain Derie (rde) <rde@odoo.com>
1 parent 84106a1 commit 02ce8aa

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

addons/website/static/tests/tours/snippet_social_media.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
import wTourUtils from 'website.tour_utils';
44

5+
// TODO: Remove following steps once fix of task-3212519 is done.
6+
// Those steps are preventing a race condition to happen in the meantime: when
7+
// the tour was clicking on the toggle to hide facebook in the next step, it
8+
// would actually "ignore" the result of the click on the toggle and would just
9+
// consider the action of focusing out the input.
10+
const socialRaceConditionClass = 'social_media_race_condition';
11+
const preventRaceConditionStep = [{
12+
content: "Wait a few ms to avoid race condition",
13+
// Ensure the class is remove from previous call of those steps
14+
extra_trigger: `body:not(.${socialRaceConditionClass})`,
15+
trigger: 'iframe .s_social_media',
16+
run() {
17+
setTimeout(() => {
18+
document.body.classList.add(socialRaceConditionClass);
19+
}, 500);
20+
}
21+
}, {
22+
content: "Check the race condition class is added after a few ms",
23+
trigger: `body.${socialRaceConditionClass}`,
24+
run() {
25+
document.body.classList.remove(socialRaceConditionClass);
26+
}
27+
}];
28+
529
const addNewSocialNetwork = function (optionIndex, linkIndex, url) {
630
return [{
731
content: "Click on Add New Social Network",
@@ -26,7 +50,9 @@ const addNewSocialNetwork = function (optionIndex, linkIndex, url) {
2650
content: "Ensure new link is changed",
2751
trigger: `iframe .s_social_media:has(a:eq(${linkIndex})[href='${url}'])`,
2852
run: () => {}, // This is a check.
29-
}];
53+
},
54+
...preventRaceConditionStep,
55+
];
3056
};
3157

3258
wTourUtils.registerWebsitePreviewTour('snippet_social_media', {
@@ -58,6 +84,7 @@ wTourUtils.registerWebsitePreviewTour('snippet_social_media', {
5884
trigger: 'we-list table input:eq(6)[data-media="facebook"]',
5985
run: () => {}, // This is a check.
6086
},
87+
...preventRaceConditionStep,
6188
// Create a Link for which we don't have an icon to propose.
6289
...addNewSocialNetwork(7, 6, 'https://whatever.it/1EdSw9X'),
6390
// Create a custom instagram link.
@@ -87,6 +114,7 @@ wTourUtils.registerWebsitePreviewTour('snippet_social_media', {
87114
":has(a:eq(5)[href='https://www.paypal.com/abc']:has(i.fa-paypal))",
88115
run: () => {}, // This is a check.
89116
},
117+
...preventRaceConditionStep,
90118
{
91119
content: 'Delete the custom link',
92120
trigger: 'we-list we-button.o_we_select_remove_option',

0 commit comments

Comments
 (0)