diff --git a/addons/website/models/website.py b/addons/website/models/website.py index c4fc144f33e..22c39daae89 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -1281,6 +1281,9 @@ class Website(models.Model): def button_go_website(self, path='/', mode_edit=False): self._force() if mode_edit: + # If the user gets on a translated page (e.g /fr) the editor will + # never start. Forcing the default language fixes this issue. + path = url_for(path, self.default_lang_id.url_code) path += '?enable_editor=1' return { 'type': 'ir.actions.act_url', diff --git a/addons/website/static/tests/tours/automatic_editor.js b/addons/website/static/tests/tours/automatic_editor.js new file mode 100644 index 00000000000..5e8dc5b2efe --- /dev/null +++ b/addons/website/static/tests/tours/automatic_editor.js @@ -0,0 +1,95 @@ +odoo.define('website.tour.automatic_editor', function (require) { +'use strict'; + +const tour = require('web_tour.tour'); + +tour.register('automatic_editor_on_new_website', { + test: true, + url: '/', +}, +[ + { + content: "Select the language dropdown", + trigger: '.js_language_selector .dropdown-toggle' + }, + { + content: "click on Add a language", + trigger: 'a.o_add_language', + }, + { + content: "Select dropdown", + trigger: 'select[name=lang]', + run: () => { + $('select[name="lang"]').val('"pa_GB"').change(); + } + }, + { + content: "load parseltongue", + extra_trigger: '.modal select[name="lang"]:propValueContains(pa_GB)', + trigger: '.modal-footer button:first', + }, + { + content: "Select the language dropdown", + trigger: '.js_language_selector .dropdown-toggle', + }, + { + content: "Select parseltongue", + trigger: 'a.js_change_lang[data-url_code=pa_GB]', + }, + { + content: "Check that we're on parseltongue and then go to settings", + trigger: 'html[lang=pa-GB]', + run: () => { + // Now go through the settings for a new website. A frontend_lang + // cookie was set during previous steps. It should not be used when + // redirecting to the frontend in the following steps. + window.location.href = '/web#action=website.action_website_configuration'; + } + }, + { + content: "create a new website", + trigger: 'button[name="action_website_create_new"]', + }, + { + content: "insert website name", + trigger: 'input[name="name"]', + run: 'text Website EN' + }, + { + content: "validate the website creation modal", + trigger: 'button.btn-primary' + }, + { + content: "skip configurator", + // This trigger targets the skip button, it doesn't have a more + // explicit class or ID. + trigger: '.o_configurator_container .container-fluid .btn.btn-link' + }, + { + content: "make hover button appear", + trigger: '.o_theme_preview', + run: () => { + $('.o_theme_preview .o_button_area').attr('style', 'visibility: visible; opacity: 1;'); + }, + }, + { + content: "Install a theme", + trigger: 'button[data-name="button_choose_theme"]' + }, + { + content: "Check that the editor is loaded", + trigger: 'body.editor_enable', + timeout: 30000, + run: () => null, // it's a check + }, + { + content: "exit edit mode", + trigger: '.o_we_website_top_actions button.btn-primary:contains("Save")', + }, + { + content: "wait for editor to close", + trigger: 'body:not(.editor_enable)', + run: () => null, // It's a check + } +]); +}); diff --git a/addons/website/tests/__init__.py b/addons/website/tests/__init__.py index c01e33f3057..de00979d8f9 100644 --- a/addons/website/tests/__init__.py +++ b/addons/website/tests/__init__.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import test_attachment from . import test_auth_signup_uninvited +from . import test_automatic_editor from . import test_base_url from . import test_configurator from . import test_controllers diff --git a/addons/website/tests/test_automatic_editor.py b/addons/website/tests/test_automatic_editor.py new file mode 100644 index 00000000000..13f3ddced14 --- /dev/null +++ b/addons/website/tests/test_automatic_editor.py @@ -0,0 +1,17 @@ +from odoo.tests import tagged +from odoo.addons.website.tests.test_configurator import TestConfiguratorCommon + +@tagged('post_install', '-at_install') +class TestAutomaticEditor(TestConfiguratorCommon): + + def test_01_automatic_editor_on_new_website(self): + # We create a lang because if the new website is displayed in this lang + # instead of the website's default one, the editor won't automatically + # start. + self.env['res.lang'].create({ + 'name': 'Parseltongue', + 'code': 'pa_GB', + 'iso_code': 'pa_GB', + 'url_code': 'pa_GB', + }) + self.start_tour('/', 'automatic_editor_on_new_website', login='admin')