Files
odoo_source/addons/website/static/tests/tours/conditional_visibility.js
T
qsm-odoo accb4b3245 [IMP] website, *: review website tour utils
*: test_website, website_blog, website_crm, website_event,
   website_forum, website_hr_recruitment, website_mass_mailing,
   website_sale, website_sale_wishlist, website_slides

- Make sure that all website tours reaching the website preview before
  their first step use the related website util to register their tour.

- Rename the website util to register a tour starting on the website
  preview from `registerEditionTour` to `registerWebsitePreviewTour`.
  Having a method using "Edition" in its name and having a boolean
  parameter named `edition` was a bit... strange.

- For both non edit mode and edit mode as a first step, ensure the util
  sets a high timeout for the first step. Indeed loading both the
  backend and the frontend (in the iframe) and potentially starting the
  edit mode can take a long time in automatic tests. We'll try and
  decrease the need for this high timeout of course.

- Review the implementation of those utils to be more consistent and
  also fix one or two mistakes in them.

closes odoo/odoo#100024

Related: odoo/design-themes#588
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-09-12 17:33:39 +02:00

59 lines
1.7 KiB
JavaScript

/** @odoo-module */
import wTourUtils from 'website.tour_utils';
const snippets = [
{
id: 's_text_image',
name: 'Text - Image',
},
];
wTourUtils.registerWebsitePreviewTour('conditional_visibility_1', {
edition: true,
url: '/',
test: true,
}, [
wTourUtils.dragNDrop(snippets[0]),
wTourUtils.clickOnSnippet(snippets[0]),
wTourUtils.changeOption('ConditionalVisibility', 'we-toggler'),
{
content: 'click on conditional visibility',
trigger: '[data-name="visibility_conditional"]',
run: 'click',
},
{
content: 'click on utm medium toggler',
trigger: '[data-save-attribute="visibilityValueUtmMedium"] we-toggler',
run: 'click',
},
{
trigger: '[data-save-attribute="visibilityValueUtmMedium"] we-selection-items [data-add-record="Email"]',
content: 'click on Email',
run: 'click',
},
...wTourUtils.clickOnSave(),
{
content: 'Check if the rule was applied',
extra_trigger: '.o_website_preview:only-child',
trigger: 'iframe #wrap',
run: function (actions) {
const style = window.getComputedStyle(this.$anchor[0].getElementsByClassName('s_text_image')[0]);
if (style.display !== 'none') {
console.error('error This item should be invisible and only visible if utm_medium === email');
}
},
},
wTourUtils.clickOnEdit(),
{
content: 'Check if the element is visible as it should always be visible in edit view',
extra_trigger: 'body.editor_has_snippets',
trigger: 'iframe #wrap .s_text_image',
run: function (actions) {
const style = window.getComputedStyle((this.$anchor[0]));
if (style.display === 'none') {
console.error('error This item should now be visible because utm_medium === email');
}
},
},
]);