Skip to content

Commit

Permalink
[REF] web_tour: prepare to change the default action in tour_compiler
Browse files Browse the repository at this point in the history
Currently, in tour_compiler, to check that an element is actually
present in the DOM in a step, there are 2 possibilities.
- `isCheck: true` => Checks that the element is in the DOM.
The latter can be disabled.
- `run() {}` => Checks that the element is in the DOM (because this
is what is done by default). However, if the element is disabled,
the step will be aborted.

In the codebase, we can see a lot of `run() {} //it's a check` and
`isCheck:true`. However, the behavior is not exactly the same.
What's more, there are 2 ways to do "the same thing".
In order to clarify the turns API, it was decided to no longer put an
action (step.run) by default. (Previously, the default action was
the "click" action).
From then on, it is no longer necessary to stipulate
`step.isCheck: true` nor `run() {}`.
The corollary is that now, you must explicitly write `run: click`, if
you want the click action to be triggered on the target.

This commit sets the stage for making this change.

closes #801

Related: odoo/odoo#167743
Related: odoo/enterprise#63711
Signed-off-by: Julien Mougenot (jum) <[email protected]>
  • Loading branch information
pipu-odoo committed Jun 5, 2024
1 parent e93b187 commit b4c5bea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions theme_test_custo/static/tests/tours/theme_menu_hierarchies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', {
{
content: 'Check Mega Menu is correctly created',
trigger: ":iframe .top_menu a.o_mega_menu_toggle",
run: "click",
}, {
content: 'Check Mega Menu content',
trigger: ":iframe .top_menu div.o_mega_menu.show .fa-cube",
run: () => null, // It's a check.
}, {
content: 'Check new top level menu is correctly created',
trigger: ':iframe .top_menu .nav-item.dropdown .dropdown-toggle:contains("Example 1")',
run: "click",
}, {
content: 'Check sub menu are correctly created',
trigger: ':iframe .top_menu .dropdown-menu.show a.dropdown-item:contains("Item 1")',
Expand All @@ -35,27 +37,31 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', {
{
content: 'Click on footer',
trigger: ':iframe footer',
run: "click",
}, {
content: 'The theme custom footer template should be listed and selected',
trigger: 'we-select[data-variable="footer-template"] we-toggler img[src*="/theme_test_custo"]',
run: () => null, // It's a check.
}, {
content: 'Click on header',
trigger: ':iframe header',
run: "click",
}, {
content: 'The theme custom header template should be listed and selected',
trigger: 'we-select[data-variable="header-template"] we-toggler img[src*="/theme_test_custo"]',
run: () => null, // It's a check.
}, {
content: 'Click on image which has a shape',
trigger: ':iframe #wrap .s_text_image img[data-shape]',
run: "click",
}, {
content: 'The theme custom "Blob 01" shape should be listed and selected',
trigger: 'we-select[data-name="shape_img_opt"] we-toggler:contains("Blob 01")',
run: () => null, // It's a check.
}, {
content: 'Click on section which has a bg shape',
trigger: ':iframe #wrap .s_text_block[data-oe-shape-data]',
run: "click",
}, {
content: 'The theme custom "Curve 01" shape should be listed and selected',
trigger: 'we-select[data-name="bg_shape_opt"] we-toggler:contains("Curve 01")',
Expand Down
6 changes: 6 additions & 0 deletions theme_test_custo/static/tests/tours/website_theme_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,37 @@ registry.category("web_tour.tours").add("website_theme_preview", {
[{
content: "Click on create new website",
trigger: 'button[name="action_website_create_new"]',
run: "click",
}, {
content: "insert website name",
trigger: '[name="name"] input',
run: "text Website Test",
}, {
content: "Validate the website creation modal",
trigger: "button.btn-primary",
run: "click",
},
// Configurator first screen
{
content: "Click Skip and start from scratch",
trigger: "button:contains('Skip and start from scratch')",
run: "click",
}, {
content: "Click on the Live preview of a theme",
trigger: ".o_theme_preview .o_button_area .btn-secondary:contains('Live Preview')",
run: "click",
}, {
content: "Switch from desktop to mobile preview",
trigger: ".btn[for=themeViewerMobile]",
run: "click",
}, {
content: "Check that the mobile view is active",
trigger: ".o_view_form_theme_preview_controller .o_field_iframe > div.is_mobile:visible",
run: () => null, // it's a check
}, {
content: "Switch back to desktop",
trigger: ".btn[for=themeViewerDesktop]",
run: "click",
}, {
content: "Check that the desktop view is active",
trigger: ".o_view_form_theme_preview_controller .o_field_iframe > div:not(.is_mobile):visible",
Expand Down

0 comments on commit b4c5bea

Please sign in to comment.