From 3eaddbd76f258ee847f34cd12b51f8bd460e4839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Wed, 13 Dec 2023 10:23:16 +0100 Subject: [PATCH] [FIX] survey: fix nondeterministic runbot issue This commit fixes a nondeterministic runbot issue during the survey session management tour suite (that actually contains multiple tours). It turns out that the first tour is so short that it does not let enough time to the web framework to correctly initialize everything before it gets killed (as the tour steps are completed almost instantly). It's hard to say exactly where the issue comes from, as the error does not mention anything (we only know that it's a rejected promise): """ Error received after termination: PromiseRejectionEvent( isTrusted=true, reason=Event, type='unhandledrejection', target=Window, currentTarget=Window)" """ Removing this first tour also removes the nondeterministic issue. It seems like an acceptable compromise as this tour was not really testing anything anyway, we now directly start the session from the python code. (Note: this issue only started occurring in v17). Task-3637591 closes odoo/odoo#146107 Signed-off-by: Thibault Delavallee (tde) --- .../tests/tours/survey_tour_session_create.js | 24 ------------------- addons/survey/tests/test_survey_ui_session.py | 9 ++++--- 2 files changed, 4 insertions(+), 29 deletions(-) delete mode 100644 addons/survey/static/tests/tours/survey_tour_session_create.js diff --git a/addons/survey/static/tests/tours/survey_tour_session_create.js b/addons/survey/static/tests/tours/survey_tour_session_create.js deleted file mode 100644 index f6546ace474..00000000000 --- a/addons/survey/static/tests/tours/survey_tour_session_create.js +++ /dev/null @@ -1,24 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; -import { accessSurveysteps } from "./survey_tour_session_tools"; - -/** - * Small tour that will simply start the session and wait for attendees. - */ -registry.category("web_tour.tours").add("test_survey_session_create_tour", { - url: "/web", - test: true, - steps: () => { - return [ - ...accessSurveysteps, - { - trigger: 'button[name="action_start_session"]', - }, - { - trigger: '.o_survey_session_attendees_count:contains("0")', - run: function () {}, // check session is correctly started - }, - ]; - }, -}); diff --git a/addons/survey/tests/test_survey_ui_session.py b/addons/survey/tests/test_survey_ui_session.py index 2046e8efe6d..787b61aab06 100644 --- a/addons/survey/tests/test_survey_ui_session.py +++ b/addons/survey/tests/test_survey_ui_session.py @@ -139,9 +139,6 @@ class TestUiSession(HttpCase): (4, timed_scored_choice_answer_3.id)], }) - # ======================= - # PART 1 : CREATE SESSION - # ======================= def action_open_session_manager_mock(self): """ Mock original method to ensure we are not using another tab as it creates issues with automated tours. """ @@ -152,9 +149,11 @@ class TestUiSession(HttpCase): 'url': '/survey/session/manage/%s' % self.access_token } - with patch('odoo.addons.survey.models.survey_survey.Survey.action_open_session_manager', action_open_session_manager_mock): - self.start_tour('/web', 'test_survey_session_create_tour', login='admin') + # ======================= + # PART 1 : CREATE SESSION + # ======================= + survey_session.action_start_session() # tricky part: we only take into account answers created after the session_start_time # the create_date of the answers we just saved is set to the beginning of the test. # but the session_start_time is set after that.