[REF] mail: tests: remove nextAnimationFrame

In some tests it was no longer necessary.

Negative tests will be slightly weaker, but they are so weak already
that is does not change much, they should be done differently anyway.

closes odoo/odoo#134025

Related: odoo/enterprise#46739
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2023-09-04 21:53:38 +00:00
committed by Alexandre Kühn
parent 4458a01606
commit 53cd2bd72f
10 changed files with 19 additions and 89 deletions
@@ -10,7 +10,6 @@ import {
dragenterFiles,
dropFiles,
insertText,
nextAnimationFrame,
pasteFiles,
scroll,
start,
@@ -886,6 +885,5 @@ QUnit.test("Message is sent only once when pressing enter twice in a row", async
triggerHotkey("Enter");
triggerHotkey("Enter");
// weak test, no guarantee that we waited long enough for the potential second message to be posted
await nextAnimationFrame();
await contains(".o-mail-Message-content", { text: "Hello World!" });
});
@@ -5,7 +5,6 @@ import {
click,
contains,
mockGetMedia,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
@@ -105,7 +104,6 @@ QUnit.test("should disconnect when closing page while in call", async (assert) =
await contains(".o-discuss-Call");
// simulate page close
window.dispatchEvent(new Event("pagehide"), { bubble: true });
await nextAnimationFrame();
assert.verifySteps(["sendBeacon_leave_call"]);
});
@@ -6,7 +6,6 @@ import {
contains,
createFile,
mockGetMedia,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
@@ -161,7 +160,7 @@ QUnit.test("make voice message in chat", async () => {
openDiscuss(channelId);
await click("button[title='Voice Message']");
await contains(".o-mail-VoiceRecorder", { text: "00 : 00" });
await nextAnimationFrame();
await Promise.resolve();
// simulate 10 sec elapsed
patchDate(2023, 6, 31, 13, 0, 11); // +1 so exactly 10 sec elapsed
// simulate some microphone data
@@ -171,7 +170,6 @@ QUnit.test("make voice message in chat", async () => {
await contains(".o-mail-VoicePlayer");
// wait for audio stream decode + drawing of waves
await voicePlayerDrawing;
await nextAnimationFrame();
await contains(".o-mail-VoicePlayer button[title='Play']");
await contains(".o-mail-VoicePlayer canvas", { count: 2 }); // 1 for global waveforms, 1 for played waveforms
await contains(".o-mail-VoicePlayer", { text: "00 : 04" }); // duration of call_02_in_.mp3
@@ -1,13 +1,6 @@
/* @odoo-module */
import {
click,
contains,
insertText,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { click, contains, insertText, start, startServer } from "@mail/../tests/helpers/test_utils";
import { patchWithCleanup, triggerHotkey, makeDeferred } from "@web/../tests/helpers/utils";
@@ -615,7 +608,6 @@ QUnit.test("emptying inbox displays rainbow man in inbox", async () => {
openDiscuss();
await click("button", { text: "Mark all read" });
await contains("button:contains(Inbox) .badge", { count: 0 });
await nextAnimationFrame();
await contains(".o_reward_rainbow");
});
@@ -645,7 +637,6 @@ QUnit.test("emptying inbox doesn't display rainbow man in another thread", async
needaction_inbox_counter: 0,
});
await contains("button:contains(Inbox) .badge", { count: 0 });
await nextAnimationFrame();
// weak test, no guarantee that we waited long enough for the potential rainbow man to show
await contains(".o_reward_rainbow", { count: 0 });
});
@@ -1,14 +1,7 @@
/* @odoo-module */
import { Command } from "@mail/../tests/helpers/command";
import {
click,
contains,
insertText,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { click, contains, insertText, start, startServer } from "@mail/../tests/helpers/test_utils";
import { getOrigin } from "@web/core/utils/urls";
@@ -1036,7 +1029,6 @@ QUnit.test("Do no channel_info after unpin", async (assert) => {
message_type: "comment",
},
});
await nextAnimationFrame();
// weak test, no guarantee that we waited long enough for the potential rpc to be done
assert.verifySteps([]);
});
@@ -49,21 +49,6 @@ function _createFakeDataTransfer(files) {
};
}
//------------------------------------------------------------------------------
// Public: rendering timers
//------------------------------------------------------------------------------
/**
* Returns a promise resolved at the next animation frame.
*
* @returns {Promise}
*/
function nextAnimationFrame() {
return new Promise(function (resolve) {
setTimeout(() => requestAnimationFrame(() => resolve()));
});
}
//------------------------------------------------------------------------------
// Public: test lifecycle
//------------------------------------------------------------------------------
@@ -422,7 +407,6 @@ export {
dragenterFiles,
dropFiles,
insertText,
nextAnimationFrame,
pasteFiles,
scroll,
start,
@@ -1,13 +1,6 @@
/* @odoo-module */
import {
click,
contains,
insertText,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { click, contains, insertText, start, startServer } from "@mail/../tests/helpers/test_utils";
QUnit.module("link preview");
@@ -266,10 +259,8 @@ QUnit.test("No crash on receiving link preview of non-known message", async (ass
const { env, openDiscuss } = await start();
openDiscuss();
env.services.rpc("/mail/link_preview", { message_id: messageId });
await nextAnimationFrame();
assert.ok(true);
env.services.rpc("/mail/link_preview/delete", { link_preview_id: linkPreviewId });
await nextAnimationFrame();
assert.ok(true);
});
@@ -1,14 +1,7 @@
/* @odoo-module */
import { Command } from "@mail/../tests/helpers/command";
import {
click,
contains,
insertText,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { click, contains, insertText, start, startServer } from "@mail/../tests/helpers/test_utils";
import { deserializeDateTime } from "@web/core/l10n/dates";
import { getOrigin } from "@web/core/utils/urls";
@@ -1278,9 +1271,8 @@ QUnit.test(
openDiscuss(channelId);
await contains(".o-mail-Message-avatar");
assert.doesNotHaveClass($(".o-mail-Message-avatarContainer"), "cursor-pointer");
click(".o-mail-Message-avatar").catch(() => {});
await nextAnimationFrame();
await click(".o-mail-Message-avatar");
// weak test, no guarantee that we waited long enough for the potential chat window to show
await contains(".o-mail-ChatWindow", { count: 0 });
}
);
@@ -1,12 +1,6 @@
/* @odoo-module */
import {
click,
contains,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { click, contains, start, startServer } from "@mail/../tests/helpers/test_utils";
import { DELAY_FOR_SPINNER } from "@mail/core/web/chatter";
import { makeDeferred } from "@web/../tests/helpers/utils";
@@ -272,13 +266,10 @@ QUnit.test("composer state conserved when clicking on another topbar button", as
await contains("button", { text: "Send message" });
await contains("button", { text: "Log note" });
await contains("button[aria-label='Attach files']");
await click("button", { text: "Log note" });
await contains("button:contains(Log note).active");
await contains("button:contains(Send message).active", { count: 0 });
$(`button[aria-label='Attach files']`)[0].click();
await nextAnimationFrame();
await click(".o-mail-Chatter-topbar button[aria-label='Attach files']");
await contains("button:contains(Log note).active");
await contains("button:contains(Send message).active", { count: 0 });
});
@@ -1,12 +1,6 @@
/* @odoo-module */
import {
click,
contains,
nextAnimationFrame,
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { click, contains, scroll, start, startServer } from "@mail/../tests/helpers/test_utils";
import { patchWithCleanup } from "@web/../tests/helpers/utils";
@@ -226,14 +220,14 @@ QUnit.test("Load 100 followers at once", async () => {
const { openFormView } = await start();
await openFormView("res.partner", partnerIds[0]);
await contains("button[title='Show Followers']", { text: "210" });
await click("button[title='Show Followers']");
await contains(".o-mail-Follower", { text: "Mitchell Admin" });
await contains(".o-mail-Follower", { count: 100 });
$(".o-mail-Followers-dropdown span:contains(Load more)")[0].scrollIntoView();
await contains(".o-mail-Followers-dropdown span", { text: "Load more" });
await scroll(".o-mail-Followers-dropdown", "bottom");
await contains(".o-mail-Follower", { count: 200 });
await nextAnimationFrame(); // give enough time for the Load more button to scroll out of view
$(".o-mail-Followers-dropdown span:contains(Load more)")[0].scrollIntoView();
await new Promise(setTimeout); // give enough time for the useVisible hook to register load more as hidden
await scroll(".o-mail-Followers-dropdown", "bottom");
await contains(".o-mail-Follower", { count: 210 });
await contains(".o-mail-Followers-dropdown span", { count: 0, text: "Load more" });
});
@@ -267,10 +261,11 @@ QUnit.test("Load 100 recipients at once", async () => {
await contains("button[title='Show all recipients']");
await click("button[title='Show all recipients']");
await contains(".o-mail-RecipientList li", { count: 100 });
$(".o-mail-RecipientList span:contains(Load more)")[0].scrollIntoView();
await contains(".o-mail-RecipientList span", { text: "Load more" });
await scroll(".o-mail-RecipientList", "bottom");
await contains(".o-mail-RecipientList li", { count: 200 });
await nextAnimationFrame(); // give enough time for the Load more button to scroll out of view
$(".o-mail-RecipientList span:contains(Load more)")[0].scrollIntoView();
await new Promise(setTimeout); // give enough time for the useVisible hook to register load more as hidden
await scroll(".o-mail-RecipientList", "bottom");
await contains(".o-mail-RecipientList li", { count: 210 });
await contains(".o-mail-RecipientList span", { count: 0, text: "Load more" });
});
@@ -324,7 +319,7 @@ QUnit.test(
QUnit.test(
'Show "No Followers" dropdown-item if there are no followers and user does not have write access',
async (assert) => {
async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({});
const { openView } = await start({