From 8066001ee4e1e38805f4b3564fcfae411e4856ea Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 5 Mar 2020 11:44:00 +0000 Subject: [PATCH] [FIX] website: add test for 5ac269d722f 5ac269d722f fixed 7e2b0ebe799 that prevented the website menu to actually be visible, since the JS in charge of displaying the menu was 'crashing'. A test was missing to avoid that issue to appear ever again, since it is quite a critical problem. Note that it might look strange that breaking such a mechanism does not make the runbot red, but since the menus are actually considered visible, the tests are able to 'see' it in DOM and click on it. They are actually hidden through an opacity 0 & height 0 while the JS process them. task-2093679 closes odoo/odoo#47138 X-original-commit: 0dc00a252dfe7fee658579a60dc7b1b1ca71a661 Signed-off-by: Quentin Smetz (qsm) --- .../static/tests/tours/website_navbar_menu.js | 20 +++++++++++++++++++ addons/website/tests/test_ui.py | 11 ++++++++++ addons/website/views/assets.xml | 1 + 3 files changed, 32 insertions(+) create mode 100644 addons/website/static/tests/tours/website_navbar_menu.js diff --git a/addons/website/static/tests/tours/website_navbar_menu.js b/addons/website/static/tests/tours/website_navbar_menu.js new file mode 100644 index 00000000000..e3523f69076 --- /dev/null +++ b/addons/website/static/tests/tours/website_navbar_menu.js @@ -0,0 +1,20 @@ +odoo.define("website.tour.website_navbar_menu", function (require) { +"use strict"; + +var tour = require("web_tour.tour"); + +tour.register("website_navbar_menu", { + test: true, + url: "/", +}, [ + { + content: "Ensure menus are in DOM", + trigger: '#top_menu .nav-item a:contains("Test Tour Menu")', + run: function () {}, // it's a check + }, { + content: "Ensure menus loading is done (so they are actually visible)", + trigger: 'body:not(:has(.o_menu_loading))', + run: function () {}, // it's a check + } +]); +}); diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 92f0796fc9b..d739ed877b6 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -110,6 +110,17 @@ class TestUi(odoo.tests.HttpCase): def test_03_backend_dashboard(self): self.start_tour("/", 'backend_dashboard', login='admin') + def test_04_website_navbar_menu(self): + website = self.env['website'].search([], limit=1) + self.env['website.menu'].create({ + 'name': 'Test Tour Menu', + 'url': '/test-tour-menu', + 'parent_id': website.menu_id.id, + 'sequence': 0, + 'website_id': website.id, + }) + self.start_tour("/", 'website_navbar_menu') + def test_05_specific_website_editor(self): website_default = self.env['website'].search([], limit=1) new_website = self.env['website'].create({'name': 'New Website'}) diff --git a/addons/website/views/assets.xml b/addons/website/views/assets.xml index a0d00feb356..1015427043b 100644 --- a/addons/website/views/assets.xml +++ b/addons/website/views/assets.xml @@ -25,6 +25,7 @@