* The tours are now run by the `MacroEngine` defined in `macro.js`.
* This is accomplished by converting (at runtime) the user-defined tours to
`Macro`s. See `tour_compilers.js` for the step (and tour-to-macro) compilation.
* API is kept the same as much as possible. Basically, declaring tours stayed
the same with some exceptions:
* `allowInvisible` can be provided in a step to allow consuming the trigger
element even if it is invisible.
* `isCheck` can now be used to replace the no operation `run` that is
traditionally signals the runner to only perform a check.
* Before, multiple `run`s can be called simultaneously. Now, each `run` method
is awaited before proceeding to the next step.
* If the trigger element is `disabled`, the tour runner will *not* proceed on
calling the `run` method and the runner will stay on current step until the
trigger element becomes `enabled`.
* However, the tour runner is okay with `disabled` trigger element if the step
has `isCheck = true`. As long as the trigger element is found for `isCheck`
step, the tour runner will happily move to the next step.
* Some tours are adjusted to properly run with this new tour runner.
* When the tour failed:
* The dom string is not logged anymore.
* However, a warning message containing the relative location of the step will
be logged. This is better in helping the author in locating the failed step.
**Some guidelines learned during the development:**
* Each step may trigger a dom mutation. It's a good practice to insert an
intermediate step that *checks* the existence of an element that result from
the action of the previous step.
* Refrain from using the `run` method for assertions. `run`, in principle, is
provided to perform actions that are not offered by the helper. Use the
`trigger` for assertions.
* During dev, find `SHOW_POINTER_DURATION` and set it to `250`. This will show
the pointer (pointing to the trigger element) for 250ms when watching the
tour.
closes odoo/odoo#107618
Task-id: 3082036
Related: odoo/enterprise#37560
Signed-off-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
60 lines
1.8 KiB
JavaScript
60 lines
1.8 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',
|
|
allowInvisible: true,
|
|
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');
|
|
}
|
|
},
|
|
},
|
|
]);
|