Files
odoo_source/addons/website/static/tests/tours/website_style_edition.js
T
qsm-odoo 0f2a9e4e85 [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>
2022-10-07 14:37:30 +02:00

53 lines
1.7 KiB
JavaScript

odoo.define("website.tour.website_style_edition", function (require) {
"use strict";
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: '/',
edition: true,
}, [{
content: "Go to theme options",
extra_trigger: '#oe_snippets.o_loaded',
trigger: '.o_we_customize_theme_btn',
}, {
content: "Change font size",
trigger: '[data-variable="font-size-base"] input',
run: `text_blur ${TARGET_FONT_SIZE}`,
}, {
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: checkFontSize,
},
wTourUtils.clickOnEdit(),
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',
}, {
content: "The media dialog should open",
trigger: '.o_select_media_dialog',
run: () => {}, // It's a check.
}]);
});