Files
odoo_source/addons/website/tests/test_configurator.py
T
Romain Derie 577cfc9e7f [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>
2023-07-05 18:47:01 +02:00

78 lines
3.5 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from unittest.mock import patch
import odoo.tests
class TestConfiguratorCommon(odoo.tests.HttpCase):
def _theme_upgrade_upstream(self):
# patch to prevent module install/upgrade during tests
pass
def setUp(self):
super().setUp()
def iap_jsonrpc_mocked_configurator(*args, **kwargs):
endpoint = args[0]
params = kwargs.get('params', {})
language = params.get('lang', 'en_US')
if endpoint.endswith('/api/website/1/configurator/industries'):
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"},
{"id": 3, "label": "aboriginal art gallery in fr"},
{"id": 4, "label": "abortion clinic in fr"},
{"id": 5, "label": "abrasives supplier in fr"},
{"id": 6, "label": "abundant life church in fr"}]}
else:
return {"industries": [
{"id": 1, "label": "abbey"},
{"id": 2, "label": "aboriginal and torres strait islander organisation"},
{"id": 3, "label": "aboriginal art gallery"},
{"id": 4, "label": "abortion clinic"},
{"id": 5, "label": "abrasives supplier"},
{"id": 6, "label": "abundant life church"}]}
elif '/api/website/2/configurator/recommended_themes' in endpoint:
return []
elif '/api/website/2/configurator/custom_resources/' in endpoint:
return {'images': {}}
iap_patch = patch('odoo.addons.iap.tools.iap_tools.iap_jsonrpc', iap_jsonrpc_mocked_configurator)
self.startPatcher(iap_patch)
patcher = patch('odoo.addons.website.models.ir_module_module.IrModuleModule._theme_upgrade_upstream', wraps=self._theme_upgrade_upstream)
self.startPatcher(patcher)
@odoo.tests.common.tagged('post_install', '-at_install')
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, [parseltongue.id])],
}).lang_install()
feature = self.env['website.configurator.feature'].search([('name', '=', 'Privacy Policy')])
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'})
self.start_tour('/website/force/%s?path=%%2Fwebsite%%2Fconfigurator' % website_fr.id, 'configurator_translation', login='admin')