summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Socias <bso@odoo.com>2020-11-27 11:00:19 +0000
committerBenoit Socias <bso@odoo.com>2020-11-27 11:00:19 +0000
commitdb3296c034fe4c82d19580418fd5cdecdf578395 (patch)
treee22eb913ef0236438211143dbf66ff4312049c0f
parent2a12393b68bbec9b76f1534b3e881c39348d8a0e (diff)
[FIX] website_links: not perform a request during automated test
This commit fixes the step trigger: '#o_website_links_link_tracker_form #generated_tracked_link:contains("/r/")' that was taking too long because of a call to _get_title_from_url happening during the creation of a 'link.tracker'. Before this commit the automated tests of website_links did trigger an http request on the 'contactus' page which sometimes took too long to respond and reached the test failure timeout. After this commit the information obtained from this request is hard-coded to avoid the unpredictable timing of the test. This commit is a manual port of #62479. task-2397724 closes odoo/odoo#62508 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
-rw-r--r--addons/website_links/static/tests/tours/website_links.js5
-rw-r--r--addons/website_links/tests/test_ui.py12
2 files changed, 13 insertions, 4 deletions
diff --git a/addons/website_links/static/tests/tours/website_links.js b/addons/website_links/static/tests/tours/website_links.js
index d958308c5f6..12984da2275 100644
--- a/addons/website_links/static/tests/tours/website_links.js
+++ b/addons/website_links/static/tests/tours/website_links.js
@@ -29,10 +29,7 @@ tour.register('website_links_tour', {
// 2. Visit it
{
content: "check that link was created and visit it",
- // Depending of the speed of `requests.get` from `_get_title_from_url`,
- // the link name will either be "About us" (page title) or
- // "http://url/aboutus" (page url).
- extra_trigger: '#o_website_links_recent_links .truncate_text:first():contains("Contact us"), #o_website_links_recent_links .truncate_text:first():contains("contactus")',
+ extra_trigger: '#o_website_links_recent_links .truncate_text:first():contains("Contact Us")',
trigger: '#o_website_links_link_tracker_form #generated_tracked_link:contains("/r/")',
run: function () {
window.location.href = $('#generated_tracked_link').text();
diff --git a/addons/website_links/tests/test_ui.py b/addons/website_links/tests/test_ui.py
index e21473b33a5..a78e54d7594 100644
--- a/addons/website_links/tests/test_ui.py
+++ b/addons/website_links/tests/test_ui.py
@@ -1,11 +1,23 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from unittest.mock import patch
+
import odoo.tests
@odoo.tests.common.tagged('post_install', '-at_install')
class TestUi(odoo.tests.HttpCase):
+ def setUp(self):
+ super(TestUi, self).setUp()
+
+ def _get_title_from_url(addr, **kw):
+ return 'Contact Us | My Website'
+
+ patcher = patch('odoo.addons.link_tracker.models.link_tracker.LinkTracker._get_title_from_url', wraps=_get_title_from_url)
+ patcher.start()
+ self.addCleanup(patcher.stop)
+
def test_01_test_ui(self):
self.env['link.tracker'].create({
'campaign_id': 2,