From 7c66694cdb6a858428683ddd0153c664b755d16a Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Wed, 9 Nov 2022 08:46:43 +0000 Subject: [PATCH] [FIX] website: add a test on snippet cache The last two parent of this commit introduced fixes towards the Snippet Cache, more specifically, the snippet cache according to the snippet language. Commit [1] introduced a Snippet template "Cache" that keeps the snippet templates in memory throughout multiple instantiation of the SnippetsMenu. Unfortunately, while this improved performance, it also introduced bugs where the cache was not properly cleared. Starting the edition in translate mode, then switching back to master edit mode would sometimes lead to the Snippets being loaded in the wrong language. The parent commits fix that but this one introduces a test to make the snippet cache and translation more robust. [1]: https://github.com/odoo/odoo/commit/03c552690b15cbf2e7d6b7812386ac64042219af#diff-52a4f9d2c217548e69e6b7fd097f286f1754a6389734eea254b87255e501cbefR18 closes odoo/odoo#108643 X-original-commit: a066dc8319cc9c204656a25af16fc78ae618cd71 Signed-off-by: Romain Derie (rde) --- .../static/tests/tours/snippet_translation.js | 37 +++++++++++++++++++ addons/website/tests/test_ui.py | 6 +++ 2 files changed, 43 insertions(+) diff --git a/addons/website/static/tests/tours/snippet_translation.js b/addons/website/static/tests/tours/snippet_translation.js index de899aff183..29fe287429f 100644 --- a/addons/website/static/tests/tours/snippet_translation.js +++ b/addons/website/static/tests/tours/snippet_translation.js @@ -19,3 +19,40 @@ wTourUtils.registerWebsitePreviewTour('snippet_translation', { run: () => null, // it's a check }, ]); +wTourUtils.registerWebsitePreviewTour('snippet_translation_changing_lang', { + url: '/', + test: true, +}, [ + { + content: "Change language to Parseltongue", + trigger: 'iframe .js_language_selector .btn', + }, + { + content: "Change the language to English", + trigger: 'iframe .js_language_selector .js_change_lang[data-url_code="en"]', + }, + { + content: "Enable translation", + trigger: '.o_translate_website_container a', + }, + { + content: "Close the dialog", + trigger: '.modal-footer .btn-primary', + }, + ...wTourUtils.clickOnSave(), + { + content: "Click on edit in master", + trigger: '.o_edit_website_container a', + }, + { + content: "Wait for edit mode to start", + trigger: '.o_website_preview.editor_enable.editor_has_snippets', + timeout: '30000', + }, + wTourUtils.dragNDrop({name: 'Cover'}), + { + content: "Check that contact us contain Parseltongue", + trigger: 'iframe .s_cover .btn-primary:contains("Contact us in Parseltongue")', + run: () => null, // it's a check + }, +]); diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 3aec455db39..d8552c32b55 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -182,8 +182,14 @@ class TestUiTranslate(odoo.tests.HttpCase): 'language_ids': [(6, 0, [parseltongue.id])], 'default_lang_id': parseltongue.id, }) + website_2 = self.env['website'].create({ + 'name': 'website en_US', + 'language_ids': [(6, 0, [self.env.ref('base.lang_en').id, parseltongue.id])], + 'default_lang_id': parseltongue.id, + }) self.start_tour(f"/website/force/{website.id}", 'snippet_translation', login='admin') + self.start_tour(f"/website/force/{website_2.id}", 'snippet_translation_changing_lang', login='admin') @odoo.tests.common.tagged('post_install', '-at_install')