Files
odoo_source/addons/website/static/tests/tours/snippet_version.js
T
Arthur Detroux (ard) 1dd75ea014 [FIX] website: fix a race condition on snippet_version tour
Commit [1] moved the edition of the website in the backend and
introduced an iframe as the editable. In doing so, some tour
actions became unstable.

The issue is that previously, when an action reloaded the page, the tour
service would reload as well. This is no longer the case and the tour
service stays active when the page is reloaded (e.g. when saving a
page). This can lead to a tour clicking on an item before it is ready to
be clicked.

Specifically in this case, the tour saved and clicked on edit as the
next step.
Clicking on edit before the page is properly reloaded leads to the click
being ignored.

This commit uses the util function `clickOnSave` which ensures we're out
of edit mode and the page is reloaded before doing anything else.

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

runbot-4074

closes odoo/odoo#94932

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-06-30 18:52:16 +02:00

62 lines
2.8 KiB
JavaScript

odoo.define("website.tour.snippet_version", function (require) {
"use strict";
const wTourUtils = require('website.tour_utils');
wTourUtils.registerEditionTour("snippet_version", {
edition: true,
url: "/",
test: true,
}, [{
content: "Drop s_test_snip snippet",
trigger: '#oe_snippets .oe_snippet:has(.s_test_snip) .oe_snippet_thumbnail',
run: "drag_and_drop iframe #wrap",
}, {
content: "Drop s_text_image snippet",
trigger: '#oe_snippets .oe_snippet:has(.s_text_image) .oe_snippet_thumbnail:not(.o_we_already_dragging)',
run: "drag_and_drop iframe #wrap",
}, {
content: "Test t-snippet and t-snippet-call: snippets have data-snippet set",
trigger: '#oe_snippets .o_panel_body > .oe_snippet.ui-draggable',
run: function () {
// Tests done here as all these are not visible on the page
const draggableSnippets = document.querySelectorAll('#oe_snippets .o_panel_body > .oe_snippet.ui-draggable > :nth-child(2)');
if (![...draggableSnippets].every(el => el.dataset.snippet)) {
console.error("error Some t-snippet are missing their template name");
}
if (!document.querySelector('#oe_snippets [data-snippet="s_test_snip"] [data-snippet="s_share"]')) {
console.error("error s_share t-called inside s_test_snip is missing template name");
}
if (!document.querySelector('iframe:not(.o_ignore_in_tour)').contentDocument.querySelector('#wrap [data-snippet="s_test_snip"] [data-snippet="s_share"]')) {
console.error("error Dropped a s_test_snip snippet but missing s_share template name in it");
}
},
},
...wTourUtils.clickOnSave(),
wTourUtils.clickOnEdit(),
{
content: "Modify the version of snippets",
trigger: '#oe_snippets .o_panel_body > .oe_snippet',
run: function () {
document.querySelector('#oe_snippets .oe_snippet > [data-snippet="s_test_snip"]').dataset.vjs = '999';
document.querySelector('#oe_snippets .oe_snippet > [data-snippet="s_share"]').dataset.vcss = '999';
document.querySelector('#oe_snippets .oe_snippet > [data-snippet="s_text_image"]').dataset.vxml = '999';
},
}, {
content: "Edit s_test_snip",
trigger: 'iframe #wrap.o_editable .s_test_snip',
}, {
content: "Edit text_image",
extra_trigger: 'we-customizeblock-options:contains(Test snip) .snippet-option-VersionControl > we-alert',
trigger: 'iframe #wrap.o_editable .s_text_image',
}, {
content: "Edit s_share",
extra_trigger: 'we-customizeblock-options:contains(Text - Image) .snippet-option-VersionControl > we-alert',
trigger: 'iframe #wrap.o_editable .s_share',
}, {
content: "s_share is outdated",
extra_trigger: 'we-customizeblock-options:contains(Share) .snippet-option-VersionControl > we-alert',
trigger: 'iframe body',
}]);
});