[FIX] mail:tests: no undeterministic failure of discuss history test

Before this commit, the test 'all messages in "Inbox" in "History"
after marked all as read' had non-deterministic failures.

More precisely, it crashed on either assertion "there should be 30
messages in History" or "there should be 40 messages in History",
both resulting to 0 messages in History instead.

Unfortunately, as of the date of this commit, we still do not
understand why it rarely fails. In the meantime, we have decided to
make these errors less likely to happen, by waiting much longer
before the assertions. We are aware that this is a poor solution,
but this is much better than skipping the test, until we find and fix
this issue at a later moment.

Closes #43072

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2020-01-13 10:13:41 +00:00
parent 6a9b29ec9a
commit 2f3e6e9ea8
+30 -2
View File
@@ -1818,8 +1818,16 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
discuss.destroy();
});
QUnit.test('all messages in "Inbox" in "History" after marked all as read', async function (assert) {
assert.expect(10)
QUnit.test('all messages in "Inbox" in "History" after marked all as read', async function (assert) {
/**
* FIXME: for some reasons, this test may crash non-deterministically on
* runbot around once every hundreds of builds. As of the writing of this
* comment, no explanation has been found, so extra `nextTick()` have been
* added in the meantime. This work-around sucks, but this is better than
* skipping this test, until we find the issue and fix it properly in the
* future.
*/
assert.expect(10);
const messagesData = [];
for (let i = 0; i < 40; i++) {
@@ -1898,6 +1906,16 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
const $history = discuss.$('.o_mail_discuss_item[data-thread-id="mailbox_history"]');
await testUtils.dom.click($history);
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
assert.verifySteps(['message_fetch'],
"should fetch messages once for history");
assert.containsN(discuss, '.o_thread_message', 30,
@@ -1907,6 +1925,16 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
discuss.$('.o_mail_thread').scrollTop(0);
await loadMoreDef;
await testUtils.nextTick();
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
await testUtils.nextTick(); // extra (non-deterministic)
assert.verifySteps(['message_fetch'],
"should fetch more messages in history for loadMore");
assert.containsN(discuss, '.o_thread_message', 40,