[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) <rde@odoo.com>
This commit is contained in:
Arthur Detroux (ard)
2022-12-23 21:19:51 +01:00
committed by Romain Derie
parent 8d48efeece
commit 7c66694cdb
2 changed files with 43 additions and 0 deletions
@@ -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
},
]);
+6
View File
@@ -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')