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 () {