[IMP] website: make website_style_edition tour more runbot-friendly

The tour contains this part:

1. Change the font-size
2. Click on save
3. Check that edit mode was left
4. Check the font-size is ok

The problem is that step 1 induces a series of RPC and processing
(rebuilding assets, reloading them in the client, etc) but those are
not awaited before going into step 2 which also induces a RPC (the save)
which is only done once the other RPC are finished.

While we will try to optimize the duration of those RPC in the future.
Meanwhile we could simply increase to the timeout of step 3 but it seems
better to change the tour to divide the multiple things to await:

1. Change the font-size
2. Check the font-size is ok
3. Click on save
4. Check that edit mode was left
5. Check the font-size is still ok

runbot-4706

closes odoo/odoo#102609

X-original-commit: c2bc6c2f8446e98c8a4089daf048e67457be277f
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
qsm-odoo
2022-10-07 14:37:30 +02:00
parent f0b4171873
commit 0f2a9e4e85
@@ -5,6 +5,13 @@ const wTourUtils = require("website.tour_utils");
const TARGET_FONT_SIZE = 30;
const checkFontSize = function (actions) {
const style = actions.tip_widget.el.ownerDocument.defaultView.getComputedStyle(this.$anchor[0]);
if (style.fontSize !== `${TARGET_FONT_SIZE}px`) {
console.error(`Expected the font-size to be equal to ${TARGET_FONT_SIZE}px but found ${style.fontSize} instead`);
}
};
wTourUtils.registerWebsitePreviewTour("website_style_edition", {
test: true,
url: '/',
@@ -17,19 +24,23 @@ wTourUtils.registerWebsitePreviewTour("website_style_edition", {
content: "Change font size",
trigger: '[data-variable="font-size-base"] input',
run: `text_blur ${TARGET_FONT_SIZE}`,
},
...wTourUtils.clickOnSave(), {
}, {
content: "Check the font size was properly adapted",
trigger: 'iframe #wrapwrap',
// Waiting the CSS to be reloaded: the code adds a new assets bundle with
// a #t=... at the end then removes the old one.
extra_trigger: 'iframe html:not(:has(link[href$="web.assets_frontend.min.css"]))',
run: checkFontSize,
},
...wTourUtils.clickOnSave(),
{
content: "Check the font size is still ok outside of edit mode",
trigger: 'iframe body:not(.editor_enable) #wrapwrap',
run: function (actions) {
const style = actions.tip_widget.el.ownerDocument.defaultView.getComputedStyle(this.$anchor[0]);
if (style.fontSize !== `${TARGET_FONT_SIZE}px`) {
console.error(`Expected the font-size to be equal to ${TARGET_FONT_SIZE}px but found ${style.fontSize} instead`);
}
},
run: checkFontSize,
},
wTourUtils.clickOnEdit(),
wTourUtils.goToTheme(), {
wTourUtils.goToTheme(),
{
content: "Click on the Background Image selection",
trigger: '[data-customize-body-bg-type="\'image\'"]:not(.active)',
extra_trigger: '[data-customize-body-bg-type="NONE"].active',