From 09093a51ae6cb5fa95196e6a9c06757abe526da2 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 13 Dec 2023 16:09:30 +0100 Subject: [PATCH] [FIX] survey: bad orm.read usage when updating attendees count Start a live session, on the manager side stay on the welcome page (the one that counts how many attendees joined). Using several other private browsing tabs join the live session. On the manager side, the number of attendees never changes. During a previous refactoring of legacy rpc => orm, an error slipped, instead the records and fields as separated arguments, the two were passed together as a list in a single argument. We used the opportunity to increase the verbosity in case of errors and to enrich our test cases. Fine tunning of 7422eb6 ([IMP] *: remove legacy rpc) Task-2834638 closes odoo/odoo#149427 Signed-off-by: Thibault Delavallee (tde) --- .../static/src/js/survey_session_manage.js | 6 ++++-- .../tests/tours/survey_tour_session_start.js | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/addons/survey/static/src/js/survey_session_manage.js b/addons/survey/static/src/js/survey_session_manage.js index aacca6a1565..ff094745bec 100644 --- a/addons/survey/static/src/js/survey_session_manage.js +++ b/addons/survey/static/src/js/survey_session_manage.js @@ -496,16 +496,18 @@ publicWidget.registry.SurveySessionManage = publicWidget.Widget.extend(SurveyPre return self.orm.read( "survey.survey", - [[self.surveyId], ['session_answer_count']] + [self.surveyId], + ['session_answer_count'], ).then(function (result) { if (result && result.length === 1){ self.$('.o_survey_session_attendees_count').text( result[0].session_answer_count ); } - }, function () { + }, function (err) { // on failure, stop refreshing clearInterval(self.attendeesRefreshInterval); + console.error(err); }); }, diff --git a/addons/survey/static/tests/tours/survey_tour_session_start.js b/addons/survey/static/tests/tours/survey_tour_session_start.js index f357ca1bd70..1e43ffa8cbc 100644 --- a/addons/survey/static/tests/tours/survey_tour_session_start.js +++ b/addons/survey/static/tests/tours/survey_tour_session_start.js @@ -15,7 +15,24 @@ registry.category("web_tour.tours").add('test_survey_session_start_tour', { trigger: 'button[name="action_open_session_manager"]', }, { trigger: '.o_survey_session_attendees_count:contains("3")', - run: function () {} // check attendees count + run: function () { + /* We want to test 2 things: (1) that the attendees count is right + on the rendered xml template and (2) that the attendees count + gets correctly updated every 2 seconds via JS. + + This step did verify the one on the xml template, we now change + the value back to 0 to test that in 2 seconds it'll be updated + by JS. + + The "waitrpc" class just serves to rule out concurrency issues + between this step's run and the next step's trigger. */ + const elem = document.querySelector('.o_survey_session_attendees_count'); + elem.classList.add("waitrpc"); + elem.textContent = '0'; + } +}, { + trigger: '.o_survey_session_attendees_count.waitrpc:contains("3")', + isCheck: true }, { trigger: 'h1', run: function () {