[IMP] website: make the test not rely on .pot

Before this commit, the "click on save" in french step was checking for
the element containing the "Save" french translation term, which is
coming from Transifex.
It sometimes changes, making the tour fail.
It was "Sauver", then "Sauvegarder" and now "Enregistrer".

This was a well known issue as we already made a quick and dirty fix for
that with [1].
It was judged enough as we did not want to spend more time on this fix
as it was expected to not break anytime soon, and we needed a quick fix.

The chance is now taken to adapt the test to not rely anymore on the
.pot file.

We also take the chance to not use an existant translation but a fake
one as it will speed up the test (no need to actually read/parse .po
files are there is none for this lang).

[1]: https://github.com/odoo/odoo/commit/594ac2c9651f27cc1623fcd5b916cb191241651b

runbot-22946
runbot-22945

closes odoo/odoo#127493

X-original-commit: 6d9d4d1b43544ae98cc8037ba01c81b66ab9f0ee
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Romain Derie
2023-07-05 18:47:01 +02:00
parent 2950c449de
commit 577cfc9e7f
2 changed files with 19 additions and 14 deletions
@@ -48,7 +48,7 @@ registry.category("web_tour.tours").add('configurator_translation', {
// Features screen
{
content: "select confidentialité",
trigger: '.card:contains(confidentialité)',
trigger: '.card:contains(Parseltongue_privacy)',
}, {
content: "Click on build my website",
trigger: 'button.btn-primary',
@@ -62,16 +62,10 @@ registry.category("web_tour.tours").add('configurator_translation', {
timeout: 30000,
}, {
// Check the content of the save button to make sure the website is in
// French. (The editor should be in the website's default language,
// which should be french in this test.)
// Also note that sometimes the translation is being changed on
// Transifex from "Sauvegarder" to "Sauver" or the other way around.
// TODO: Strengthen this tour by creating a new fake language and some
// translations for the checked terms. See what's done in `Sign`
// `test_translate_sign_instructions` tour with the `Parseltongue`
// language.
// Parseltongue. (The editor should be in the website's default language,
// which should be parseltongue in this test.)
content: "exit edit mode",
trigger: '.o_we_website_top_actions button.btn-primary:contains("Sauvegarder"), .o_we_website_top_actions button.btn-primary:contains("Sauver")',
trigger: '.o_we_website_top_actions button.btn-primary:contains("Save_Parseltongue")',
}, {
content: "wait for editor to be closed",
trigger: 'iframe body:not(.editor_enable)',
+15 -4
View File
@@ -19,7 +19,7 @@ class TestConfiguratorCommon(odoo.tests.HttpCase):
params = kwargs.get('params', {})
language = params.get('lang', 'en_US')
if endpoint.endswith('/api/website/1/configurator/industries'):
if language == 'fr_FR':
if language in ('fr_FR', 'pa_GB'):
return {"industries": [
{"id": 1, "label": "abbey in fr"},
{"id": 2, "label": "aboriginal and torres strait islander organisation in fr"},
@@ -50,16 +50,27 @@ class TestConfiguratorCommon(odoo.tests.HttpCase):
class TestConfiguratorTranslation(TestConfiguratorCommon):
def test_01_configurator_translation(self):
parseltongue = self.env['res.lang'].create({
'name': 'Parseltongue',
'code': 'pa_GB',
'iso_code': 'pa_GB',
'url_code': 'pa_GB',
})
self.env["base.language.install"].create({
'overwrite': True,
'lang_ids': [(6, 0, [self.env.ref('base.lang_fr').id])],
'lang_ids': [(6, 0, [parseltongue.id])],
}).lang_install()
feature = self.env['website.configurator.feature'].search([('name', '=', 'Privacy Policy')])
feature.with_context(lang='fr_FR').write({'name': 'Politique de confidentialité'})
self.env.ref('base.user_admin').write({'lang': self.env.ref('base.lang_fr').code})
feature.with_context(lang=parseltongue.code).write({'name': 'Parseltongue_privacy'})
self.env.ref('base.user_admin').write({'lang': parseltongue.code})
website_fr = self.env['website'].create({
'name': "New website",
})
self.env.ref('web_editor.snippets').update_field_translations('arch_db', {
parseltongue.code: {
'Save': 'Save_Parseltongue'
}
})
# disable configurator todo to ensure this test goes through
active_todo = self.env['ir.actions.todo'].search([('state', '=', 'open')], limit=1)
active_todo.update({'state': 'done'})