[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) <tde@openerp.com>
This commit is contained in:
Julien Castiaux
2024-01-22 19:01:03 +00:00
parent b4ccdb34b6
commit 09093a51ae
2 changed files with 22 additions and 3 deletions
@@ -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);
});
},
@@ -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 () {