From d0cd971afb518f449ab6c60cef33e6fe0b7ea1f9 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 28 Feb 2019 14:19:22 +0000 Subject: [PATCH] [FIX] website_links: fix remaining bugs and restore skipped test This commit is following c78da8a80 that fixed website_links module. We had to merge it with a skipped test as there was an error only appearing with Docker (on runbot or on local with Docker). This commit fix that test error and some other remaining bugs not found during the first fix: 1. Fix the test error by adding a step to show recently used links. Indeed the bug was that newest links would return inconsistent order as both 2 links created during the steps have the same creation date. On runbot it would click on the wrong link, the one which has 0 clicks. Then JS would crash (see error bellow). 2. `websiteLinksCharts` JS animation class would execute all the `start` method code even if there was no `_totalClicks`. JS would then crash as `beginDate` would not be set correctly. Before the refactoring all that code would be skipped as surrounded by an if/else condition. 3. BS3 to BS4 broke the nav-tabs layout to switch between 'Newest, Most Clicked and Recently Used. `mt16` needed to be removed. Closes #31829 --- addons/website_links/static/src/js/test_ui_flow.js | 6 +++++- addons/website_links/static/src/js/website_links_charts.js | 1 + addons/website_links/tests/test_ui.py | 2 -- addons/website_links/views/website_links_template.xml | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/website_links/static/src/js/test_ui_flow.js b/addons/website_links/static/src/js/test_ui_flow.js index 4d8c7def0f9..584fc38c65d 100644 --- a/addons/website_links/static/src/js/test_ui_flow.js +++ b/addons/website_links/static/src/js/test_ui_flow.js @@ -52,9 +52,13 @@ tour.register('website_links_tour', { }, }, // 3. Check that counter got incremented and charts are correctly displayed + { + content: "filter recently used links", + trigger: '#filter-recently-used-links', + }, { content: "visit link stats page", - trigger: '#o_website_links_recent_links a:containsExact("Stats"):first()', + trigger: '#o_website_links_recent_links a:containsExact("Stats"):first', }, { content: "check click number and ensure graphs are initialized", diff --git a/addons/website_links/static/src/js/website_links_charts.js b/addons/website_links/static/src/js/website_links_charts.js index bd2e3ba2747..64da6aa6388 100644 --- a/addons/website_links/static/src/js/website_links_charts.js +++ b/addons/website_links/static/src/js/website_links_charts.js @@ -183,6 +183,7 @@ sAnimations.registry.websiteLinksCharts = sAnimations.Class.extend({ $('#all_time_charts').prepend(_t("There is no data to show")); $('#last_month_charts').prepend(_t("There is no data to show")); $('#last_week_charts').prepend(_t("There is no data to show")); + return; } var formattedClicksByDay = {}; diff --git a/addons/website_links/tests/test_ui.py b/addons/website_links/tests/test_ui.py index 58a697ef7a1..6a8e317eab1 100644 --- a/addons/website_links/tests/test_ui.py +++ b/addons/website_links/tests/test_ui.py @@ -1,13 +1,11 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import odoo.tests -import unittest @odoo.tests.common.tagged('post_install', '-at_install') class TestUi(odoo.tests.HttpCase): - @unittest.skip("Race condition on runbot or on local with Docker. Merging the test skipped for history purpose as the tour has been reviewed.") def test_01_test_ui(self): self.env['link.tracker'].create({ 'campaign_id': 2, diff --git a/addons/website_links/views/website_links_template.xml b/addons/website_links/views/website_links_template.xml index aca362bc40c..626ec232e53 100644 --- a/addons/website_links/views/website_links_template.xml +++ b/addons/website_links/views/website_links_template.xml @@ -87,7 +87,7 @@

Your tracked links - +