From 9cac574db7e02abc1d76f0ae04584b4f7bf2c6c1 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 27 Dec 2022 16:32:05 +0000 Subject: [PATCH] [FIX] website: avoid race conditions during gray color palette tour The "website_gray_color_palette" tour recently failed 4 times during staging build on runbot, out of those 4 caught times, it seems that: A) 3 were because the last step was marked as failed too soon (screenshots and logs seem to indicate the editor was still loading). B) 1 was because of a "random" asset error (traceback when lazy loading the editor JS). The cause of (B) was not found and should be later investigated if seen again. This commit tries to avoid (A) which is probably related to a known issue: when the website iframe has to reload it may sometimes take more time than is allowed by the default timeout of tour steps. Some improvements regarding that will be made at [1] and probably by further PR after that (improving the editor loading speed in general). Meanwhile, this commit reviews the tour to not save the editor as it was actually not needed in this tour (nothing has to be saved). [1]: https://github.com/odoo/odoo/pull/100122 runbot-14112 closes odoo/odoo#108747 X-original-commit: fa1819f09948c64ff7acf634eed075515f6a01d2 Signed-off-by: Quentin Smetz (qsm) --- .../static/tests/tours/gray_color_palette.js | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/addons/website/static/tests/tours/gray_color_palette.js b/addons/website/static/tests/tours/gray_color_palette.js index bb1ce0fad13..19228c0c67d 100644 --- a/addons/website/static/tests/tours/gray_color_palette.js +++ b/addons/website/static/tests/tours/gray_color_palette.js @@ -1,6 +1,25 @@ /** @odoo-module **/ import wTourUtils from 'website.tour_utils'; +function waitForCSSReload() { + return [ + { + // This step is here because the option is applied but triggers a + // reloading of the CC value, so if the second value is sent too + // soon, it will be ignored. Clicking on the snippet tab and back + // will ensure that the mutex is cleared, and therefore we can apply + // the saturation step. + content: "Click on the blocks tab and back on theme to ensure the changes are applied", + trigger: '.o_we_add_snippet_btn', + }, + { + content: "Go back to theme options", + trigger: '.o_we_customize_theme_btn', + extra_trigger: '#o_scroll', + }, + ]; +} + wTourUtils.registerWebsitePreviewTour('website_gray_color_palette', { test: true, url: '/', @@ -24,19 +43,7 @@ wTourUtils.registerWebsitePreviewTour('website_gray_color_palette', { slider.dispatchEvent(new InputEvent('change', {bubbles: true})); }, }, - { - // This step is here because the option is applied but triggers a reloading of the - // css value, so if the second value is sent too soon, it will be ignored. - // Clicking on the snippet tab and back will ensure that the mutex is cleared, - // and therefore we can apply the saturation step. - content: "Click on the blacks tab and back on theme to ensure the changes are applied", - trigger: '.o_we_add_snippet_btn', - }, - { - content: "Go back to theme options", - trigger: '.o_we_customize_theme_btn', - extra_trigger: '#o_scroll', - }, + ...waitForCSSReload(), { content: "Drag the saturation slider", trigger: '.o_we_user_value_widget[data-param="gray-extra-saturation"]', @@ -47,10 +54,10 @@ wTourUtils.registerWebsitePreviewTour('website_gray_color_palette', { slider.dispatchEvent(new InputEvent('change', {bubbles: true})); } }, - ...wTourUtils.clickOnSave(), + ...waitForCSSReload(), { content: "Wait for the iframe to be loaded", - trigger: 'iframe body:not(.editor_enable)', + trigger: 'iframe body', run: () => { const iframeEl = document.querySelector('.o_website_preview .o_iframe'); const styles = iframeEl.contentWindow.getComputedStyle(iframeEl.contentDocument.documentElement);