From 3ce461cc5183e09bc4006b9294c5d682b0533a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Thu, 31 Aug 2023 12:42:24 +0200 Subject: [PATCH] [REF] mail, *: move contains count to named parameter * = calendar, hr, im_livechat, mrp, project_todo, sms, snailmail, test_mail The parameter is too often specified with its default value to be worth being a positional parameter. Part-of: odoo/odoo#133717 --- .../static/tests/activity_menu_tests.js | 8 +- .../static/tests/activity_widget_tests.js | 2 +- .../static/tests/m2x_avatar_employee_tests.js | 2 +- .../static/tests/channel_invite_tests.js | 20 +- .../static/tests/chat_window_patch_tests.js | 4 +- .../static/tests/composer_patch_tests.js | 22 +- .../static/tests/discuss_patch_tests.js | 10 +- .../tests/embed/feedback_panel_tests.js | 16 +- .../tests/embed/livechat_button_tests.js | 16 +- .../tests/embed/livechat_service_tests.js | 4 +- .../tests/embed/livechat_session_tests.js | 10 +- .../tests/embed/transcript_sender_tests.js | 10 +- .../tests/embed/unread_messages_tests.js | 6 +- .../tests/messaging_menu_patch_tests.js | 8 +- .../tests/messaging_service_patch_tests.js | 4 +- .../mobile_messaging_menu_patch_tests.js | 4 +- .../static/tests/sidebar_patch_tests.js | 38 ++- .../static/tests/suggestions_tests.js | 6 +- .../static/tests/thread_model_patch_tests.js | 4 +- .../activity_mark_done_popover_tests.js | 6 +- .../tests/activity/activity_menu_tests.js | 2 +- .../static/tests/activity/activity_tests.js | 60 ++-- .../chat_window/chat_window_manager_tests.js | 36 +-- .../tests/chat_window/chat_window_tests.js | 196 ++++++------ .../static/tests/composer/composer_tests.js | 155 +++++----- .../composer/suggested_recipients_test.js | 24 +- .../mail/static/tests/core/open_chat_test.js | 2 +- .../static/tests/core/out_of_focus_tests.js | 2 +- .../static/tests/crosstab/crosstab_tests.js | 34 ++- .../discuss/call/call_settings_menu_tests.js | 10 +- .../static/tests/discuss/call/call_tests.js | 18 +- .../tests/discuss/call/web/call_tests.js | 14 +- .../discuss/core/channel_invitation_tests.js | 4 +- .../discuss/core/channel_member_list_tests.js | 14 +- .../tests/discuss/core/composer_tests.js | 8 +- .../tests/discuss/core/crosstab_tests.js | 10 +- .../tests/discuss/core/discuss_tests.js | 2 +- .../tests/discuss/core/suggestion_tests.js | 32 +- .../core/web/chat_window_new_message_tests.js | 26 +- .../discuss/core/web/command_palette_tests.js | 18 +- .../tests/discuss/core/web/crosstab_tests.js | 2 +- .../tests/discuss/core/web/discuss_tests.js | 40 +-- .../discuss/core/web/messaging_menu_tests.js | 6 +- .../tests/discuss/core/web/sidebar_tests.js | 12 +- .../message_pin/pinned_messages_tests.js | 8 +- .../tests/discuss/typing/typing_tests.js | 42 +-- .../voice_message/voice_message_tests.js | 8 +- .../static/tests/discuss_app/discuss_tests.js | 280 +++++++++--------- .../static/tests/discuss_app/inbox_tests.js | 69 +++-- .../discuss_app/jump_to_present_tests.js | 24 +- .../static/tests/discuss_app/sidebar_tests.js | 142 ++++----- addons/mail/static/tests/emoji/emoji_tests.js | 16 +- .../tests/gif_picker/gif_picker_test.js | 10 +- .../mail/static/tests/helpers/test_utils.js | 9 +- addons/mail/static/tests/mail_utils_tests.js | 22 +- .../static/tests/message/link_preview_test.js | 30 +- .../message/message_seen_indicator_tests.js | 22 +- .../static/tests/message/message_tests.js | 137 +++++---- .../static/tests/messaging/messaging_tests.js | 6 +- .../messaging_menu/messaging_menu_tests.js | 135 ++++----- .../messaging_menu/notification_tests.js | 23 +- .../mail/static/tests/mobile/mobile_tests.js | 4 +- .../tests/suggestion/suggestion_tests.js | 34 +-- .../tests/thread/attachment_list_tests.js | 14 +- .../mail/static/tests/thread/thread_tests.js | 165 ++++++----- .../web/activity/activity_widget_tests.js | 14 +- .../static/tests/web/attachment_box_tests.js | 28 +- addons/mail/static/tests/web/chatter_tests.js | 113 +++---- .../static/tests/web/chatter_topbar_tests.js | 48 +-- .../static/tests/web/fields/avatar_tests.js | 4 +- .../tests/web/fields/m2x_avatar_user_tests.js | 12 +- .../web/fields/many2many_tags_email_tests.js | 10 +- .../static/tests/web/follow_button_tests.js | 16 +- .../tests/web/follower_list_menu_tests.js | 42 +-- .../mail/static/tests/web/follower_tests.js | 18 +- .../static/tests/web/form_renderer_tests.js | 28 +- .../static/tests/mrp_document_kanban_tests.js | 2 +- .../static/tests/activity_menu_tests.js | 32 +- .../messaging_menu_patch_tests.js | 8 +- .../static/tests/thread/message_patch_test.js | 2 +- .../tests/message/message_patch_tests.js | 16 +- .../messaging_menu_patch_tests.js | 8 +- .../test_mail/static/tests/activity_tests.js | 13 +- .../tests/systray_activity_menu_tests.js | 20 +- .../static/tests/tracking_value_tests.js | 4 +- 85 files changed, 1300 insertions(+), 1265 deletions(-) diff --git a/addons/calendar/static/tests/activity_menu_tests.js b/addons/calendar/static/tests/activity_menu_tests.js index 90c62bbafb1..6114df3dd15 100644 --- a/addons/calendar/static/tests/activity_menu_tests.js +++ b/addons/calendar/static/tests/activity_menu_tests.js @@ -31,10 +31,10 @@ QUnit.test("activity menu widget:today meetings", async function (assert) { assert.step("action"); }, }); - await contains(".o-mail-ActivityGroup span", 1, { text: "Today's Meetings" }); - await contains(".o-mail-ActivityGroup .o-calendar-meeting", 2); - await contains(".o-calendar-meeting span.fw-bold", 1, { text: "meeting1" }); - await contains(".o-calendar-meeting span:not(.fw-bold)", 1, { text: "meeting2" }); + await contains(".o-mail-ActivityGroup span", { text: "Today's Meetings" }); + await contains(".o-mail-ActivityGroup .o-calendar-meeting", { count: 2 }); + await contains(".o-calendar-meeting span.fw-bold", { text: "meeting1" }); + await contains(".o-calendar-meeting span:not(.fw-bold)", { text: "meeting2" }); await click(".o-mail-ActivityMenu .o-mail-ActivityGroup"); assert.verifySteps(["action"]); }); diff --git a/addons/calendar/static/tests/activity_widget_tests.js b/addons/calendar/static/tests/activity_widget_tests.js index f79c74538ba..7d7895deddf 100644 --- a/addons/calendar/static/tests/activity_widget_tests.js +++ b/addons/calendar/static/tests/activity_widget_tests.js @@ -65,6 +65,6 @@ QUnit.test("list activity widget: reschedule button in dropdown", async (assert) assert.strictEqual($(".o-mail-ListActivity-summary")[0].innerText, "OXP"); await click(".o-mail-ActivityButton"); // open the popover - await contains(".o-mail-ActivityListPopoverItem-editbtn .fa-pencil", 0); + await contains(".o-mail-ActivityListPopoverItem-editbtn .fa-pencil", { count: 0 }); await contains(".o-mail-ActivityListPopoverItem-editbtn .fa-calendar"); }); diff --git a/addons/hr/static/tests/m2x_avatar_employee_tests.js b/addons/hr/static/tests/m2x_avatar_employee_tests.js index 798225a7461..5d8233b84b0 100644 --- a/addons/hr/static/tests/m2x_avatar_employee_tests.js +++ b/addons/hr/static/tests/m2x_avatar_employee_tests.js @@ -159,7 +159,7 @@ QUnit.test( res_id: avatarId, views: [[false, "form"]], }); - await contains(".o_field_widget[name=employee_id] input", 1, { value: "Mario" }); + await contains(".o_field_widget[name=employee_id] input", { value: "Mario" }); await dom.click(document.querySelector(".o_m2o_avatar > img")); await contains( ".o_notification.border-info:contains(You can only chat with employees that have a dedicated user.)" diff --git a/addons/im_livechat/static/tests/channel_invite_tests.js b/addons/im_livechat/static/tests/channel_invite_tests.js index 1767133c96b..3c44433d71e 100644 --- a/addons/im_livechat/static/tests/channel_invite_tests.js +++ b/addons/im_livechat/static/tests/channel_invite_tests.js @@ -29,12 +29,12 @@ QUnit.test("Can invite a partner to a livechat channel", async () => { await click("button[title='Add Users']"); await click(".o-discuss-ChannelInvitation-selectable:contains(James) input"); await click("button:contains(Invite):not(:disabled)"); - await contains(".o-discuss-ChannelInvitation", 0); + await contains(".o-discuss-ChannelInvitation", { count: 0 }); await click("button[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 1, { text: "James" }); + await contains(".o-discuss-ChannelMember", { text: "James" }); }); -QUnit.test("Available operators come first", async (assert) => { +QUnit.test("Available operators come first", async () => { const pyEnv = await startServer(); pyEnv["res.partner"].create({ name: "Harry", @@ -61,12 +61,12 @@ QUnit.test("Available operators come first", async (assert) => { const { openDiscuss } = await start(); await openDiscuss(channelId); await click("button[title='Add Users']"); - const partnerSuggestions = await contains(".o-discuss-ChannelInvitation-selectable", 2); - assert.ok(partnerSuggestions[0].textContent.includes("Ron")); - assert.ok(partnerSuggestions[1].textContent.includes("Harry")); + await contains(".o-discuss-ChannelInvitation-selectable", { count: 2 }); + await contains(".o-discuss-ChannelInvitation-selectable:eq(0)", { text: "Ron" }); + await contains(".o-discuss-ChannelInvitation-selectable:eq(1)", { text: "Harry" }); }); -QUnit.test("Partners invited most frequently by the current user come first", async (assert) => { +QUnit.test("Partners invited most frequently by the current user come first", async () => { const pyEnv = await startServer(); pyEnv["res.partner"].create({ name: "John", @@ -105,7 +105,7 @@ QUnit.test("Partners invited most frequently by the current user come first", as await click("button:contains(Invite):not(:disabled)"); await click(".o-mail-DiscussSidebarChannel span", { text: "Visitor #2" }); await click("button[title='Add Users']"); - const partnerSuggestions = await contains(".o-discuss-ChannelInvitation-selectable", 2); - assert.ok(partnerSuggestions[0].textContent.includes("John")); - assert.ok(partnerSuggestions[1].textContent.includes("Albert")); + await contains(".o-discuss-ChannelInvitation-selectable", { count: 2 }); + await contains(".o-discuss-ChannelInvitation-selectable:eq(0)", { text: "John" }); + await contains(".o-discuss-ChannelInvitation-selectable:eq(1)", { text: "Albert" }); }); diff --git a/addons/im_livechat/static/tests/chat_window_patch_tests.js b/addons/im_livechat/static/tests/chat_window_patch_tests.js index a4dd2fab612..d2146206047 100644 --- a/addons/im_livechat/static/tests/chat_window_patch_tests.js +++ b/addons/im_livechat/static/tests/chat_window_patch_tests.js @@ -19,8 +19,8 @@ QUnit.test("No call buttons", async () => { await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-ChatWindow-command i.fa-phone", 0); - await contains(".o-mail-ChatWindow-command i.fa-gear", 0); + await contains(".o-mail-ChatWindow-command i.fa-phone", { count: 0 }); + await contains(".o-mail-ChatWindow-command i.fa-gear", { count: 0 }); }); QUnit.test("closing a chat window with no message from admin side unpins it", async (assert) => { diff --git a/addons/im_livechat/static/tests/composer_patch_tests.js b/addons/im_livechat/static/tests/composer_patch_tests.js index e0018435514..2a1804addc5 100644 --- a/addons/im_livechat/static/tests/composer_patch_tests.js +++ b/addons/im_livechat/static/tests/composer_patch_tests.js @@ -24,7 +24,7 @@ QUnit.test("No add attachments button", async (assert) => { const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Composer"); - await contains("button[title='Attach files']", 0); + await contains("button[title='Attach files']", { count: 0 }); }); QUnit.test("Attachment upload via drag and drop disabled", async (assert) => { @@ -40,7 +40,7 @@ QUnit.test("Attachment upload via drag and drop disabled", async (assert) => { await contains(".o-mail-Composer"); dragenterFiles($(".o-mail-Composer-input")[0]); await nextTick(); - await contains(".o-mail-Dropzone", 0); + await contains(".o-mail-Dropzone", { count: 0 }); }); QUnit.test("Can execute help command on livechat channels", async (assert) => { @@ -94,7 +94,7 @@ QUnit.test('Receives visitor typing status "is typing"', async (assert) => { }) ) ); - await contains(".o-discuss-Typing", 1, { text: "Visitor 20 is typing..." }); + await contains(".o-discuss-Typing", { text: "Visitor 20 is typing..." }); }); QUnit.test('display canned response suggestions on typing ":"', async () => { @@ -115,7 +115,7 @@ QUnit.test('display canned response suggestions on typing ":"', async () => { const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Composer-input"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); await insertText(".o-mail-Composer-input", ":"); await contains(".o-mail-Composer-suggestionList .o-open"); }); @@ -138,11 +138,11 @@ QUnit.test("use a canned response", async (assert) => { const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", ":"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "Hello! How are you? " }); + await contains(".o-mail-Composer-input", { value: "Hello! How are you? " }); }); QUnit.test("use a canned response some text", async (assert) => { @@ -168,7 +168,7 @@ QUnit.test("use a canned response some text", async (assert) => { assert.strictEqual($(".o-mail-Composer-input").val(), "bluhbluh "); await insertText(".o-mail-Composer-input", ":"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "bluhbluh Hello! How are you? " }); + await contains(".o-mail-Composer-input", { value: "bluhbluh Hello! How are you? " }); }); QUnit.test("add an emoji after a canned response", async () => { @@ -189,11 +189,11 @@ QUnit.test("add an emoji after a canned response", async () => { const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", ":"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "Hello! How are you? " }); + await contains(".o-mail-Composer-input", { value: "Hello! How are you? " }); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "😊" }); - await contains(".o-mail-Composer-input", 1, { value: "Hello! How are you? 😊" }); + await contains(".o-mail-Composer-input", { value: "Hello! How are you? 😊" }); }); diff --git a/addons/im_livechat/static/tests/discuss_patch_tests.js b/addons/im_livechat/static/tests/discuss_patch_tests.js index 77a141ed518..c7aa5c80b8f 100644 --- a/addons/im_livechat/static/tests/discuss_patch_tests.js +++ b/addons/im_livechat/static/tests/discuss_patch_tests.js @@ -190,14 +190,14 @@ QUnit.test( ]); const { openDiscuss } = await start(); await openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel:eq(0)", 1, { text: "Visitor 12" }); - await contains(".o-mail-DiscussSidebarChannel:eq(1)", 1, { text: "Visitor 11" }); + await contains(".o-mail-DiscussSidebarChannel:eq(0)", { text: "Visitor 12" }); + await contains(".o-mail-DiscussSidebarChannel:eq(1)", { text: "Visitor 11" }); // post a new message on the last channel await click(".o-mail-DiscussSidebarChannel:eq(1)"); await insertText(".o-mail-Composer-input", "Blabla"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-DiscussSidebarChannel", 2); - await contains(".o-mail-DiscussSidebarChannel:eq(0) span", 1, { text: "Visitor 11" }); - await contains(".o-mail-DiscussSidebarChannel:eq(1) span", 1, { text: "Visitor 12" }); + await contains(".o-mail-DiscussSidebarChannel", { count: 2 }); + await contains(".o-mail-DiscussSidebarChannel:eq(0) span", { text: "Visitor 11" }); + await contains(".o-mail-DiscussSidebarChannel:eq(1) span", { text: "Visitor 12" }); } ); diff --git a/addons/im_livechat/static/tests/embed/feedback_panel_tests.js b/addons/im_livechat/static/tests/embed/feedback_panel_tests.js index b89084a4d56..3ff676d4b32 100644 --- a/addons/im_livechat/static/tests/embed/feedback_panel_tests.js +++ b/addons/im_livechat/static/tests/embed/feedback_panel_tests.js @@ -18,7 +18,7 @@ QUnit.test("Do not ask feedback if empty", async () => { await click(".o-livechat-LivechatButton"); await contains(".o-mail-ChatWindow"); await click("[title='Close Chat Window']"); - await contains(".o-livechat-LivechatButton", 0); + await contains(".o-livechat-LivechatButton", { count: 0 }); }); QUnit.test("Close without feedback", async (assert) => { @@ -38,10 +38,10 @@ QUnit.test("Close without feedback", async (assert) => { await contains(".o-mail-ChatWindow"); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o-mail-Message-content", 1, { text: "Hello World!" }); + await contains(".o-mail-Message-content", { text: "Hello World!" }); await click("[title='Close Chat Window']"); await click("button", { text: "Close conversation" }); - await contains(".o-livechat-LivechatButton", 0); + await contains(".o-livechat-LivechatButton", { count: 0 }); assert.verifySteps(["/im_livechat/visitor_leave_session"]); }); @@ -64,13 +64,13 @@ QUnit.test("Feedback with rating and comment", async (assert) => { await contains(".o-mail-ChatWindow"); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o-mail-Message-content", 1, { text: "Hello World!" }); + await contains(".o-mail-Message-content", { text: "Hello World!" }); await click("[title='Close Chat Window']"); assert.verifySteps(["/im_livechat/visitor_leave_session"]); await click(`img[data-alt="${RATING.GOOD}"]`); await insertText("textarea[placeholder='Explain your note']", "Good job!"); await click("button:contains(Send):not(:disabled)"); - await contains("p", 1, { text: "Thank you for your feedback" }); + await contains("p", { text: "Thank you for your feedback" }); assert.verifySteps(["/im_livechat/feedback"]); }); @@ -81,10 +81,10 @@ QUnit.test("Closing folded chat window should open it with feedback", async () = await click(".o-livechat-LivechatButton"); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o-mail-Message-content", 1, { text: "Hello World!" }); + await contains(".o-mail-Message-content", { text: "Hello World!" }); await click("[title='Fold']"); await contains(".o-mail-ChatWindow.o-folded"); await click("[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow.o-folded", 0); - await contains(".o-mail-ChatWindow p", 1, { text: "Did we correctly answer your question?" }); + await contains(".o-mail-ChatWindow.o-folded", { count: 0 }); + await contains(".o-mail-ChatWindow p", { text: "Did we correctly answer your question?" }); }); diff --git a/addons/im_livechat/static/tests/embed/livechat_button_tests.js b/addons/im_livechat/static/tests/embed/livechat_button_tests.js index c72eb4694ba..627b6be56d2 100644 --- a/addons/im_livechat/static/tests/embed/livechat_button_tests.js +++ b/addons/im_livechat/static/tests/embed/livechat_button_tests.js @@ -14,10 +14,10 @@ QUnit.test("open/close temporary channel", async () => { start(); await click(".o-livechat-LivechatButton"); await contains(".o-mail-ChatWindow"); - await contains(".o-livechat-LivechatButton", 0); + await contains(".o-livechat-LivechatButton", { count: 0 }); await click("[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow", 0); - await contains(".o-livechat-LivechatButton", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); + await contains(".o-livechat-LivechatButton", { count: 0 }); }); QUnit.test("open/close persisted channel", async () => { @@ -27,14 +27,14 @@ QUnit.test("open/close persisted channel", async () => { await click(".o-livechat-LivechatButton"); await insertText(".o-mail-Composer-input", "How can I help?"); triggerHotkey("Enter"); - await contains(".o-mail-Message-content", 1, { text: "How can I help?" }); + await contains(".o-mail-Message-content", { text: "How can I help?" }); await click("[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow-content p", 1, { + await contains(".o-mail-ChatWindow-content p", { text: "Did we correctly answer your question?", }); await click("[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow", 0); - await contains(".o-livechat-LivechatButton", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); + await contains(".o-livechat-LivechatButton", { count: 0 }); }); QUnit.test("livechat not available", async () => { @@ -48,5 +48,5 @@ QUnit.test("livechat not available", async () => { }, }); await contains(".o-mail-ChatWindowContainer"); - await contains(".o-livechat-LivechatButton", 0); + await contains(".o-livechat-LivechatButton", { count: 0 }); }); diff --git a/addons/im_livechat/static/tests/embed/livechat_service_tests.js b/addons/im_livechat/static/tests/embed/livechat_service_tests.js index e0ad706385a..39c5c8b2eb9 100644 --- a/addons/im_livechat/static/tests/embed/livechat_service_tests.js +++ b/addons/im_livechat/static/tests/embed/livechat_service_tests.js @@ -31,7 +31,7 @@ QUnit.test("persisted session history", async () => { message_type: "comment", }); start(); - await contains(".o-mail-Message-content", 1, { text: "Old message in history" }); + await contains(".o-mail-Message-content", { text: "Old message in history" }); }); QUnit.test("previous operator prioritized", async () => { @@ -43,5 +43,5 @@ QUnit.test("previous operator prioritized", async () => { setCookie("im_livechat_previous_operator_pid", JSON.stringify(previousOperatorId)); start(); click(".o-livechat-LivechatButton"); - await contains(".o-mail-Message-author", 1, { text: "John Doe" }); + await contains(".o-mail-Message-author", { text: "John Doe" }); }); diff --git a/addons/im_livechat/static/tests/embed/livechat_session_tests.js b/addons/im_livechat/static/tests/embed/livechat_session_tests.js index 5c6b0dd9344..76f17d5f6cf 100644 --- a/addons/im_livechat/static/tests/embed/livechat_session_tests.js +++ b/addons/im_livechat/static/tests/embed/livechat_session_tests.js @@ -35,10 +35,10 @@ QUnit.test("Unsuccessful message post shows session expired", async () => { }); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o_notification_content", 1, { + await contains(".o_notification_content", { text: "Session expired... Please refresh and try again.", }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); }); QUnit.test("Session is reset after failing to persist the channel", async () => { @@ -55,7 +55,7 @@ QUnit.test("Session is reset after failing to persist the channel", async () => await click(".o-livechat-LivechatButton"); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o_notification_content", 1, { + await contains(".o_notification_content", { text: "No available collaborator, please try again later.", }); await contains(".o-livechat-LivechatButton"); @@ -72,7 +72,7 @@ QUnit.test("Thread state is saved on the session", async (assert) => { await contains(".o-mail-ChatWindow-content"); assert.strictEqual(env.services["im_livechat.livechat"].sessionCookie.state, "open"); await click(".o-mail-ChatWindow-header"); - await contains(".o-mail-ChatWindow-content", 0); + await contains(".o-mail-ChatWindow-content", { count: 0 }); assert.strictEqual(env.services["im_livechat.livechat"].sessionCookie.state, "folded"); await click(".o-mail-ChatWindow-header"); await contains(".o-mail-ChatWindow-content"); @@ -87,7 +87,7 @@ QUnit.test("Seen message is saved on the session", async (assert) => { assert.notOk(env.services["im_livechat.livechat"].sessionCookie.seen_message_id); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); assert.strictEqual( env.services["im_livechat.livechat"].sessionCookie.seen_message_id, env.services["im_livechat.livechat"].thread.newestMessage.id diff --git a/addons/im_livechat/static/tests/embed/transcript_sender_tests.js b/addons/im_livechat/static/tests/embed/transcript_sender_tests.js index f9a9c8f9c5a..a19dd68255c 100644 --- a/addons/im_livechat/static/tests/embed/transcript_sender_tests.js +++ b/addons/im_livechat/static/tests/embed/transcript_sender_tests.js @@ -23,13 +23,13 @@ QUnit.test("send", async (assert) => { await click(".o-livechat-LivechatButton"); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o-mail-Message-content", 1, { text: "Hello World!" }); + await contains(".o-mail-Message-content", { text: "Hello World!" }); await click(".o-mail-ChatWindow-command[title*='Close']"); - await contains(".form-text", 1, { text: "Receive a copy of this conversation." }); + await contains(".form-text", { text: "Receive a copy of this conversation." }); await contains("button[data-action='sendTranscript']:disabled"); await insertText("input[placeholder='mail@example.com']", "odoobot@odoo.com"); await click("button[data-action='sendTranscript']:not(:disabled)"); - await contains(".form-text", 1, { text: "The conversation was sent." }); + await contains(".form-text", { text: "The conversation was sent." }); assert.verifySteps(["send_transcript - odoobot@odoo.com"]); }); @@ -46,9 +46,9 @@ QUnit.test("send failed", async () => { await click(".o-livechat-LivechatButton"); await insertText(".o-mail-Composer-input", "Hello World!"); triggerHotkey("Enter"); - await contains(".o-mail-Message-content", 1, { text: "Hello World!" }); + await contains(".o-mail-Message-content", { text: "Hello World!" }); await click(".o-mail-ChatWindow-command[title*='Close']"); await insertText("input[placeholder='mail@example.com']", "odoobot@odoo.com"); await click("button[data-action='sendTranscript']:not(:disabled)"); - await contains(".form-text", 1, { text: "An error occurred. Please try again." }); + await contains(".form-text", { text: "An error occurred. Please try again." }); }); diff --git a/addons/im_livechat/static/tests/embed/unread_messages_tests.js b/addons/im_livechat/static/tests/embed/unread_messages_tests.js index ac33931293a..bcd08ad3dce 100644 --- a/addons/im_livechat/static/tests/embed/unread_messages_tests.js +++ b/addons/im_livechat/static/tests/embed/unread_messages_tests.js @@ -32,7 +32,7 @@ QUnit.test("new message from operator displays unread counter", async () => { thread_model: "discuss.channel", }) ); - await contains(".o-mail-ChatWindow-counter", 1, { text: "1" }); + await contains(".o-mail-ChatWindow-counter", { text: "1" }); }); QUnit.test("focus on unread livechat marks it as read", async () => { @@ -58,9 +58,9 @@ QUnit.test("focus on unread livechat marks it as read", async () => { thread_model: "discuss.channel", }) ); - await contains(".o-mail-Thread-newMessage ~ .o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Thread-newMessage ~ .o-mail-Message .o-mail-Message-content", { text: "Are you there?", }); $(".o-mail-Composer-input").trigger("focus"); - await contains(".o-mail-Thread-newMessage", 0); + await contains(".o-mail-Thread-newMessage", { count: 0 }); }); diff --git a/addons/im_livechat/static/tests/messaging_menu_patch_tests.js b/addons/im_livechat/static/tests/messaging_menu_patch_tests.js index fdc94f30afd..b158b1ba8d1 100644 --- a/addons/im_livechat/static/tests/messaging_menu_patch_tests.js +++ b/addons/im_livechat/static/tests/messaging_menu_patch_tests.js @@ -19,10 +19,10 @@ QUnit.test('livechats should be in "chat" filter', async () => { await start(); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-MessagingMenu button:contains(All).fw-bolder"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Visitor 11" }); + await contains(".o-mail-NotificationItem-name", { text: "Visitor 11" }); await click(".o-mail-MessagingMenu button", { text: "Chats" }); await contains(".o-mail-MessagingMenu button:contains(Chat).fw-bolder"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Visitor 11" }); + await contains(".o-mail-NotificationItem-name", { text: "Visitor 11" }); }); QUnit.test('livechats should be in "livechat" tab in mobile', async () => { @@ -40,7 +40,7 @@ QUnit.test('livechats should be in "livechat" tab in mobile', async () => { await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click("button", { text: "Livechat" }); - await contains(".o-mail-NotificationItem", 1, { text: "Visitor 11" }); + await contains(".o-mail-NotificationItem", { text: "Visitor 11" }); await click("button", { text: "Chat" }); - await contains(".o-mail-NotificationItem", 0, { text: "Visitor 11" }); + await contains(".o-mail-NotificationItem", { count: 0, text: "Visitor 11" }); }); diff --git a/addons/im_livechat/static/tests/messaging_service_patch_tests.js b/addons/im_livechat/static/tests/messaging_service_patch_tests.js index 89c9d0905da..d29e21ceb19 100644 --- a/addons/im_livechat/static/tests/messaging_service_patch_tests.js +++ b/addons/im_livechat/static/tests/messaging_service_patch_tests.js @@ -34,8 +34,8 @@ QUnit.test("Notify message received out of focus", async () => { uuid: channel.uuid, }) ); - await contains(".o_notification.border-info .o_notification_title", 1, { + await contains(".o_notification.border-info .o_notification_title", { text: "New message", }); - await contains(".o_notification.border-info .o_notification_content", 1, { text: "Hello" }); + await contains(".o_notification.border-info .o_notification_content", { text: "Hello" }); }); diff --git a/addons/im_livechat/static/tests/mobile_messaging_menu_patch_tests.js b/addons/im_livechat/static/tests/mobile_messaging_menu_patch_tests.js index 639beceef83..87a4d49d9d7 100644 --- a/addons/im_livechat/static/tests/mobile_messaging_menu_patch_tests.js +++ b/addons/im_livechat/static/tests/mobile_messaging_menu_patch_tests.js @@ -13,7 +13,7 @@ QUnit.test("Livechat button is not present when there is no livechat thread", as await start(); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-MessagingMenu"); - await contains(".o-mail-MessagingMenu-navbar span", 0, { text: "Livechat" }); + await contains(".o-mail-MessagingMenu-navbar span", { count: 0, text: "Livechat" }); }); QUnit.test("Livechat button is present when there is at least one livechat thread", async () => { @@ -30,5 +30,5 @@ QUnit.test("Livechat button is present when there is at least one livechat threa await start(); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-MessagingMenu"); - await contains(".o-mail-MessagingMenu-navbar span", 1, { text: "Livechat" }); + await contains(".o-mail-MessagingMenu-navbar span", { text: "Livechat" }); }); diff --git a/addons/im_livechat/static/tests/sidebar_patch_tests.js b/addons/im_livechat/static/tests/sidebar_patch_tests.js index 61811fa0ffb..2ded91c45f1 100644 --- a/addons/im_livechat/static/tests/sidebar_patch_tests.js +++ b/addons/im_livechat/static/tests/sidebar_patch_tests.js @@ -20,7 +20,7 @@ QUnit.test("Unknown visitor", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebar .o-mail-DiscussSidebarCategory-livechat"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Visitor 11" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Visitor 11" }); }); QUnit.test("Known user with country", async () => { @@ -70,8 +70,8 @@ QUnit.test("Do not show channel when visitor is typing", async () => { }); const { env, openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 2); - await contains(".o-mail-DiscussSidebarCategory-livechat", 0); + await contains(".o-mail-DiscussSidebarCategory", { count: 2 }); + await contains(".o-mail-DiscussSidebarCategory-livechat", { count: 0 }); // simulate livechat visitor typing const channel = pyEnv["discuss.channel"].searchRead([["id", "=", channelId]])[0]; await pyEnv.withUser(pyEnv.publicUserId, () => @@ -82,7 +82,7 @@ QUnit.test("Do not show channel when visitor is typing", async () => { ); // weak test, no guaranteed that we waited long enough for the livechat to potentially appear await nextTick(); - await contains(".o-mail-DiscussSidebarCategory-livechat", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat", { count: 0 }); }); QUnit.test("Close should update the value on the server", async (assert) => { @@ -169,7 +169,9 @@ QUnit.test("Open from the bus", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-livechat"); - await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", { + count: 0, + }); pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.record/insert", { "res.users.settings": { id: settingsId, @@ -203,7 +205,9 @@ QUnit.test("Close from the bus", async () => { is_discuss_sidebar_category_livechat_open: false, }, }); - await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", { + count: 0, + }); }); QUnit.test("Smiley face avatar for an anonymous livechat item", async () => { @@ -263,7 +267,9 @@ QUnit.test("No counter if the category is unfolded and with unread messages", as const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-livechat"); - await contains(".o-mail-DiscussSidebarCategory-livechat .o-mail-Discuss-category-counter", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat .o-mail-Discuss-category-counter", { + count: 0, + }); }); QUnit.test("No counter if category is folded and without unread messages", async () => { @@ -284,7 +290,7 @@ QUnit.test("No counter if category is folded and without unread messages", async const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-livechat"); - await contains(".o-mail-DiscussSidebarCategory-livechat .o-discuss-badge", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat .o-discuss-badge", { count: 0 }); }); QUnit.test( @@ -313,7 +319,7 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory-livechat .o-discuss-badge", 1, { + await contains(".o-mail-DiscussSidebarCategory-livechat .o-discuss-badge", { text: "1", }); } @@ -339,7 +345,7 @@ QUnit.test("Close manually by clicking the title", async () => { await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel"); // fold the livechat category await click(".o-mail-DiscussSidebarCategory-livechat .btn"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); }); QUnit.test("Open manually by clicking the title", async () => { @@ -360,7 +366,9 @@ QUnit.test("Open manually by clicking the title", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-livechat"); - await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", { + count: 0, + }); // open the livechat category await click(".o-mail-DiscussSidebarCategory-livechat .btn"); await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel"); @@ -381,7 +389,9 @@ QUnit.test("Category item should be invisible if the category is closed", async openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel"); await click(".o-mail-DiscussSidebarCategory-livechat .btn"); - await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarCategory-livechat + .o-mail-DiscussSidebarChannel", { + count: 0, + }); }); QUnit.test("Active category item should be visible even if the category is closed", async () => { @@ -420,7 +430,7 @@ QUnit.test("Clicking on unpin button unpins the channel", async () => { const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebarChannel [title='Unpin Conversation']"); - await contains(".o_notification_content", 1, { + await contains(".o_notification_content", { text: "You unpinned your conversation with Visitor 11", }); }); @@ -444,5 +454,5 @@ QUnit.test("Message unread counter", async () => { uuid: pyEnv["discuss.channel"].searchRead([["id", "=", channelId]])[0].uuid, }) ); - await contains(".o-mail-DiscussSidebarChannel .badge", 1, { text: "1" }); + await contains(".o-mail-DiscussSidebarChannel .badge", { text: "1" }); }); diff --git a/addons/im_livechat/static/tests/suggestions_tests.js b/addons/im_livechat/static/tests/suggestions_tests.js index adf6a758b17..77b8a0cec7d 100644 --- a/addons/im_livechat/static/tests/suggestions_tests.js +++ b/addons/im_livechat/static/tests/suggestions_tests.js @@ -22,9 +22,9 @@ QUnit.test("Suggestions are shown after delimiter was used in text (:)", async ( const { openDiscuss } = await start(); await openDiscuss(channelId); await insertText(".o-mail-Composer-input", ":"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "hello" }); + await contains(".o-mail-Composer-suggestion strong", { text: "hello" }); await insertText(".o-mail-Composer-input", ")"); - await contains(".o-mail-Composer-suggestion strong", 0); + await contains(".o-mail-Composer-suggestion strong", { count: 0 }); await insertText(".o-mail-Composer-input", " :"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "hello" }); + await contains(".o-mail-Composer-suggestion strong", { text: "hello" }); }); diff --git a/addons/im_livechat/static/tests/thread_model_patch_tests.js b/addons/im_livechat/static/tests/thread_model_patch_tests.js index 2cda21d6bd7..ea2599bec9b 100644 --- a/addons/im_livechat/static/tests/thread_model_patch_tests.js +++ b/addons/im_livechat/static/tests/thread_model_patch_tests.js @@ -29,8 +29,8 @@ QUnit.test("Thread name unchanged when inviting new users", async () => { await click("button[title='Add Users']"); await click(".o-discuss-ChannelInvitation-selectable:contains(James) input"); await click("button:contains(Invite):not(:disabled)"); - await contains(".o-discuss-ChannelInvitation", 0); + await contains(".o-discuss-ChannelInvitation", { count: 0 }); await click("button[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 1, { text: "James" }); + await contains(".o-discuss-ChannelMember", { text: "James" }); await contains(".o-mail-Discuss-threadName[title='Visitor #20']"); }); diff --git a/addons/mail/static/tests/activity/activity_mark_done_popover_tests.js b/addons/mail/static/tests/activity/activity_mark_done_popover_tests.js index 0232daaaa4c..f3fcbc7d50c 100644 --- a/addons/mail/static/tests/activity/activity_mark_done_popover_tests.js +++ b/addons/mail/static/tests/activity/activity_mark_done_popover_tests.js @@ -26,7 +26,7 @@ QUnit.test("activity mark done popover simplest layout", async () => { await contains(".o-mail-ActivityMarkAsDone textarea[placeholder='Write Feedback']"); await contains(".o-mail-ActivityMarkAsDone button[aria-label='Done and Schedule Next']"); await contains(".o-mail-ActivityMarkAsDone button[aria-label='Done']"); - await contains(".o-mail-ActivityMarkAsDone button", 1, { text: "Discard" }); + await contains(".o-mail-ActivityMarkAsDone button", { text: "Discard" }); }); QUnit.test("activity with force next mark done popover simplest layout", async () => { @@ -49,8 +49,8 @@ QUnit.test("activity with force next mark done popover simplest layout", async ( await contains(".o-mail-ActivityMarkAsDone"); await contains(".o-mail-ActivityMarkAsDone textarea[placeholder='Write Feedback']"); await contains(".o-mail-ActivityMarkAsDone button[aria-label='Done and Schedule Next']"); - await contains(".o-mail-ActivityMarkAsDone button[aria-label='Done']", 0); - await contains(".o-mail-ActivityMarkAsDone button", 1, { text: "Discard" }); + await contains(".o-mail-ActivityMarkAsDone button[aria-label='Done']", { count: 0 }); + await contains(".o-mail-ActivityMarkAsDone button", { text: "Discard" }); }); QUnit.test("activity mark done popover mark done without feedback", async (assert) => { diff --git a/addons/mail/static/tests/activity/activity_menu_tests.js b/addons/mail/static/tests/activity/activity_menu_tests.js index 57e35eb5c89..d67ccc7d4b3 100644 --- a/addons/mail/static/tests/activity/activity_menu_tests.js +++ b/addons/mail/static/tests/activity/activity_menu_tests.js @@ -14,5 +14,5 @@ QUnit.test("should update activities when opening the activity menu", async (ass res_model: "res.partner", }); await click(".o_menu_systray i[aria-label='Activities']"); - await contains(".o-mail-ActivityMenu-counter", 1, { text: "1" }); + await contains(".o-mail-ActivityMenu-counter", { text: "1" }); }); diff --git a/addons/mail/static/tests/activity/activity_tests.js b/addons/mail/static/tests/activity/activity_tests.js index 3b1e63536a1..2a59434dbe2 100644 --- a/addons/mail/static/tests/activity/activity_tests.js +++ b/addons/mail/static/tests/activity/activity_tests.js @@ -39,7 +39,7 @@ QUnit.test("activity upload document is available", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity-info span", 1, { text: "Upload Document" }); + await contains(".o-mail-Activity-info span", { text: "Upload Document" }); await contains(".btn .fa-upload"); await contains(".o-mail-Activity .o_input_file"); }); @@ -62,10 +62,10 @@ QUnit.test("activity can upload a document", async () => { contentType: "text/plain", name: "text.txt", }); - await contains(".o-mail-Activity-info span", 1, { text: "Upload Document" }); + await contains(".o-mail-Activity-info span", { text: "Upload Document" }); inputFiles($(".o-mail-Activity .o_input_file")[0], [file]); - await contains(".o-mail-Activity-info span", 0, { text: "Upload Document" }); - await contains("button[aria-label='Attach files']", 1, { text: "1" }); + await contains(".o-mail-Activity-info span", { count: 0, text: "Upload Document" }); + await contains("button[aria-label='Attach files']", { text: "1" }); }); QUnit.test("activity simplest layout", async () => { @@ -81,13 +81,13 @@ QUnit.test("activity simplest layout", async () => { await contains(".o-mail-Activity-sidebar"); await contains(".o-mail-Activity-user"); await contains(".o-mail-Activity-info"); - await contains(".o-mail-Activity-note", 0); - await contains(".o-mail-Activity-details", 0); - await contains(".o-mail-Activity-mailTemplates", 0); - await contains(".btn", 0, { text: "Edit" }); - await contains(".o-mail-Activity span", 0, { text: "Cancel" }); - await contains(".btn", 0, { text: "Mark Done" }); - await contains(".o-mail-Activity-info span", 0, { text: "Upload Document" }); + await contains(".o-mail-Activity-note", { count: 0 }); + await contains(".o-mail-Activity-details", { count: 0 }); + await contains(".o-mail-Activity-mailTemplates", { count: 0 }); + await contains(".btn", { count: 0, text: "Edit" }); + await contains(".o-mail-Activity span", { count: 0, text: "Cancel" }); + await contains(".btn", { count: 0, text: "Mark Done" }); + await contains(".o-mail-Activity-info span", { count: 0, text: "Upload Document" }); }); QUnit.test("activity with note layout", async (assert) => { @@ -120,7 +120,7 @@ QUnit.test("activity info layout when planned after tomorrow", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity span.text-success", 1, { text: "Due in 5 days:" }); + await contains(".o-mail-Activity span.text-success", { text: "Due in 5 days:" }); }); QUnit.test("activity info layout when planned tomorrow", async () => { @@ -138,7 +138,7 @@ QUnit.test("activity info layout when planned tomorrow", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity span.text-success", 1, { text: "Tomorrow:" }); + await contains(".o-mail-Activity span.text-success", { text: "Tomorrow:" }); }); QUnit.test("activity info layout when planned today", async () => { @@ -153,7 +153,7 @@ QUnit.test("activity info layout when planned today", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity span.text-warning", 1, { text: "Today:" }); + await contains(".o-mail-Activity span.text-warning", { text: "Today:" }); }); QUnit.test("activity info layout when planned yesterday", async () => { @@ -171,7 +171,7 @@ QUnit.test("activity info layout when planned yesterday", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity span.text-danger", 1, { text: "Yesterday:" }); + await contains(".o-mail-Activity span.text-danger", { text: "Yesterday:" }); }); QUnit.test("activity info layout when planned before yesterday", async () => { @@ -189,7 +189,7 @@ QUnit.test("activity info layout when planned before yesterday", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity span.text-danger", 1, { text: "5 days overdue:" }); + await contains(".o-mail-Activity span.text-danger", { text: "5 days overdue:" }); }); /** @@ -213,11 +213,11 @@ QUnit.skip("activity info layout change at midnight", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity span.text-success", 1, { text: "Tomorrow:" }); + await contains(".o-mail-Activity span.text-success", { text: "Tomorrow:" }); patchDate(2023, 11, 8, 0, 0, 1); // OXP is coming! await mock.advanceTime(2000); - await contains(".o-mail-Activity span.text-warning", 1, { text: "Today:" }); + await contains(".o-mail-Activity span.text-warning", { text: "Today:" }); }); QUnit.test("activity with a summary layout", async () => { @@ -230,7 +230,7 @@ QUnit.test("activity with a summary layout", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity-info span", 1, { text: "“test summary”" }); + await contains(".o-mail-Activity-info span", { text: "“test summary”" }); }); QUnit.test("activity without summary layout", async () => { @@ -243,7 +243,7 @@ QUnit.test("activity without summary layout", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity-info span", 1, { text: "Email" }); + await contains(".o-mail-Activity-info span", { text: "Email" }); }); QUnit.test("activity details toggle", async () => { @@ -264,14 +264,14 @@ QUnit.test("activity details toggle", async () => { const { openFormView } = await start(); openFormView("res.partner", partnerId); await contains(".o-mail-Activity"); - await contains(".o-mail-Activity-details", 0); + await contains(".o-mail-Activity-details", { count: 0 }); await contains(".o-mail-Activity-info i[aria-label='Info']"); await click(".o-mail-Activity-info i[aria-label='Info']"); await contains(".o-mail-Activity-details"); await click(".o-mail-Activity-info i[aria-label='Info']"); - await contains(".o-mail-Activity-details", 0); + await contains(".o-mail-Activity-details", { count: 0 }); }); QUnit.test("activity with mail template layout", async (assert) => { @@ -290,7 +290,7 @@ QUnit.test("activity with mail template layout", async (assert) => { await contains(".o-mail-Activity"); await contains(".o-mail-Activity-sidebar"); await contains(".o-mail-Activity-mailTemplates"); - await contains(".o-mail-ActivityMailTemplate-name", 1, { text: "Dummy mail template" }); + await contains(".o-mail-ActivityMailTemplate-name", { text: "Dummy mail template" }); await contains(".o-mail-ActivityMailTemplate-preview"); await contains(".o-mail-ActivityMailTemplate-send"); }); @@ -373,7 +373,7 @@ QUnit.test("activity click on mark as done", async () => { await click(".btn", { text: "Mark Done" }); await contains(".o-mail-ActivityMarkAsDone"); await click(".btn", { text: "Mark Done" }); - await contains(".o-mail-ActivityMarkAsDone", 0); + await contains(".o-mail-ActivityMarkAsDone", { count: 0 }); }); QUnit.test( @@ -447,7 +447,7 @@ QUnit.test("activity click on cancel", async (assert) => { }); openFormView("res.partner", partnerId); await click(".o-mail-Activity span", { text: "Cancel" }); - await contains(".o-mail-Activity", 0); + await contains(".o-mail-Activity", { count: 0 }); assert.verifySteps(["unlink"]); }); @@ -469,7 +469,7 @@ QUnit.test("activity mark done popover close on ESCAPE", async () => { await contains(".o-mail-ActivityMarkAsDone"); triggerHotkey("Escape"); - await contains(".o-mail-ActivityMarkAsDone", 0); + await contains(".o-mail-ActivityMarkAsDone", { count: 0 }); }); QUnit.test("activity mark done popover click on discard", async () => { @@ -487,7 +487,7 @@ QUnit.test("activity mark done popover click on discard", async () => { openFormView("res.partner", partnerId); await click(".btn", { text: "Mark Done" }); await click(".o-mail-ActivityMarkAsDone button", { text: "Discard" }); - await contains(".o-mail-ActivityMarkAsDone", 0); + await contains(".o-mail-ActivityMarkAsDone", { count: 0 }); }); QUnit.test("Activity are sorted by deadline", async () => { @@ -519,7 +519,7 @@ QUnit.test("Activity are sorted by deadline", async () => { }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Activity:eq(0) span", 1, { text: "5 days overdue:" }); - await contains(".o-mail-Activity:eq(1) span", 1, { text: "Today:" }); - await contains(".o-mail-Activity:eq(2) span", 1, { text: "Due in 4 days:" }); + await contains(".o-mail-Activity:eq(0) span", { text: "5 days overdue:" }); + await contains(".o-mail-Activity:eq(1) span", { text: "Today:" }); + await contains(".o-mail-Activity:eq(2) span", { text: "Due in 4 days:" }); }); diff --git a/addons/mail/static/tests/chat_window/chat_window_manager_tests.js b/addons/mail/static/tests/chat_window/chat_window_manager_tests.js index 1ccd9db6cec..9d7478b0d22 100644 --- a/addons/mail/static/tests/chat_window/chat_window_manager_tests.js +++ b/addons/mail/static/tests/chat_window/chat_window_manager_tests.js @@ -65,11 +65,11 @@ QUnit.test("chat window does not fetch messages if hidden", async (assert) => { } }, }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow", { count: 2 }); await contains(".o-mail-ChatWindowHiddenToggler"); - await contains(".o-mail-Message-content", 1, { text: "Orange" }); - await contains(".o-mail-Message-content", 0, { text: "Apple" }); - await contains(".o-mail-Message-content", 1, { text: "Banana" }); + await contains(".o-mail-Message-content", { text: "Orange" }); + await contains(".o-mail-Message-content", { count: 0, text: "Apple" }); + await contains(".o-mail-Message-content", { text: "Banana" }); assert.verifySteps(["fetch_messages", "fetch_messages"]); }); @@ -127,17 +127,17 @@ QUnit.test("click on hidden chat window should fetch its messages", async (asser } }, }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow", { count: 2 }); await contains(".o-mail-ChatWindowHiddenToggler"); - await contains(".o-mail-Message-content", 1, { text: "Orange" }); - await contains(".o-mail-Message-content", 0, { text: "Apple" }); - await contains(".o-mail-Message-content", 1, { text: "Banana" }); + await contains(".o-mail-Message-content", { text: "Orange" }); + await contains(".o-mail-Message-content", { count: 0, text: "Apple" }); + await contains(".o-mail-Message-content", { text: "Banana" }); assert.verifySteps(["fetch_messages", "fetch_messages"]); await click(".o-mail-ChatWindowHiddenToggler"); await click(".o-mail-ChatWindowHiddenMenu-item .o-mail-ChatWindow-command[title='Open']"); - await contains(".o-mail-Message-content", 1, { text: "Orange" }); - await contains(".o-mail-Message-content", 1, { text: "Apple" }); - await contains(".o-mail-Message", 0, { text: "Banana" }); + await contains(".o-mail-Message-content", { text: "Orange" }); + await contains(".o-mail-Message-content", { text: "Apple" }); + await contains(".o-mail-Message", { count: 0, text: "Banana" }); assert.verifySteps(["fetch_messages"]); }); @@ -168,19 +168,19 @@ QUnit.test( await contains(".o-mail-ChatWindow"); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "channel-B" }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow", { count: 2 }); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "channel-C" }); - await contains(".o-mail-ChatWindowHiddenToggler", 1, { text: "1" }); + await contains(".o-mail-ChatWindowHiddenToggler", { text: "1" }); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "channel-D" }); - await contains(".o-mail-ChatWindowHiddenToggler", 1, { text: "2" }); - await contains(".o-mail-ChatWindow-name:eq(0)", 1, { text: "channel-A" }); - await contains(".o-mail-ChatWindow-name:eq(1)", 1, { text: "channel-D" }); + await contains(".o-mail-ChatWindowHiddenToggler", { text: "2" }); + await contains(".o-mail-ChatWindow-name:eq(0)", { text: "channel-A" }); + await contains(".o-mail-ChatWindow-name:eq(1)", { text: "channel-D" }); await click( ".o-mail-ChatWindow-header:contains(channel-D) .o-mail-ChatWindow-command[title='Close Chat Window']" ); - await contains(".o-mail-ChatWindow-name:eq(0)", 1, { text: "channel-A" }); - await contains(".o-mail-ChatWindow-name:eq(1)", 1, { text: "channel-C" }); + await contains(".o-mail-ChatWindow-name:eq(0)", { text: "channel-A" }); + await contains(".o-mail-ChatWindow-name:eq(1)", { text: "channel-C" }); } ); diff --git a/addons/mail/static/tests/chat_window/chat_window_tests.js b/addons/mail/static/tests/chat_window/chat_window_tests.js index e4bd57daece..6236ba2feab 100644 --- a/addons/mail/static/tests/chat_window/chat_window_tests.js +++ b/addons/mail/static/tests/chat_window/chat_window_tests.js @@ -40,7 +40,7 @@ QUnit.test( patchUiSize({ size: SIZES.SM }); const { env } = await start(); await contains(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-MessagingMenu-counter", 0); + await contains(".o-mail-MessagingMenu-counter", { count: 0 }); // simulate receiving a message pyEnv.withUser(userId, () => env.services.rpc("/mail/message/post", { @@ -49,8 +49,8 @@ QUnit.test( thread_model: "discuss.channel", }) ); - await contains(".o-mail-MessagingMenu-counter", 1, { text: "1" }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-MessagingMenu-counter", { text: "1" }); + await contains(".o-mail-ChatWindow", { count: 0 }); } ); @@ -94,7 +94,7 @@ QUnit.test("Message post in chat window of chatter should log a note", async () await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-Message-content", 1, { + await contains(".o-mail-Message-content", { text: "A needaction message to have it in messaging menu", }); await contains( @@ -103,8 +103,8 @@ QUnit.test("Message post in chat window of chatter should log a note", async () await contains(".o-mail-Composer [placeholder='Log an internal note…']"); await insertText(".o-mail-ChatWindow .o-mail-Composer-input", "Test"); triggerHotkey("control+Enter"); - await contains(".o-mail-Message-content", 1, { text: "Test" }); - await contains(".o-mail-Message:contains(Test) .o-mail-Message-bubble.border", 0); // non-bordered bubble = "Log note" mode + await contains(".o-mail-Message-content", { text: "Test" }); + await contains(".o-mail-Message:contains(Test) .o-mail-Message-bubble.border", { count: 0 }); // non-bordered bubble = "Log note" mode }); QUnit.test("load messages from opening chat window from messaging menu", async () => { @@ -124,7 +124,7 @@ QUnit.test("load messages from opening chat window from messaging menu", async ( await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message", 21); + await contains(".o-mail-Message", { count: 21 }); }); QUnit.test("chat window: basic rendering", async () => { @@ -136,17 +136,17 @@ QUnit.test("chat window: basic rendering", async () => { await contains(".o-mail-ChatWindow"); await contains(".o-mail-ChatWindow-header"); await contains(".o-mail-ChatWindow-header .o-mail-ChatWindow-threadAvatar"); - await contains(".o-mail-ChatWindow-name", 1, { text: "General" }); - await contains(".o-mail-ChatWindow-command", 4); + await contains(".o-mail-ChatWindow-name", { text: "General" }); + await contains(".o-mail-ChatWindow-command", { count: 4 }); await contains("[title='Start a Call']"); await contains("[title='Open Actions Menu']"); await contains("[title='Fold']"); await contains("[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow-content .o-mail-Thread .o-mail-Thread-empty", 1, { + await contains(".o-mail-ChatWindow-content .o-mail-Thread .o-mail-Thread-empty", { text: "There are no messages in this conversation.", }); await click("[title='Open Actions Menu']"); - await contains(".o-mail-ChatWindow-command", 10); + await contains(".o-mail-ChatWindow-command", { count: 10 }); await contains("[title='Pinned Messages']"); await contains("[title='Show Attachments']"); await contains("[title='Add Users']"); @@ -163,14 +163,14 @@ QUnit.test("Fold state of chat window is sync among browser tabs", async () => { await click(".o_menu_systray i[aria-label='Messages']", { target: tab1.target }); await click(".o-mail-NotificationItem", { target: tab1.target }); await click(".o-mail-ChatWindow-header", { target: tab1.target }); // Fold - await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", 0, { target: tab1.target }); - await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", 0, { target: tab2.target }); + await contains(".o-mail-ChatWindow-content", { count: 0, target: tab1.target }); + await contains(".o-mail-ChatWindow-content", { count: 0, target: tab2.target }); await click(".o-mail-ChatWindow-header", { target: tab2.target }); // Unfold - await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", 1, { target: tab1.target }); - await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", 1, { target: tab2.target }); + await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", { target: tab1.target }); + await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", { target: tab2.target }); await click("[title='Close Chat Window']", { target: tab1.target }); - await contains(".o-mail-ChatWindow", 0, { target: tab1.target }); - await contains(".o-mail-ChatWindow", 0, { target: tab2.target }); + await contains(".o-mail-ChatWindow", { count: 0, target: tab1.target }); + await contains(".o-mail-ChatWindow", { count: 0, target: tab2.target }); }); QUnit.test( @@ -213,7 +213,7 @@ QUnit.test("chat window: fold", async (assert) => { // Fold chat window await click(".o-mail-ChatWindow-command[title='Fold']"); - await contains(".o-mail-ChatWindow .o-mail-Thread", 0); + await contains(".o-mail-ChatWindow .o-mail-Thread", { count: 0 }); assert.verifySteps(["rpc:channel_fold/folded"]); // Unfold chat window @@ -233,13 +233,13 @@ QUnit.test("chat window: open / close", async (assert) => { }, }); await click("button i[aria-label='Messages']"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); await click(".o-mail-NotificationItem"); await contains(".o-mail-ChatWindow"); assert.verifySteps(["rpc:channel_fold/open"]); await click(".o-mail-ChatWindow-command[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); assert.verifySteps(["rpc:channel_fold/closed"]); // Reopen chat window @@ -275,7 +275,7 @@ QUnit.test( await click(".o-mail-NotificationItem"); await contains(".o-mail-ChatWindow"); await click("[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); const [member] = pyEnv["discuss.channel.member"].searchRead([ ["channel_id", "=", channelId], ["partner_id", "=", pyEnv.currentPartnerId], @@ -302,7 +302,7 @@ QUnit.test("chat window: close on ESCAPE", async (assert) => { $(".o-mail-Composer-input")[0].focus(); triggerHotkey("Escape"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); assert.verifySteps(["rpc:channel_fold/closed"]); }); @@ -343,7 +343,7 @@ QUnit.test( await start(); await click("button[aria-label='Emojis']"); triggerHotkey("Escape"); - await contains(".o-EmojiPicker", 0); + await contains(".o-EmojiPicker", { count: 0 }); await contains(".o-mail-ChatWindow"); } ); @@ -360,7 +360,7 @@ QUnit.test("open 2 different chat windows: enough screen width [REQUIRE FOCUS]", await click("button i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Channel_1" }); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Channel_1" }); + await contains(".o-mail-ChatWindow-name", { text: "Channel_1" }); assert.strictEqual( document.activeElement, $(".o-mail-ChatWindow-name:contains(Channel_1)") @@ -370,9 +370,9 @@ QUnit.test("open 2 different chat windows: enough screen width [REQUIRE FOCUS]", await click("button i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Channel_2" }); - await contains(".o-mail-ChatWindow", 2); - await contains(".o-mail-ChatWindow-name", 1, { text: "Channel_2" }); - await contains(".o-mail-ChatWindow-name", 1, { text: "Channel_1" }); + await contains(".o-mail-ChatWindow", { count: 2 }); + await contains(".o-mail-ChatWindow-name", { text: "Channel_2" }); + await contains(".o-mail-ChatWindow-name", { text: "Channel_1" }); assert.strictEqual( document.activeElement, $(".o-mail-ChatWindow-name:contains(Channel_2)") @@ -404,19 +404,19 @@ QUnit.test("open 3 different chat windows: not enough screen width", async (asse await click("button i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Channel_1" }); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-ChatWindowHiddenToggler", 0); + await contains(".o-mail-ChatWindowHiddenToggler", { count: 0 }); await click("button i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Channel_2" }); - await contains(".o-mail-ChatWindow", 2); - await contains(".o-mail-ChatWindowHiddenToggler", 0); + await contains(".o-mail-ChatWindow", { count: 2 }); + await contains(".o-mail-ChatWindowHiddenToggler", { count: 0 }); await click("button i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Channel_3" }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow", { count: 2 }); await contains(".o-mail-ChatWindowHiddenToggler"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Channel_1" }); - await contains(".o-mail-ChatWindow-name", 1, { text: "Channel_3" }); + await contains(".o-mail-ChatWindow-name", { text: "Channel_1" }); + await contains(".o-mail-ChatWindow-name", { text: "Channel_3" }); assert.strictEqual( document.activeElement, $(".o-mail-ChatWindow-name:contains(Channel_3)") @@ -449,30 +449,30 @@ QUnit.test("closing hidden chat window", async (assert) => { await contains(".o-mail-ChatWindow"); await click("i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Ch_2" }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow", { count: 2 }); await click("i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Ch_3" }); - await contains(".o-mail-ChatWindowHiddenToggler", 1, { text: "1" }); + await contains(".o-mail-ChatWindowHiddenToggler", { text: "1" }); await click("i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Ch_4" }); - await contains(".o-mail-ChatWindowHiddenToggler", 1, { text: "2" }); + await contains(".o-mail-ChatWindowHiddenToggler", { text: "2" }); await click(".o-mail-ChatWindowHiddenToggler"); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_1", }); - await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", 1, { text: "Ch_2" }); - await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", 1, { text: "Ch_3" }); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", { text: "Ch_2" }); + await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", { text: "Ch_3" }); + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_4", }); await click(".o-mail-ChatWindow:contains(Ch_2) [title='Close Chat Window']"); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_1", }); - await contains(".o-mail-ChatWindow-name", 0, { text: "Ch_2" }); + await contains(".o-mail-ChatWindow-name", { count: 0, text: "Ch_2" }); - await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", 1, { text: "Ch_3" }); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", { text: "Ch_3" }); + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_4", }); }); @@ -498,23 +498,23 @@ QUnit.test("Opening hidden chat window from messaging menu", async (assert) => { await click("i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Ch_3" }); await click(".o-mail-ChatWindowHiddenToggler"); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_1", }); - await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", 1, { text: "Ch_2" }); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", { text: "Ch_2" }); + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_3", }); await click("i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Ch_2" }); await click(".o-mail-ChatWindowHiddenToggler"); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_1", }); - await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", 1, { + await contains(":not(.o-mail-ChatWindowHiddenMenu) .o-mail-ChatWindow-name", { text: "Ch_2", }); - await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", 1, { text: "Ch_3" }); + await contains(".o-mail-ChatWindowHiddenMenu .o-mail-ChatWindow-name", { text: "Ch_3" }); }); QUnit.test( @@ -558,7 +558,7 @@ QUnit.test( "should have enough space to open 2 chat windows simultaneously" ); await start(); - await contains(".o-mail-ChatWindow .o-mail-Composer-input", 2); + await contains(".o-mail-ChatWindow .o-mail-Composer-input", { count: 2 }); $(".o-mail-ChatWindow-name:contains(MyTeam)") .closest(".o-mail-ChatWindow") @@ -586,7 +586,7 @@ QUnit.test("chat window: switch on TAB [REQUIRE FOCUS]", async (assert) => { await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "channel1" }); - await contains(".o-mail-ChatWindow", 1); + await contains(".o-mail-ChatWindow", { count: 1 }); await contains(".o-mail-ChatWindow:contains(channel1) .o-mail-Composer-input:focus"); triggerHotkey("Tab"); @@ -594,7 +594,7 @@ QUnit.test("chat window: switch on TAB [REQUIRE FOCUS]", async (assert) => { await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "channel2" }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow", { count: 2 }); await contains(".o-mail-ChatWindow:contains(channel2) .o-mail-Composer-input:focus"); triggerHotkey("Tab"); @@ -655,7 +655,7 @@ QUnit.test("chat window: TAB cycle with 3 open chat windows [REQUIRE FOCUS]", as ); await start(); // FIXME: assumes ordering: MyProject, MyTeam, General - await contains(".o-mail-ChatWindow .o-mail-Composer-input", 3); + await contains(".o-mail-ChatWindow .o-mail-Composer-input", { count: 3 }); (await contains(".o-mail-ChatWindow:contains(MyProject) .o-mail-Composer-input"))[0].focus(); triggerHotkey("Tab"); @@ -709,8 +709,8 @@ QUnit.test( }) ); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); } ); @@ -739,7 +739,7 @@ QUnit.test( thread_model: "discuss.channel", }) ); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); } ); @@ -785,7 +785,7 @@ QUnit.test("chat window should not open when receiving a new DM from odoobot", a thread_model: "discuss.channel", }) ); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); }); QUnit.test( @@ -813,11 +813,11 @@ QUnit.test( }); } await start(); - await contains(".o-mail-Message", 10); + await contains(".o-mail-Message", { count: 10 }); await insertText(".o-mail-Composer-input", "WOLOLO"); triggerHotkey("Enter"); - await contains(".o-mail-Message", 11); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 11 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); } ); @@ -845,7 +845,7 @@ QUnit.test("chat window should remain folded when new message is received", asyn }); const { env } = await start(); await contains(".o-mail-ChatWindow.o-folded"); - await contains(".o-mail-ChatWindow-counter", 0); + await contains(".o-mail-ChatWindow-counter", { count: 0 }); pyEnv.withUser(userId, () => env.services.rpc("/mail/message/post", { post_data: { body: "New Message", message_type: "comment" }, @@ -853,7 +853,7 @@ QUnit.test("chat window should remain folded when new message is received", asyn thread_model: "discuss.channel", }) ); - await contains(".o-mail-ChatWindow-counter", 1, { text: "1" }); + await contains(".o-mail-ChatWindow-counter", { text: "1" }); await contains(".o-mail-ChatWindow.o-folded"); }); @@ -891,7 +891,7 @@ QUnit.test( // simulate resize to go into mobile patchUiSize({ size: SIZES.SM }); window.dispatchEvent(new UIEvent("resize")); - await contains(".o-mail-ChatWindowHiddenToggler", 0); + await contains(".o-mail-ChatWindowHiddenToggler", { count: 0 }); } ); @@ -903,7 +903,9 @@ QUnit.test("chat window: composer state conservation on toggle discuss", async ( await click(".o-mail-NotificationItem"); // Set content of the composer of the chat window await insertText(".o-mail-Composer-input", "XDU for the win !"); - await contains(".o-mail-Composer-footer .o-mail-AttachmentList .o-mail-AttachmentCard", 0); + await contains(".o-mail-Composer-footer .o-mail-AttachmentList .o-mail-AttachmentCard", { + count: 0, + }); // Set attachments of the composer const files = [ await createFile({ @@ -918,18 +920,20 @@ QUnit.test("chat window: composer state conservation on toggle discuss", async ( }), ]; inputFiles($(".o-mail-Composer-coreMain .o_input_file")[0], files); - await contains(".o-mail-AttachmentCard .fa-check", 2); + await contains(".o-mail-AttachmentCard .fa-check", { count: 2 }); openDiscuss(); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); openView({ res_id: channelId, res_model: "discuss.channel", views: [[false, "form"]], }); - await contains(".o-mail-Composer-footer .o-mail-AttachmentList .o-mail-AttachmentCard", 2); - await contains(".o-mail-Composer-input", 1, { value: "XDU for the win !" }); + await contains(".o-mail-Composer-footer .o-mail-AttachmentList .o-mail-AttachmentCard", { + count: 2, + }); + await contains(".o-mail-Composer-input", { value: "XDU for the win !" }); }); QUnit.test( @@ -979,9 +983,9 @@ QUnit.test( thread_model: "discuss.channel", }) ); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); $(".o-mail-Composer-input")[0].focus(); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); } ); @@ -998,18 +1002,18 @@ QUnit.test("chat window: scroll conservation on toggle discuss", async () => { const { openDiscuss, openView } = await start(); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message", 31); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 31 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-ChatWindow .o-mail-Thread", 142); openDiscuss(null, { waitUntilMessagesLoaded: false }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); openView({ res_id: channelId, res_model: "discuss.channel", views: [[false, "list"]], }); - await contains(".o-mail-Message", 31); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: 142 }); + await contains(".o-mail-Message", { count: 31 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: 142 }); }); QUnit.test( @@ -1027,17 +1031,17 @@ QUnit.test( await start(); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message", 31); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 31 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-ChatWindow .o-mail-Thread", 142); // fold chat window await click(".o-mail-ChatWindow-command[title='Fold']"); - await contains(".o-mail-Message", 0); - await contains(".o-mail-ChatWindow .o-mail-Thread", 0); + await contains(".o-mail-Message", { count: 0 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { count: 0 }); // unfold chat window await click(".o-mail-ChatWindow-command[title='Open']"); - await contains(".o-mail-Message", 31); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: 142 }); + await contains(".o-mail-Message", { count: 31 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: 142 }); } ); @@ -1056,13 +1060,13 @@ QUnit.test( const { openDiscuss, openView } = await start(); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message", 31); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 31 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-ChatWindow .o-mail-Thread", 142); // fold chat window await click(".o-mail-ChatWindow-command[title='Fold']"); openDiscuss(null, { waitUntilMessagesLoaded: false }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); openView({ res_id: channelId, res_model: "discuss.channel", @@ -1070,8 +1074,8 @@ QUnit.test( }); // unfold chat window await click(".o-mail-ChatWindow-command[title='Open']"); - await contains(".o-mail-ChatWindow .o-mail-Message", 31); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: 142 }); + await contains(".o-mail-ChatWindow .o-mail-Message", { count: 31 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: 142 }); } ); @@ -1087,13 +1091,13 @@ QUnit.test("folded chat window should hide member-list and settings buttons", as await contains("[title='Show Call Settings']"); await click(".o-mail-ChatWindow-header"); // click away to close the more menu - await contains("[title='Show Member List']", 0); + await contains("[title='Show Member List']", { count: 0 }); // Fold chat window await click(".o-mail-ChatWindow-command[title='Fold']"); - await contains("[title='Open Actions Menu']", 0); - await contains("[title='Show Member List']", 0); - await contains("[title='Show Call Settings']", 0); + await contains("[title='Open Actions Menu']", { count: 0 }); + await contains("[title='Show Member List']", { count: 0 }); + await contains("[title='Show Call Settings']", { count: 0 }); // Unfold chat window await click(".o-mail-ChatWindow-command[title='Open']"); @@ -1113,7 +1117,7 @@ QUnit.test("Chat window in mobile are not foldable", async () => { await start(); await click("button i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-ChatWindow-header.cursor-pointer", 0); + await contains(".o-mail-ChatWindow-header.cursor-pointer", { count: 0 }); await click(".o-mail-ChatWindow-header"); await contains(".o-mail-ChatWindow-content"); // content => non-folded }); @@ -1132,7 +1136,7 @@ QUnit.test("Server-synced chat windows should not open at page load on mobile", patchUiSize({ size: SIZES.SM }); await start(); await contains(".o-mail-ChatWindowContainer"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); }); QUnit.test("chat window of channels should not have 'Open in Discuss' (mobile)", async () => { @@ -1145,7 +1149,7 @@ QUnit.test("chat window of channels should not have 'Open in Discuss' (mobile)", await contains(".o-mail-ChatWindow"); await contains("[title='Open Actions Menu']"); await click("[title='Open Actions Menu']"); - await contains("[title='Open in Discuss']", 0); + await contains("[title='Open in Discuss']", { count: 0 }); }); QUnit.test("Open chat window of new inviter", async () => { @@ -1158,7 +1162,7 @@ QUnit.test("Open chat window of new inviter", async () => { username: "Newbie", partnerId, }); - await contains(".o-mail-ChatWindow-name", 1, { text: "Newbie" }); + await contains(".o-mail-ChatWindow-name", { text: "Newbie" }); await contains( ".o_notification:contains(Newbie connected. This is their first connection. Wish them luck.)" ); @@ -1209,7 +1213,7 @@ QUnit.test( await contains(".o-mail-Message-moreMenu.dropdown-menu"); document.querySelector(".o-mail-Message [title='Expand']").focus(); // necessary otherwise focus is in composer input triggerHotkey("Escape"); - await contains(".o-mail-Message-moreMenu.dropdown-menu", 0); + await contains(".o-mail-Message-moreMenu.dropdown-menu", { count: 0 }); await contains(".o-mail-ChatWindow"); } ); diff --git a/addons/mail/static/tests/composer/composer_tests.js b/addons/mail/static/tests/composer/composer_tests.js index e4cbd1aa132..bc23599e811 100644 --- a/addons/mail/static/tests/composer/composer_tests.js +++ b/addons/mail/static/tests/composer/composer_tests.js @@ -89,7 +89,7 @@ QUnit.test("add an emoji", async () => { openDiscuss(channelId); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "😤" }); - await contains(".o-mail-Composer-input", 1, { value: "😤" }); + await contains(".o-mail-Composer-input", { value: "😤" }); }); QUnit.test( @@ -100,9 +100,9 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss(channelId); await click("button[aria-label='Emojis']"); - await contains(".o-mail-Composer-input:focus", 0); + await contains(".o-mail-Composer-input:focus", { count: 0 }); triggerHotkey("Escape"); - await contains(".o-mail-Composer-input:focus", 1); + await contains(".o-mail-Composer-input:focus", { count: 1 }); } ); @@ -112,11 +112,11 @@ QUnit.test("add an emoji after some text", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "Blabla"); - await contains(".o-mail-Composer-input", 1, { value: "Blabla" }); + await contains(".o-mail-Composer-input", { value: "Blabla" }); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "🤑" }); - await contains(".o-mail-Composer-input", 1, { value: "Blabla🤑" }); + await contains(".o-mail-Composer-input", { value: "Blabla🤑" }); }); QUnit.test("add emoji replaces (keyboard) text selection [REQUIRE FOCUS]", async () => { @@ -125,12 +125,12 @@ QUnit.test("add emoji replaces (keyboard) text selection [REQUIRE FOCUS]", async const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "Blabla"); - const textarea = (await contains(".o-mail-Composer-input", 1, { value: "Blabla" }))[0]; + const textarea = (await contains(".o-mail-Composer-input", { value: "Blabla" }))[0]; // simulate selection of all the content by keyboard textarea.setSelectionRange(0, textarea.value.length); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "🤠" }); - await contains(".o-mail-Composer-input", 1, { value: "🤠" }); + await contains(".o-mail-Composer-input", { value: "🤠" }); }); QUnit.test("Cursor is positioned after emoji after adding it", async (assert) => { @@ -153,13 +153,13 @@ QUnit.test("selected text is not replaced after cancelling the selection", async const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "Blabla"); - const textarea = (await contains(".o-mail-Composer-input", 1, { value: "Blabla" }))[0]; + const textarea = (await contains(".o-mail-Composer-input", { value: "Blabla" }))[0]; // simulate selection of all the content by keyboard textarea.setSelectionRange(0, textarea.value.length); await click(".o-mail-Discuss-content"); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "🤠" }); - await contains(".o-mail-Composer-input", 1, { value: "Blabla🤠" }); + await contains(".o-mail-Composer-input", { value: "Blabla🤠" }); }); QUnit.test( @@ -206,7 +206,7 @@ QUnit.test("keep emoji picker scroll value when re-opening it", async () => { await scroll(".o-EmojiPicker-content", 150); await click("button[aria-label='Emojis']"); await click("button[aria-label='Emojis']"); - await contains(".o-EmojiPicker-content", 1, { scroll: 150 }); + await contains(".o-EmojiPicker-content", { scroll: 150 }); }); QUnit.test("reset emoji picker scroll value after an emoji is picked", async () => { @@ -218,7 +218,7 @@ QUnit.test("reset emoji picker scroll value after an emoji is picked", async () await scroll(".o-EmojiPicker-content", 150); await click(".o-Emoji", { text: "😎" }); await click("button[aria-label='Emojis']"); - await contains(".o-EmojiPicker-content", 1, { scroll: 0 }); + await contains(".o-EmojiPicker-content", { scroll: 0 }); }); QUnit.test( @@ -244,10 +244,10 @@ QUnit.test( await scroll(".o-EmojiPicker-content", 200); await triggerEvent(getFixture(), null, "mousedown"); await click("button[aria-label='Emojis']"); - await contains(".o-EmojiPicker-content", 1, { scroll: 150 }); + await contains(".o-EmojiPicker-content", { scroll: 150 }); await triggerEvent(getFixture(), null, "mousedown"); await click("[title='Add a Reaction']"); - await contains(".o-EmojiPicker-content", 1, { scroll: 200 }); + await contains(".o-EmojiPicker-content", { scroll: 200 }); } ); @@ -257,11 +257,11 @@ QUnit.test("composer text input cleared on message post", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "test message"); - await contains(".o-mail-Composer-input", 1, { value: "test message" }); + await contains(".o-mail-Composer-input", { value: "test message" }); await click(".o-mail-Composer-send:not([disabled])"); await contains(".o-mail-Message"); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); }); QUnit.test("send message only once when button send is clicked twice quickly", async () => { @@ -280,7 +280,7 @@ QUnit.test('send button on discuss.channel should have "Send" as label', async ( const channelId = pyEnv["discuss.channel"].create({ name: "minecraft-wii-u" }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Composer-send:disabled", 1, { text: "Send" }); + await contains(".o-mail-Composer-send:disabled", { text: "Send" }); }); QUnit.test("Show send button in mobile", async () => { @@ -308,11 +308,10 @@ QUnit.test( await insertText(".o-mail-Composer-input", "According to all known laws of aviation,"); await click("span", { text: "epic-shrek-lovers" }); await contains("textarea.o-mail-Composer-input[placeholder='Message #epic-shrek-lovers…']"); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); await click("span", { text: "minigolf-galaxy-iv" }); await contains( "textarea.o-mail-Composer-input[placeholder='Message #minigolf-galaxy-iv…']", - 1, { value: "According to all known laws of aviation," } ); } @@ -333,13 +332,13 @@ QUnit.test("add an emoji after a partner mention", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "@Te"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "@TestPartner " }); + await contains(".o-mail-Composer-input", { value: "@TestPartner " }); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "😊" }); - await contains(".o-mail-Composer-input", 1, { value: "@TestPartner 😊" }); + await contains(".o-mail-Composer-input", { value: "@TestPartner 😊" }); }); QUnit.test("mention a channel after some text", async () => { @@ -350,12 +349,12 @@ QUnit.test("mention a channel after some text", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "bluhbluh "); - await contains(".o-mail-Composer-input", 1, { value: "bluhbluh " }); + await contains(".o-mail-Composer-input", { value: "bluhbluh " }); await insertText(".o-mail-Composer-input", "#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "bluhbluh #General " }); + await contains(".o-mail-Composer-input", { value: "bluhbluh #General " }); }); QUnit.test("add an emoji after a channel mention", async () => { @@ -366,13 +365,13 @@ QUnit.test("add an emoji after a channel mention", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "#General " }); + await contains(".o-mail-Composer-input", { value: "#General " }); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "😊" }); - await contains(".o-mail-Composer-input", 1, { value: "#General 😊" }); + await contains(".o-mail-Composer-input", { value: "#General 😊" }); }); QUnit.test("pending mentions are kept when toggling composer", async () => { @@ -382,12 +381,12 @@ QUnit.test("pending mentions are kept when toggling composer", async () => { await click("button", { text: "Send message" }); await insertText(".o-mail-Composer-input", "@"); await click(".o-mail-Composer-suggestion strong", { text: "Mitchell Admin" }); - await contains(".o-mail-Composer-input", 1, { value: "@Mitchell Admin " }); + await contains(".o-mail-Composer-input", { value: "@Mitchell Admin " }); await click("button", { text: "Send message" }); - await contains(".o-mail-Composer-input", 0); + await contains(".o-mail-Composer-input", { count: 0 }); await click("button", { text: "Send message" }); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-body a.o_mail_redirect", 1, { text: "@Mitchell Admin" }); + await contains(".o-mail-Message-body a.o_mail_redirect", { text: "@Mitchell Admin" }); }); QUnit.test('do not post message on channel with "SHIFT-Enter" keyboard shortcut', async () => { @@ -396,10 +395,10 @@ QUnit.test('do not post message on channel with "SHIFT-Enter" keyboard shortcut' const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "Test"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); triggerHotkey("shift+Enter"); await nextTick(); // weak test, no guarantee that we waited long enough for the potential message to be posted - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test('post message on channel with "Enter" keyboard shortcut', async () => { @@ -408,7 +407,7 @@ QUnit.test('post message on channel with "Enter" keyboard shortcut', async () => const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "Test"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); triggerHotkey("Enter"); await contains(".o-mail-Message"); }); @@ -420,14 +419,14 @@ QUnit.test("leave command on channel", async () => { openDiscuss(channelId); await contains(".o-mail-DiscussSidebarChannel:contains(general).o-active"); await insertText(".o-mail-Composer-input", "/leave"); - await contains(".o-mail-Composer-suggestion strong", 1); + await contains(".o-mail-Composer-suggestion strong", { count: 1 }); triggerHotkey("Enter"); - await contains(".o-mail-Composer-input", 1, { value: "/leave " }); + await contains(".o-mail-Composer-input", { value: "/leave " }); triggerHotkey("Enter"); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "general" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "general" }); - await contains(".o-mail-Discuss h4.text-muted", 1, { text: "No conversation selected." }); - await contains(".o_notification_content", 1, { text: "You unsubscribed from general." }); + await contains(".o-mail-Discuss h4.text-muted", { text: "No conversation selected." }); + await contains(".o_notification_content", { text: "You unsubscribed from general." }); }); QUnit.test("Can handle leave notification from unknown member", async () => { @@ -447,8 +446,8 @@ QUnit.test("Can handle leave notification from unknown member", async () => { env.services.orm.call("discuss.channel", "action_unfollow", [channelId]) ); await click("button[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 1, { text: "Mitchell Admin" }); - await contains(".o-discuss-ChannelMember", 0, { text: "Dobby" }); + await contains(".o-discuss-ChannelMember", { text: "Mitchell Admin" }); + await contains(".o-discuss-ChannelMember", { count: 0, text: "Dobby" }); }); QUnit.test("leave command on chat", async () => { @@ -465,14 +464,14 @@ QUnit.test("leave command on chat", async () => { openDiscuss(channelId); await contains(".o-mail-DiscussSidebarChannel:contains(Chuck Norris).o-active"); await insertText(".o-mail-Composer-input", "/leave"); - await contains(".o-mail-Composer-suggestion strong", 1); + await contains(".o-mail-Composer-suggestion strong", { count: 1 }); triggerHotkey("Enter"); - await contains(".o-mail-Composer-input", 1, { value: "/leave " }); + await contains(".o-mail-Composer-input", { value: "/leave " }); triggerHotkey("Enter"); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "Chuck Norris" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "Chuck Norris" }); - await contains(".o-mail-Discuss h4.text-muted", 1, { text: "No conversation selected." }); - await contains(".o_notification_content", 1, { + await contains(".o-mail-Discuss h4.text-muted", { text: "No conversation selected." }); + await contains(".o_notification_content", { text: "You unpinned your conversation with Chuck Norris", }); }); @@ -483,9 +482,9 @@ QUnit.test("Can post suggestions", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "#general"); - await contains(".o-mail-Composer-suggestion strong", 1); + await contains(".o-mail-Composer-suggestion strong", { count: 1 }); triggerHotkey("Enter"); - await contains(".o-mail-Composer-input", 1, { value: "#general " }); + await contains(".o-mail-Composer-input", { value: "#general " }); triggerHotkey("Enter"); await contains(".o-mail-Message .o_channel_redirect"); }); @@ -521,14 +520,14 @@ QUnit.test("quick edit last self-message from UP arrow", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message-content", 1, { text: "Test" }); - await contains(".o-mail-Message:contains(Test) .o-mail-Composer", 0); + await contains(".o-mail-Message-content", { text: "Test" }); + await contains(".o-mail-Message:contains(Test) .o-mail-Composer", { count: 0 }); triggerHotkey("ArrowUp"); await contains(".o-mail-Message .o-mail-Composer"); triggerHotkey("Escape"); - await contains(".o-mail-Message .o-mail-Composer", 0); + await contains(".o-mail-Message .o-mail-Composer", { count: 0 }); await contains(".o-mail-Composer-input:focus"); // non-empty composer should not trigger quick edit @@ -538,7 +537,7 @@ QUnit.test("quick edit last self-message from UP arrow", async () => { // Wait 2 animation frames to make sure it doesn't show quick edit await nextTick(); await nextTick(); - await contains(".o-mail-Message .o-mail-Composer", 0); + await contains(".o-mail-Message .o-mail-Composer", { count: 0 }); }); QUnit.test("Select composer suggestion via Enter does not send the message", async () => { @@ -560,9 +559,9 @@ QUnit.test("Select composer suggestion via Enter does not send the message", asy await insertText(".o-mail-Composer-input", "@Shrek"); await contains(".o-mail-Composer-suggestion"); triggerHotkey("Enter"); - await contains(".o-mail-Composer-input", 1, { value: "@Shrek " }); + await contains(".o-mail-Composer-input", { value: "@Shrek " }); // weak test, no guarantee that we waited long enough for the potential message to be posted - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test("composer: drop attachments", async () => { @@ -583,14 +582,14 @@ QUnit.test("composer: drop attachments", async () => { }), ]; await contains(".o-mail-Composer-input"); - await contains(".o-mail-Dropzone", 0); - await contains(".o-mail-AttachmentCard", 0); + await contains(".o-mail-Dropzone", { count: 0 }); + await contains(".o-mail-AttachmentCard", { count: 0 }); dragenterFiles($(".o-mail-Composer-input")[0]); await contains(".o-mail-Dropzone"); - await contains(".o-mail-AttachmentCard", 0); + await contains(".o-mail-AttachmentCard", { count: 0 }); dropFiles((await contains(".o-mail-Dropzone"))[0], files); - await contains(".o-mail-Dropzone", 0); - await contains(".o-mail-AttachmentCard", 2); + await contains(".o-mail-Dropzone", { count: 0 }); + await contains(".o-mail-AttachmentCard", { count: 2 }); dragenterFiles($(".o-mail-Composer-input")[0]); dropFiles((await contains(".o-mail-Dropzone"))[0], [ await createFile({ @@ -599,7 +598,7 @@ QUnit.test("composer: drop attachments", async () => { name: "text3.txt", }), ]); - await contains(".o-mail-AttachmentCard", 3); + await contains(".o-mail-AttachmentCard", { count: 3 }); }); QUnit.test("composer: add an attachment", async () => { @@ -671,7 +670,7 @@ QUnit.test("composer: send button is disabled if attachment upload is not finish // simulates attachment finishes uploading attachmentUploadedPromise.resolve(); await contains(".o-mail-AttachmentCard"); - await contains(".o-mail-AttachmentCard.o-isUploading", 0); + await contains(".o-mail-AttachmentCard.o-isUploading", { count: 0 }); await contains(".o-mail-Composer-send:not(:disabled)"); }); @@ -691,7 +690,7 @@ QUnit.test("remove an attachment from composer does not need any confirmation", await contains(".o-mail-AttachmentList .o-mail-AttachmentCard"); await click(".o-mail-AttachmentCard-unlink"); - await contains(".o-mail-AttachmentList .o-mail-AttachmentCard", 0); + await contains(".o-mail-AttachmentList .o-mail-AttachmentCard", { count: 0 }); }); QUnit.test("composer: paste attachments", async () => { @@ -707,7 +706,7 @@ QUnit.test("composer: paste attachments", async () => { }), ]; await contains(".o-mail-Composer-input"); - await contains(".o-mail-AttachmentList .o-mail-AttachmentCard", 0); + await contains(".o-mail-AttachmentList .o-mail-AttachmentCard", { count: 0 }); pasteFiles($(".o-mail-Composer-input")[0], files); await contains(".o-mail-AttachmentList .o-mail-AttachmentCard"); }); @@ -751,7 +750,7 @@ QUnit.test("remove an uploading attachment", async () => { await contains(".o-mail-AttachmentCard.o-isUploading"); click(".o-mail-AttachmentCard-unlink"); - await contains(".o-mail-Composer .o-mail-AttachmentCard", 0); + await contains(".o-mail-Composer .o-mail-AttachmentCard", { count: 0 }); }); QUnit.test("Show a thread name in the recipient status text.", async () => { @@ -766,7 +765,7 @@ QUnit.test("Show a thread name in the recipient status text.", async () => { const { openFormView } = await start(); openFormView("res.partner", partnerId); await click("button", { text: "Send message" }); - await contains(".o-mail-Chatter div", 1, { text: "To: test" }); + await contains(".o-mail-Chatter div", { text: "To: test" }); await contains('span[title="test@odoo.com"]'); }); @@ -792,13 +791,13 @@ QUnit.test("Show recipient list when there is more than 5 followers.", async () openFormView("res.partner", partnerIds[0]); await click("button", { text: "Send message" }); await click("button[title='Show all recipients']"); - await contains("li", 1, { text: "test1@odoo.com" }); - await contains("li", 1, { text: "test2@odoo.com" }); - await contains("li", 1, { text: "test3@odoo.com" }); - await contains("li", 1, { text: "test4@odoo.com" }); - await contains("li", 1, { text: "test5@odoo.com" }); - await contains("li", 1, { text: "test6@odoo.com" }); - await contains(".o-mail-Chatter div", 1, { text: "To: test1, test2, test3, test4, test5, …" }); + await contains("li", { text: "test1@odoo.com" }); + await contains("li", { text: "test2@odoo.com" }); + await contains("li", { text: "test3@odoo.com" }); + await contains("li", { text: "test4@odoo.com" }); + await contains("li", { text: "test5@odoo.com" }); + await contains("li", { text: "test6@odoo.com" }); + await contains(".o-mail-Chatter div", { text: "To: test1, test2, test3, test4, test5, …" }); }); QUnit.test( @@ -827,9 +826,9 @@ QUnit.test( contentType: "text/plain", }); inputFiles((await contains(".o-mail-Composer-coreMain .o_input_file"))[0], [file1, file2]); - await contains(".o-mail-AttachmentCard div", 1, { text: "text1.txt" }); - await contains(".o-mail-AttachmentCard div", 1, { text: "text2.txt" }); - await contains(".o-mail-AttachmentCard-aside div[title='Uploading']", 2); + await contains(".o-mail-AttachmentCard div", { text: "text1.txt" }); + await contains(".o-mail-AttachmentCard div", { text: "text2.txt" }); + await contains(".o-mail-AttachmentCard-aside div[title='Uploading']", { count: 2 }); } ); @@ -865,11 +864,11 @@ QUnit.test( }), ]); inputFiles(input[0], [file1, file2]); - await contains(".o-mail-AttachmentCard.o-isUploading div", 1, { text: "text1.txt" }); - await contains(".o-mail-AttachmentCard.o-isUploading div", 1, { text: "text2.txt" }); + await contains(".o-mail-AttachmentCard.o-isUploading div", { text: "text1.txt" }); + await contains(".o-mail-AttachmentCard.o-isUploading div", { text: "text2.txt" }); click(".o-mail-AttachmentCard-unlink:eq(1)"); - await contains(".o-mail-AttachmentCard div", 0, { text: "text2.txt" }); + await contains(".o-mail-AttachmentCard div", { count: 0, text: "text2.txt" }); // Simulates the completion of the upload of the first attachment uploadPromise.resolve(); @@ -890,5 +889,5 @@ QUnit.test("Message is sent only once when pressing enter twice in a row", async triggerHotkey("Enter"); triggerHotkey("Enter"); }); - await contains(".o-mail-Message-content", 1, { text: "Hello World!" }); + await contains(".o-mail-Message-content", { text: "Hello World!" }); }); diff --git a/addons/mail/static/tests/composer/suggested_recipients_test.js b/addons/mail/static/tests/composer/suggested_recipients_test.js index 310cbcd0b0b..20cdfc736a4 100644 --- a/addons/mail/static/tests/composer/suggested_recipients_test.js +++ b/addons/mail/static/tests/composer/suggested_recipients_test.js @@ -29,8 +29,8 @@ QUnit.test("with 3 or less suggested recipients: no 'show more' button", async ( const { openFormView } = await start(); openFormView("res.fake", fakeId); await click("button", { text: "Send message" }); - await contains(".o-mail-SuggestedRecipient", 2); - await contains("button", 0, { text: "Show more" }); + await contains(".o-mail-SuggestedRecipient", { count: 2 }); + await contains("button", { count: 0, text: "Show more" }); }); QUnit.test( @@ -66,8 +66,8 @@ QUnit.test( }, }); await click("button", { text: "Send message" }); - await contains(".o-mail-SuggestedRecipient", 1, { text: "john@test.be (john@test.be)" }); - await contains(".o-mail-SuggestedRecipient", 1, { text: "John Jane" }); + await contains(".o-mail-SuggestedRecipient", { text: "john@test.be (john@test.be)" }); + await contains(".o-mail-SuggestedRecipient", { text: "John Jane" }); assert.ok( $(".o-mail-SuggestedRecipient:contains(john@test.be) input[type=checkbox]")[0].checked ); @@ -106,8 +106,8 @@ QUnit.test( }, }); await click("button", { text: "Send message" }); - await contains(".o-mail-SuggestedRecipient", 1, { text: "john@test.be (john@test.be)" }); - await contains(".o-mail-SuggestedRecipient", 1, { text: "John Jane" }); + await contains(".o-mail-SuggestedRecipient", { text: "john@test.be (john@test.be)" }); + await contains(".o-mail-SuggestedRecipient", { text: "John Jane" }); assert.ok( $(".o-mail-SuggestedRecipient:contains(john@test.be) input[type=checkbox]")[0].checked ); @@ -135,7 +135,7 @@ QUnit.test("more than 3 suggested recipients: display only 3 and 'show more' but const { openFormView } = await start({ serverData: { views } }); openFormView("res.fake", fakeId); await click("button", { text: "Send message" }); - await contains("button", 1, { text: "Show more" }); + await contains("button", { text: "Show more" }); }); QUnit.test( @@ -155,7 +155,7 @@ QUnit.test( openFormView("res.fake", fakeId); await click("button", { text: "Send message" }); await click("button", { text: "Show more" }); - await contains(".o-mail-SuggestedRecipient", 4); + await contains(".o-mail-SuggestedRecipient", { count: 4 }); } ); @@ -176,7 +176,7 @@ QUnit.test( openFormView("res.fake", fakeId); await click("button", { text: "Send message" }); await click("button", { text: "Show more" }); - await contains("button", 1, { text: "Show less" }); + await contains("button", { text: "Show less" }); } ); @@ -198,8 +198,8 @@ QUnit.test( await click("button", { text: "Send message" }); await click("button", { text: "Show more" }); await click("button", { text: "Show less" }); - await contains(".o-mail-SuggestedRecipient", 3); - await contains("button", 1, { text: "Show more" }); + await contains(".o-mail-SuggestedRecipient", { count: 3 }); + await contains("button", { text: "Show more" }); } ); @@ -218,7 +218,7 @@ QUnit.test( const { openFormView } = await start({ serverData: { views } }); openFormView("res.fake", fakeId); await click("button", { text: "Send message" }); - await contains(".o-mail-SuggestedRecipient input:checked", 2); + await contains(".o-mail-SuggestedRecipient input:checked", { count: 2 }); assert.ok( $(".o-mail-SuggestedRecipient:not([data-partner-id]) input[type=checkbox]")[0].checked ); diff --git a/addons/mail/static/tests/core/open_chat_test.js b/addons/mail/static/tests/core/open_chat_test.js index 61faec4ded6..9057f0d68d7 100644 --- a/addons/mail/static/tests/core/open_chat_test.js +++ b/addons/mail/static/tests/core/open_chat_test.js @@ -32,7 +32,7 @@ QUnit.test("openChat: open new chat for user", async () => { pyEnv["res.users"].create({ partner_id: partnerId }); const { env } = await start(); await contains(".o-mail-ChatWindowContainer"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); env.services["mail.thread"].openChat({ partnerId }); await contains(".o-mail-ChatWindow"); }); diff --git a/addons/mail/static/tests/core/out_of_focus_tests.js b/addons/mail/static/tests/core/out_of_focus_tests.js index b0afcfae130..72414b6c93b 100644 --- a/addons/mail/static/tests/core/out_of_focus_tests.js +++ b/addons/mail/static/tests/core/out_of_focus_tests.js @@ -24,7 +24,7 @@ QUnit.test("Spaces in notifications are not encoded", async () => { res_id: channelId, }, }); - await contains(".o_notification.border-info .o_notification_content", 1, { + await contains(".o_notification.border-info .o_notification_content", { text: "Hello world!", }); }); diff --git a/addons/mail/static/tests/crosstab/crosstab_tests.js b/addons/mail/static/tests/crosstab/crosstab_tests.js index 549bdc027a9..4a7bfce93f9 100644 --- a/addons/mail/static/tests/crosstab/crosstab_tests.js +++ b/addons/mail/static/tests/crosstab/crosstab_tests.js @@ -17,8 +17,8 @@ QUnit.test("Messages are received cross-tab", async () => { tab2.openDiscuss(channelId); await tab1.insertText(".o-mail-Composer-input", "Hello World!"); await click("button:contains(Send):not(:disabled)", { target: tab1.target }); - await contains(".o-mail-Message-content", 1, { target: tab1.target, text: "Hello World!" }); - await contains(".o-mail-Message-content", 1, { target: tab2.target, text: "Hello World!" }); + await contains(".o-mail-Message-content", { target: tab1.target, text: "Hello World!" }); + await contains(".o-mail-Message-content", { target: tab2.target, text: "Hello World!" }); }); QUnit.test("Delete starred message updates counter", async () => { @@ -36,14 +36,14 @@ QUnit.test("Delete starred message updates counter", async () => { const tab2 = await start({ asTab: true }); tab1.openDiscuss(channelId); tab2.openDiscuss(channelId); - await contains("button", 1, { target: tab2.target, text: "Starred1" }); + await contains("button", { target: tab2.target, text: "Starred1" }); tab1.env.services.rpc("/mail/message/update_content", { message_id: messageId, body: "", attachment_ids: [], }); - await contains("button", 0, { target: tab2.target, text: "Starred1" }); + await contains("button", { count: 0, target: tab2.target, text: "Starred1" }); }); QUnit.test("Thread rename", async () => { @@ -58,8 +58,8 @@ QUnit.test("Thread rename", async () => { tab2.openDiscuss(channelId); await tab1.insertText(".o-mail-Discuss-threadName:not(:disabled)", "Sales", { replace: true }); triggerHotkey("Enter"); - await contains(".o-mail-Discuss-threadName[title='Sales']", 1, { target: tab2.target }); - await contains(".o-mail-DiscussSidebarChannel span", 1, { target: tab2.target, text: "Sales" }); + await contains(".o-mail-Discuss-threadName[title='Sales']", { target: tab2.target }); + await contains(".o-mail-DiscussSidebarChannel span", { target: tab2.target, text: "Sales" }); }); QUnit.test("Thread description update", async () => { @@ -76,7 +76,7 @@ QUnit.test("Thread description update", async () => { replace: true, }); triggerHotkey("Enter"); - await contains(".o-mail-Discuss-threadDescription[title='The very best channel']", 1, { + await contains(".o-mail-Discuss-threadDescription[title='The very best channel']", { target: tab2.target, }); }); @@ -98,7 +98,7 @@ QUnit.test("Channel subscription is renewed when channel is added from invite", env.services.orm.call("discuss.channel", "add_members", [[channelId]], { partner_ids: [pyEnv.currentPartnerId], }); - await contains(".o-mail-DiscussSidebarChannel", 2); + await contains(".o-mail-DiscussSidebarChannel", { count: 2 }); await new Promise((resolve) => setTimeout(resolve)); // update of channels is debounced assert.verifySteps(["update-channels"]); }); @@ -114,7 +114,7 @@ QUnit.test("Channel subscription is renewed when channel is left", async (assert }); openDiscuss(); await click(".o-mail-DiscussSidebarChannel .btn[title='Leave this channel']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await new Promise((resolve) => setTimeout(resolve)); // update of channels is debounced assert.verifySteps(["update-channels"]); }); @@ -141,7 +141,7 @@ QUnit.test("Adding attachments", async () => { attachment_ids: [attachmentId], message_id: messageId, }); - await contains(".o-mail-AttachmentCard div", 1, { target: tab2.target, text: "test.txt" }); + await contains(".o-mail-AttachmentCard div", { target: tab2.target, text: "test.txt" }); }); QUnit.test("Remove attachment from message", async () => { @@ -162,11 +162,15 @@ QUnit.test("Remove attachment from message", async () => { const tab2 = await start({ asTab: true }); tab1.openDiscuss(channelId); tab2.openDiscuss(channelId); - await contains(".o-mail-AttachmentCard div", 1, { target: tab1.target, text: "test.txt" }); + await contains(".o-mail-AttachmentCard div", { target: tab1.target, text: "test.txt" }); await click(".o-mail-AttachmentCard-unlink", { target: tab2.target }); await click(".modal-footer .btn:contains(Ok)", { target: tab2.target }); - await contains(".o-mail-AttachmentCard div", 0, { target: tab1.target, text: "test.txt" }); + await contains(".o-mail-AttachmentCard div", { + count: 0, + target: tab1.target, + text: "test.txt", + }); }); QUnit.test("Message delete notification", async () => { @@ -193,7 +197,7 @@ QUnit.test("Message delete notification", async () => { pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.message/delete", { message_ids: [messageId], }); - await contains(".o-mail-Message", 0); - await contains("button:contains(Inbox) .badge", 0); - await contains("button:contains(Starred) .badge", 0); + await contains(".o-mail-Message", { count: 0 }); + await contains("button:contains(Inbox) .badge", { count: 0 }); + await contains("button:contains(Starred) .badge", { count: 0 }); }); diff --git a/addons/mail/static/tests/discuss/call/call_settings_menu_tests.js b/addons/mail/static/tests/discuss/call/call_settings_menu_tests.js index 6691d601dc8..d73101782b3 100644 --- a/addons/mail/static/tests/discuss/call/call_settings_menu_tests.js +++ b/addons/mail/static/tests/discuss/call/call_settings_menu_tests.js @@ -36,7 +36,7 @@ QUnit.test("Renders the call settings", async () => { await contains(".o-discuss-CallSettings"); await contains("label[aria-label='Input device']"); await contains("option[value=mockAudioDeviceId]"); - await contains("option[value=mockVideoDeviceId]", 0); + await contains("option[value=mockVideoDeviceId]", { count: 0 }); await contains("input[title='toggle push-to-talk']"); await contains("label[aria-label='Voice detection threshold']"); await contains("input[title='Show video participants only']"); @@ -60,7 +60,7 @@ QUnit.test("activate push to talk", async () => { await click("input[title='toggle push-to-talk']"); await contains("i[aria-label='Register new key']"); await contains("label[aria-label='Delay after releasing push-to-talk']"); - await contains("label[aria-label='Voice detection threshold']", 0); + await contains("label[aria-label='Voice detection threshold']", { count: 0 }); }); QUnit.test("activate blur", async () => { @@ -87,7 +87,7 @@ QUnit.test("Inbox should not have any call settings menu", async () => { const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Thread"); - await contains("button[title='Show Call Settings']", 0); + await contains("button[title='Show Call Settings']", { count: 0 }); }); QUnit.test( @@ -107,7 +107,7 @@ QUnit.test( openDiscuss(channelId); await click("button[title='Show Call Settings']"); await click("button div", { text: "Inbox" }); - await contains("button[title='Hide Call Settings']", 0); - await contains(".o-discuss-CallSettings", 0); + await contains("button[title='Hide Call Settings']", { count: 0 }); + await contains(".o-discuss-CallSettings", { count: 0 }); } ); diff --git a/addons/mail/static/tests/discuss/call/call_tests.js b/addons/mail/static/tests/discuss/call/call_tests.js index ca5d73dae78..dac0bb176be 100644 --- a/addons/mail/static/tests/discuss/call/call_tests.js +++ b/addons/mail/static/tests/discuss/call/call_tests.js @@ -28,7 +28,7 @@ QUnit.test("basic rendering", async () => { await contains(".o-discuss-CallParticipantCard[aria-label='Mitchell Admin']"); await contains(".o-discuss-CallActionList"); await contains(".o-discuss-CallMenu-buttonContent"); - await contains(".o-discuss-CallActionList button", 5); + await contains(".o-discuss-CallActionList button", { count: 5 }); await contains("button[aria-label='Unmute'], button[aria-label='Mute']"); // FIXME depends on current browser permission await contains(".o-discuss-CallActionList button[aria-label='Deafen']"); await contains(".o-discuss-CallActionList button[aria-label='Turn camera on']"); @@ -52,7 +52,7 @@ QUnit.test("no call with odoobot", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Discuss-header"); - await contains(".o-mail-Discuss-header button[title='Start a Call']", 0); + await contains(".o-mail-Discuss-header button[title='Start a Call']", { count: 0 }); }); QUnit.test("should not display call UI when no more members (self disconnect)", async () => { @@ -64,7 +64,7 @@ QUnit.test("should not display call UI when no more members (self disconnect)", await click(".o-mail-Discuss-header button[title='Start a Call']"); await contains(".o-discuss-Call"); await click(".o-discuss-CallActionList button[aria-label='Disconnect']"); - await contains(".o-discuss-Call", 0); + await contains(".o-discuss-Call", { count: 0 }); }); QUnit.test("show call UI in chat window when in call", async () => { @@ -75,10 +75,10 @@ QUnit.test("show call UI in chat window when in call", async () => { await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "General" }); await contains(".o-mail-ChatWindow"); - await contains(".o-discuss-Call", 0); + await contains(".o-discuss-Call", { count: 0 }); await click(".o-mail-ChatWindow-command[title='Start a Call']"); await contains(".o-discuss-Call"); - await contains(".o-mail-ChatWindow-command[title='Start a Call']", 0); + await contains(".o-mail-ChatWindow-command[title='Start a Call']", { count: 0 }); }); QUnit.test("should disconnect when closing page while in call", async (assert) => { @@ -149,7 +149,7 @@ QUnit.test("should display invitations", async (assert) => { rtcInvitingSession: [["unlink"]], }, }); - await contains(".o-discuss-CallInvitation", 0); + await contains(".o-discuss-CallInvitation", { count: 0 }); assert.verifySteps(["pause_sound_effect"]); }); @@ -167,7 +167,7 @@ QUnit.test("can share screen", async () => { await contains(".o-discuss-CallParticipantCard video"); await click(".o-discuss-CallActionList [title='More']"); await click("[title='Stop Sharing Screen']"); - await contains(".o-discuss-CallParticipantCard video", 0); + await contains(".o-discuss-CallParticipantCard video", { count: 0 }); }); QUnit.test("can share user camera", async () => { @@ -182,7 +182,7 @@ QUnit.test("can share user camera", async () => { await click(".o-discuss-CallActionList button[title='Turn camera on']"); await contains(".o-discuss-CallParticipantCard video"); await click(".o-discuss-CallActionList button[title='Stop camera']"); - await contains(".o-discuss-CallParticipantCard video", 0); + await contains(".o-discuss-CallParticipantCard video", { count: 0 }); }); QUnit.test("Create a direct message channel when clicking on start a meeting", async () => { @@ -190,7 +190,7 @@ QUnit.test("Create a direct message channel when clicking on start a meeting", a const { openDiscuss } = await start(); openDiscuss(); await click("button", { text: "Start a meeting" }); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Mitchell Admin" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Mitchell Admin" }); await contains(".o-discuss-Call"); await contains(".o-discuss-ChannelInvitation"); }); diff --git a/addons/mail/static/tests/discuss/call/web/call_tests.js b/addons/mail/static/tests/discuss/call/web/call_tests.js index b7bb456000d..0b4c33d32d9 100644 --- a/addons/mail/static/tests/discuss/call/web/call_tests.js +++ b/addons/mail/static/tests/discuss/call/web/call_tests.js @@ -13,14 +13,14 @@ QUnit.test("no default rtc after joining a chat conversation", async () => { const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Start a conversation']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "mario"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); triggerHotkey("Enter"); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-Discuss-content .o-mail-Message", 0); - await contains(".o-discuss-Call", 0); + await contains(".o-mail-Discuss-content .o-mail-Message", { count: 0 }); + await contains(".o-discuss-Call", { count: 0 }); }); QUnit.test("no default rtc after joining a group conversation", async () => { @@ -33,13 +33,13 @@ QUnit.test("no default rtc after joining a group conversation", async () => { const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Start a conversation']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "mario"); await click(".o-discuss-ChannelSelector-suggestion", { text: "Mario" }); await insertText(".o-discuss-ChannelSelector input", "luigi", { replace: true }); await click(".o-discuss-ChannelSelector-suggestion", { text: "Luigi" }); triggerHotkey("Enter"); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-Discuss-content .o-mail-Message", 0); - await contains(".o-discuss-Call", 0); + await contains(".o-mail-Discuss-content .o-mail-Message", { count: 0 }); + await contains(".o-discuss-Call", { count: 0 }); }); diff --git a/addons/mail/static/tests/discuss/core/channel_invitation_tests.js b/addons/mail/static/tests/discuss/core/channel_invitation_tests.js index ccaa6e9a477..c3252f000fb 100644 --- a/addons/mail/static/tests/discuss/core/channel_invitation_tests.js +++ b/addons/mail/static/tests/discuss/core/channel_invitation_tests.js @@ -51,7 +51,7 @@ QUnit.test("can invite users in channel from chat window", async () => { ".o-discuss-ChannelInvitation-selectable:contains(TestPartner) input[type='checkbox']" ); await click("[title='Invite to Channel']:not(:disabled)"); - await contains(".o-discuss-ChannelInvitation", 0); + await contains(".o-discuss-ChannelInvitation", { count: 0 }); await contains( ".o-mail-Thread .o-mail-NotificationMessage:contains(Mitchell Admin invited TestPartner to the channel)" ); @@ -81,7 +81,7 @@ QUnit.test("should be able to search for a new user to invite from an existing c openDiscuss(channelId); await click(".o-mail-Discuss-header button[title='Add Users']"); await insertText(".o-discuss-ChannelInvitation-search", "TestPartner2"); - await contains(".o-discuss-ChannelInvitation-selectable", 1, { text: "TestPartner2" }); + await contains(".o-discuss-ChannelInvitation-selectable", { text: "TestPartner2" }); }); QUnit.test("Invitation form should display channel group restriction", async () => { diff --git a/addons/mail/static/tests/discuss/core/channel_member_list_tests.js b/addons/mail/static/tests/discuss/core/channel_member_list_tests.js index 717e1d5349f..2f5502c5002 100644 --- a/addons/mail/static/tests/discuss/core/channel_member_list_tests.js +++ b/addons/mail/static/tests/discuss/core/channel_member_list_tests.js @@ -61,9 +61,9 @@ QUnit.test("should have correct members in member list", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click("[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 2); + await contains(".o-discuss-ChannelMember", { count: 2 }); await contains(`.o-discuss-ChannelMember:contains("${pyEnv.currentPartner.name}")`); - await contains(".o-discuss-ChannelMember", 1, { text: "Demo" }); + await contains(".o-discuss-ChannelMember", { text: "Demo" }); }); QUnit.test( @@ -121,7 +121,7 @@ QUnit.test("should show a button to load more members if they are not all loaded openDiscuss(channelId); pyEnv["discuss.channel"].write([channelId], { channel_member_ids }); await click("[title='Show Member List']"); - await contains("button", 1, { text: "Load more" }); + await contains("button", { text: "Load more" }); }); QUnit.test("Load more button should load more members", async (assert) => { @@ -141,7 +141,7 @@ QUnit.test("Load more button should load more members", async (assert) => { pyEnv["discuss.channel"].write([channelId], { channel_member_ids }); await click("[title='Show Member List']"); await click("[title='Load more']"); - await contains(".o-discuss-ChannelMember", 102); + await contains(".o-discuss-ChannelMember", { count: 102 }); }); QUnit.test("Channel member count update after user joined", async () => { @@ -152,13 +152,13 @@ QUnit.test("Channel member count update after user joined", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click("[title='Show Member List']"); - await contains(".o-discuss-ChannelMemberList h6", 1, { text: "Offline - 1" }); + await contains(".o-discuss-ChannelMemberList h6", { text: "Offline - 1" }); await click("[title='Add Users']"); await click(".o-discuss-ChannelInvitation-selectable", { text: "Harry" }); await click("[title='Invite to Channel']:not(:disabled)"); - await contains(".o-discuss-ChannelInvitation", 0); + await contains(".o-discuss-ChannelInvitation", { count: 0 }); await click("[title='Show Member List']"); - await contains(".o-discuss-ChannelMemberList h6", 1, { text: "Offline - 2" }); + await contains(".o-discuss-ChannelMemberList h6", { text: "Offline - 2" }); }); QUnit.test("Channel member count update after user left", async (assert) => { diff --git a/addons/mail/static/tests/discuss/core/composer_tests.js b/addons/mail/static/tests/discuss/core/composer_tests.js index 719ce0335e0..298e5f5ad67 100644 --- a/addons/mail/static/tests/discuss/core/composer_tests.js +++ b/addons/mail/static/tests/discuss/core/composer_tests.js @@ -46,7 +46,7 @@ QUnit.test( openDiscuss(channelId); await insertText(".o-mail-Composer-input", "/"); await click(".o-mail-Composer-suggestion:eq(0)"); - await contains(".o-mail-Composer-suggestion strong", 0); + await contains(".o-mail-Composer-suggestion strong", { count: 0 }); await insertText(".o-mail-Composer-input", " is user?"); assert.verifySteps([], "No rpc done"); } @@ -60,11 +60,11 @@ QUnit.test("add an emoji after a command", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "/"); await click(".o-mail-Composer-suggestion:eq(0)"); - await contains(".o-mail-Composer-input", 1, { value: "/who " }); + await contains(".o-mail-Composer-input", { value: "/who " }); await click("button[aria-label='Emojis']"); await click(".o-Emoji", { text: "😊" }); - await contains(".o-mail-Composer-input", 1, { value: "/who 😊" }); + await contains(".o-mail-Composer-input", { value: "/who 😊" }); }); diff --git a/addons/mail/static/tests/discuss/core/crosstab_tests.js b/addons/mail/static/tests/discuss/core/crosstab_tests.js index 1a08fc2d75b..50b018128b0 100644 --- a/addons/mail/static/tests/discuss/core/crosstab_tests.js +++ b/addons/mail/static/tests/discuss/core/crosstab_tests.js @@ -13,13 +13,13 @@ QUnit.test("Add member to channel", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click("[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 1, { text: "Mitchell Admin" }); + await contains(".o-discuss-ChannelMember", { text: "Mitchell Admin" }); await click("[title='Add Users']"); await click(".o-discuss-ChannelInvitation-selectable", { text: "Harry" }); await click("[title='Invite to Channel']:not(:disabled)"); - await contains(".o-discuss-ChannelInvitation", 0); + await contains(".o-discuss-ChannelInvitation", { count: 0 }); await click("[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 1, { text: "Harry" }); + await contains(".o-discuss-ChannelMember", { text: "Harry" }); }); QUnit.test("Remove member from channel", async () => { @@ -39,9 +39,9 @@ QUnit.test("Remove member from channel", async () => { const { env, openDiscuss } = await start(); openDiscuss(channelId); await click("[title='Show Member List']"); - await contains(".o-discuss-ChannelMember", 1, { text: "Harry" }); + await contains(".o-discuss-ChannelMember", { text: "Harry" }); pyEnv.withUser(userId, () => env.services.orm.call("discuss.channel", "action_unfollow", [channelId]) ); - await contains(".o-discuss-ChannelMember", 0, { text: "Harry" }); + await contains(".o-discuss-ChannelMember", { count: 0, text: "Harry" }); }); diff --git a/addons/mail/static/tests/discuss/core/discuss_tests.js b/addons/mail/static/tests/discuss/core/discuss_tests.js index 905561d1bd9..03bc99cc2a9 100644 --- a/addons/mail/static/tests/discuss/core/discuss_tests.js +++ b/addons/mail/static/tests/discuss/core/discuss_tests.js @@ -13,5 +13,5 @@ QUnit.test("Member list and settings menu are exclusive", async () => { await contains(".o-discuss-ChannelMemberList"); await click("[title='Show Call Settings']"); await contains(".o-discuss-CallSettings"); - await contains(".o-discuss-ChannelMemberList", 0); + await contains(".o-discuss-ChannelMemberList", { count: 0 }); }); diff --git a/addons/mail/static/tests/discuss/core/suggestion_tests.js b/addons/mail/static/tests/discuss/core/suggestion_tests.js index cd6fafbc56c..1e7fba8ad21 100644 --- a/addons/mail/static/tests/discuss/core/suggestion_tests.js +++ b/addons/mail/static/tests/discuss/core/suggestion_tests.js @@ -26,7 +26,7 @@ QUnit.test('display command suggestions on typing "/"', async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); await insertText(".o-mail-Composer-input", "/"); await contains(".o-mail-Composer-suggestionList .o-open"); }); @@ -37,11 +37,11 @@ QUnit.test("use a command for a specific channel type", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "/"); await click(".o-mail-Composer-suggestion strong", { text: "who" }); - await contains(".o-mail-Composer-input", 1, { value: "/who " }); + await contains(".o-mail-Composer-input", { value: "/who " }); }); QUnit.test("command suggestion should only open if command is the first character", async () => { @@ -53,13 +53,13 @@ QUnit.test("command suggestion should only open if command is the first characte const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "bluhbluh "); - await contains(".o-mail-Composer-input", 1, { value: "bluhbluh " }); + await contains(".o-mail-Composer-input", { value: "bluhbluh " }); await insertText(".o-mail-Composer-input", "/"); // weak test, no guarantee that we waited long enough for the potential list to open - await contains(".o-mail-Composer-suggestionList .o-open", 0); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); }); QUnit.test("Sort partner suggestions by recent chats", async (assert) => { @@ -112,11 +112,11 @@ QUnit.test("Sort partner suggestions by recent chats", async (assert) => { await click(".o-mail-DiscussSidebarChannel span", { text: "User 2" }); await insertText(".o-mail-Composer-input", "This is a test"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-content", 1, { text: "This is a test" }); + await contains(".o-mail-Message-content", { text: "This is a test" }); await click(".o-mail-DiscussSidebarChannel span", { text: "General" }); await insertText(".o-mail-Composer-input[placeholder='Message #General…']", "@"); await insertText(".o-mail-Composer-input", "User"); - await contains(".o-mail-Composer-suggestion strong", 3); + await contains(".o-mail-Composer-suggestion strong", { count: 3 }); assert.strictEqual($(".o-mail-Composer-suggestion").eq(0).text(), "User 2"); assert.strictEqual($(".o-mail-Composer-suggestion").eq(1).text(), "User 1"); assert.strictEqual($(".o-mail-Composer-suggestion").eq(2).text(), "User 3"); @@ -136,14 +136,14 @@ QUnit.test("mention suggestion are shown after deleting a character", async () = const { openDiscuss } = await start(); await openDiscuss(channelId); await insertText(".o-mail-Composer-input", "@John D"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "John Doe" }); + await contains(".o-mail-Composer-suggestion strong", { text: "John Doe" }); await insertText(".o-mail-Composer-input", "a"); - await contains(".o-mail-Composer-suggestion strong", 0, { text: "John D" }); + await contains(".o-mail-Composer-suggestion strong", { count: 0, text: "John D" }); // Simulate pressing backspace const textarea = document.querySelector(".o-mail-Composer-input"); textarea.value = textarea.value.slice(0, -1); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "John Doe" }); + await contains(".o-mail-Composer-suggestion strong", { text: "John Doe" }); }); QUnit.test("command suggestion are shown after deleting a character", async () => { @@ -160,12 +160,12 @@ QUnit.test("command suggestion are shown after deleting a character", async () = const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "/he"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "help" }); + await contains(".o-mail-Composer-suggestion strong", { text: "help" }); await insertText(".o-mail-Composer-input", "e"); - await contains(".o-mail-Composer-suggestion strong", 0, { text: "help" }); + await contains(".o-mail-Composer-suggestion strong", { count: 0, text: "help" }); // Simulate pressing backspace const textarea = document.querySelector(".o-mail-Composer-input"); textarea.value = textarea.value.slice(0, -1); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "help" }); + await contains(".o-mail-Composer-suggestion strong", { text: "help" }); }); diff --git a/addons/mail/static/tests/discuss/core/web/chat_window_new_message_tests.js b/addons/mail/static/tests/discuss/core/web/chat_window_new_message_tests.js index 0700029376d..e0978e42e3d 100644 --- a/addons/mail/static/tests/discuss/core/web/chat_window_new_message_tests.js +++ b/addons/mail/static/tests/discuss/core/web/chat_window_new_message_tests.js @@ -26,13 +26,13 @@ QUnit.test("basic rendering", async () => { await click("button", { text: "New Message" }); await contains(".o-mail-ChatWindow"); await contains(".o-mail-ChatWindow-header"); - await contains(".o-mail-ChatWindow-header .o-mail-ChatWindow-name", 1, { text: "New message" }); - await contains(".o-mail-ChatWindow-header .o-mail-ChatWindow-command", 2); + await contains(".o-mail-ChatWindow-header .o-mail-ChatWindow-name", { text: "New message" }); + await contains(".o-mail-ChatWindow-header .o-mail-ChatWindow-command", { count: 2 }); await contains(".o-mail-ChatWindow-header .o-mail-ChatWindow-command[title='Fold']"); await contains( ".o-mail-ChatWindow-header .o-mail-ChatWindow-command[title='Close Chat Window']" ); - await contains("span", 1, { text: "To :" }); + await contains("span", { text: "To :" }); await contains(".o-discuss-ChannelSelector"); }); @@ -48,7 +48,7 @@ QUnit.test("close", async () => { await click(".o_menu_systray i[aria-label='Messages']"); await click("button", { text: "New Message" }); await click(".o-mail-ChatWindow-command[title='Close Chat Window']"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); }); QUnit.test("fold", async () => { @@ -59,8 +59,8 @@ QUnit.test("fold", async () => { await contains(".o-discuss-ChannelSelector"); await click(".o-mail-ChatWindow-command[title='Fold']"); - await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", 0); - await contains(".o-mail-ChatWindow .o-discuss-ChannelSelector", 0); + await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content", { count: 0 }); + await contains(".o-mail-ChatWindow .o-discuss-ChannelSelector", { count: 0 }); await click(".o-mail-ChatWindow-command[title='Open']"); await contains(".o-mail-ChatWindow .o-mail-ChatWindow-content"); @@ -106,8 +106,8 @@ QUnit.test( // open "new message" chat window await click(".o_menu_systray i[aria-label='Messages']"); await click("button", { text: "New Message" }); - await contains(".o-mail-ChatWindow-name", 1, { text: "New message" }); - await contains(".o-mail-ChatWindow", 2); + await contains(".o-mail-ChatWindow-name", { text: "New message" }); + await contains(".o-mail-ChatWindow", { count: 2 }); await contains(".o-mail-ChatWindow .o-discuss-ChannelSelector"); assert.ok( Array.from(document.querySelectorAll(".o-mail-ChatWindow")) @@ -117,10 +117,8 @@ QUnit.test( // open channel-2 await click(".o_menu_systray i[aria-label='Messages']"); - await click(".o-mail-NotificationItem .o-mail-NotificationItem-name", { - text: "channel-2", - }); - await contains(".o-mail-ChatWindow", 3); + await click(".o-mail-NotificationItem-name", { text: "channel-2" }); + await contains(".o-mail-ChatWindow", { count: 3 }); assert.ok( Array.from(document.querySelectorAll(".o-mail-ChatWindow"))[1].textContent.includes( "New message" @@ -133,7 +131,7 @@ QUnit.test( await imSearchDef; }); await click(".o-discuss-ChannelSelector-suggestion a", { text: "Partner 131" }); - await contains(".o-mail-ChatWindow-name", 0, { text: "New message" }); + await contains(".o-mail-ChatWindow-name", { count: 0, text: "New message" }); assert.strictEqual($(".o-mail-ChatWindow-name:eq(1)").text(), "Partner 131"); } @@ -166,7 +164,7 @@ QUnit.test( await click("button", { text: "New Message" }); await insertText(".o-discuss-ChannelSelector", "131"); await click(".o-discuss-ChannelSelector-suggestion a"); - await contains(".o-mail-ChatWindow-name", 0, { text: "New message" }); + await contains(".o-mail-ChatWindow-name", { count: 0, text: "New message" }); await contains(".o-mail-ChatWindow"); } diff --git a/addons/mail/static/tests/discuss/core/web/command_palette_tests.js b/addons/mail/static/tests/discuss/core/web/command_palette_tests.js index a6871ae3ef1..40bd6b7609f 100644 --- a/addons/mail/static/tests/discuss/core/web/command_palette_tests.js +++ b/addons/mail/static/tests/discuss/core/web/command_palette_tests.js @@ -43,12 +43,12 @@ QUnit.test("open the chatWindow of a channel from the command palette", async () // Switch to channels await editSearchBar("#"); advanceTime(commandSetupRegistry.get("#").debounceDelay); - await contains(".o_command", 1, { text: "general" }); - await contains(".o_command", 1, { text: "project" }); + await contains(".o_command", { text: "general" }); + await contains(".o_command", { text: "project" }); await click(".o_command.focused"); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-ChatWindow-name", 1, { text: "general" }); + await contains(".o-mail-ChatWindow-name", { text: "general" }); }); QUnit.test("Channel mentions in the command palette of Discuss app with @", async () => { @@ -78,19 +78,19 @@ QUnit.test("Channel mentions in the command palette of Discuss app with @", asyn await nextTick(); await editSearchBar("@"); advanceTime(commandSetupRegistry.get("@").debounceDelay); - await contains(".o_command_palette span.fw-bold", 1, { text: "Mentions" }); + await contains(".o_command_palette span.fw-bold", { text: "Mentions" }); await contains( ".o_command_category:contains('Mentions') .o_command:contains('Mitchell Admin and Mario')" ); - await contains(".o_command_category:not(:contains('Mentions')) .o_command", 1, { + await contains(".o_command_category:not(:contains('Mentions')) .o_command", { text: "Mario", }); await contains( ".o_command_category:not(:contains('Mentions')) .o_command:contains('Mitchell Admin')" ); - await contains(".o_command.focused .o_command_name", 1, { text: "Mitchell Admin and Mario" }); + await contains(".o_command.focused .o_command_name", { text: "Mitchell Admin and Mario" }); await click(".o_command.focused"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Mitchell Admin and Mario" }); + await contains(".o-mail-ChatWindow-name", { text: "Mitchell Admin and Mario" }); }); QUnit.test("Max 3 most recent channels in command palette of Discuss app with #", async () => { @@ -104,6 +104,6 @@ QUnit.test("Max 3 most recent channels in command palette of Discuss app with #" await nextTick(); await editSearchBar("#"); advanceTime(commandSetupRegistry.get("#").debounceDelay); - await contains(".o_command_palette span.fw-bold", 1, { text: "Recent" }); - await contains(".o_command_category:contains('Recent') .o_command", 3); + await contains(".o_command_palette span.fw-bold", { text: "Recent" }); + await contains(".o_command_category:contains('Recent') .o_command", { count: 3 }); }); diff --git a/addons/mail/static/tests/discuss/core/web/crosstab_tests.js b/addons/mail/static/tests/discuss/core/web/crosstab_tests.js index 850f8504a77..b6722a658aa 100644 --- a/addons/mail/static/tests/discuss/core/web/crosstab_tests.js +++ b/addons/mail/static/tests/discuss/core/web/crosstab_tests.js @@ -19,7 +19,7 @@ QUnit.test("Channel subscription is renewed when channel is manually added", asy await click("[title='Add or join a channel']"); await insertText(".o-discuss-ChannelSelector", "General"); await click(".o-discuss-ChannelSelector-suggestion:eq(0)"); - await contains(".o-mail-DiscussSidebarChannel", 1); + await contains(".o-mail-DiscussSidebarChannel", { count: 1 }); await new Promise((resolve) => setTimeout(resolve)); // update of channels is debounced assert.verifySteps(["update-channels"]); }); diff --git a/addons/mail/static/tests/discuss/core/web/discuss_tests.js b/addons/mail/static/tests/discuss/core/web/discuss_tests.js index 96a57ac9cff..57919ee0712 100644 --- a/addons/mail/static/tests/discuss/core/web/discuss_tests.js +++ b/addons/mail/static/tests/discuss/core/web/discuss_tests.js @@ -24,11 +24,11 @@ QUnit.test("can create a new channel [REQUIRE FOCUS]", async (assert) => { }); openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Add or join a channel']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "abc"); await click(".o-discuss-ChannelSelector-suggestion"); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-Discuss-content .o-mail-Message", 0); + await contains(".o-mail-Discuss-content .o-mail-Message", { count: 0 }); assert.verifySteps([ "/mail/init_messaging", "/mail/load_message_failures", @@ -51,14 +51,14 @@ QUnit.test( await insertText(".o-discuss-ChannelSelector input", "mario"); await click(".o-discuss-ChannelSelector-suggestion"); await contains(".o-discuss-ChannelSelector span[title='Mario']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); triggerHotkey("Backspace"); - await contains(".o-discuss-ChannelSelector span[title='Mario']", 0); + await contains(".o-discuss-ChannelSelector span[title='Mario']", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "mario"); await contains(".o-discuss-ChannelSelector-suggestion"); triggerHotkey("Enter"); await contains(".o-discuss-ChannelSelector span[title='Mario']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); } ); @@ -82,13 +82,13 @@ QUnit.test("can join a chat conversation", async (assert) => { }); openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Start a conversation']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "mario"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); triggerHotkey("Enter"); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); assert.verifySteps([ "/mail/init_messaging", "/mail/load_message_failures", @@ -108,16 +108,16 @@ QUnit.test("can create a group chat conversation", async () => { const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Start a conversation']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "Mario"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "Luigi"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); triggerHotkey("Enter"); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test("should create DM chat when adding self and another user", async () => { @@ -127,15 +127,15 @@ QUnit.test("should create DM chat when adding self and another user", async () = const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Start a conversation']"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "Mi"); // Mitchell Admin await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); await insertText(".o-discuss-ChannelSelector input", "Mario"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); triggerHotkey("Enter"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Mario" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Mario" }); }); QUnit.test("chat search should display no result when no matches found", async () => { @@ -143,7 +143,7 @@ QUnit.test("chat search should display no result when no matches found", async ( openDiscuss(); await click(".o-mail-DiscussSidebar i[title='Start a conversation']"); await insertText(".o-discuss-ChannelSelector", "Rainbow Panda"); - await contains(".o-discuss-ChannelSelector-suggestion", 1, { text: "No results found" }); + await contains(".o-discuss-ChannelSelector-suggestion", { text: "No results found" }); }); QUnit.test("chat search should not be visible when clicking outside of the field", async () => { @@ -156,7 +156,7 @@ QUnit.test("chat search should not be visible when clicking outside of the field await insertText(".o-discuss-ChannelSelector", "Panda"); await contains(".o-discuss-ChannelSelector-suggestion"); await click(".o-mail-DiscussSidebar"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); }); QUnit.test("sidebar: add channel", async (assert) => { @@ -187,10 +187,10 @@ QUnit.test("Chat is added to discuss on other tab that the one that joined", asy await tab1.insertText(".o-discuss-ChannelSelector input", "Jer"); await click(".o-discuss-ChannelSelector-suggestion", { target: tab1.target }); triggerHotkey("Enter"); - await contains(".o-mail-DiscussSidebarChannel:contains(Jerry Golay)", 1, { + await contains(".o-mail-DiscussSidebarChannel:contains(Jerry Golay)", { target: tab1.target, }); - await contains(".o-mail-DiscussSidebarChannel:contains(Jerry Golay)", 1, { + await contains(".o-mail-DiscussSidebarChannel:contains(Jerry Golay)", { target: tab2.target, }); }); diff --git a/addons/mail/static/tests/discuss/core/web/messaging_menu_tests.js b/addons/mail/static/tests/discuss/core/web/messaging_menu_tests.js index f5e4e114635..f98bd8554b2 100644 --- a/addons/mail/static/tests/discuss/core/web/messaging_menu_tests.js +++ b/addons/mail/static/tests/discuss/core/web/messaging_menu_tests.js @@ -18,7 +18,7 @@ QUnit.test('"Start a conversation" item selection opens chat', async () => { await click("button", { text: "Start a conversation" }); await insertText("input[placeholder='Start a conversation']", "Gandalf"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); triggerHotkey("Enter"); await contains(".o-mail-ChatWindow-name[title='Gandalf']"); }); @@ -33,7 +33,7 @@ QUnit.test('"New channel" item selection opens channel (existing)', async () => await click("button", { text: "New Channel" }); await insertText("input[placeholder='Add or join a channel']", "Gryff"); await click(".o-discuss-ChannelSelector-suggestion:eq(0)"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); await contains(".o-mail-ChatWindow-name[title='Gryffindors']"); }); @@ -45,7 +45,7 @@ QUnit.test('"New channel" item selection opens channel (new)', async () => { await click("button", { text: "New Channel" }); await insertText("input[placeholder='Add or join a channel']", "slytherins"); await click(".o-discuss-ChannelSelector-suggestion"); - await contains(".o-discuss-ChannelSelector-suggestion", 0); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0 }); await contains(".o-mail-ChatWindow-name[title='slytherins']"); }); diff --git a/addons/mail/static/tests/discuss/core/web/sidebar_tests.js b/addons/mail/static/tests/discuss/core/web/sidebar_tests.js index cefa869f548..62598ad47aa 100644 --- a/addons/mail/static/tests/discuss/core/web/sidebar_tests.js +++ b/addons/mail/static/tests/discuss/core/web/sidebar_tests.js @@ -20,9 +20,9 @@ QUnit.test("sidebar find shows channels matching search term", async () => { // When searching for a single existing channel, the results list will have at least 2 lines: // One for the existing channel itself // One for creating a channel with the search term - await contains(".o-mail-NavigableList-item", 2); - await contains(".o-mail-NavigableList-item", 1, { text: "test" }); - await contains(".o-mail-NavigableList-item", 1, { text: "Create: # test" }); + await contains(".o-mail-NavigableList-item", { count: 2 }); + await contains(".o-mail-NavigableList-item", { text: "test" }); + await contains(".o-mail-NavigableList-item", { text: "Create: # test" }); }); QUnit.test( @@ -42,8 +42,8 @@ QUnit.test( // When searching for a single existing channel, the results list will have at least 2 lines: // One for the existing channel itself // One for creating a channel with the search term - await contains(".o-mail-NavigableList-item", 2); - await contains(".o-mail-NavigableList-item", 1, { text: "test" }); - await contains(".o-mail-NavigableList-item", 1, { text: "Create: # test" }); + await contains(".o-mail-NavigableList-item", { count: 2 }); + await contains(".o-mail-NavigableList-item", { text: "test" }); + await contains(".o-mail-NavigableList-item", { text: "Create: # test" }); } ); diff --git a/addons/mail/static/tests/discuss/message_pin/pinned_messages_tests.js b/addons/mail/static/tests/discuss/message_pin/pinned_messages_tests.js index 2572bf409f4..bbaee6cef94 100644 --- a/addons/mail/static/tests/discuss/message_pin/pinned_messages_tests.js +++ b/addons/mail/static/tests/discuss/message_pin/pinned_messages_tests.js @@ -23,7 +23,7 @@ QUnit.test("Pin message", async () => { await click(".o-mail-Message [title='Expand']"); await click(".dropdown-item", { text: "Pin" }); await click(".modal-footer button", { text: "Yeah, pin it!" }); - await contains(".o-discuss-PinnedMessagesPanel .o-mail-Message-content", 1, { + await contains(".o-discuss-PinnedMessagesPanel .o-mail-Message-content", { text: "Hello world!", }); }); @@ -44,7 +44,7 @@ QUnit.test("Unpin message", async () => { await click(".o-mail-Message [title='Expand']"); await click(".dropdown-item", { text: "Unpin" }); await click(".modal-footer button", { text: "Yes, remove it please" }); - await contains(".o-discuss-PinnedMessagesPanel .o-mail-Message", 0); + await contains(".o-discuss-PinnedMessagesPanel .o-mail-Message", { count: 0 }); }); QUnit.test("Deleted messages are not pinned", async () => { @@ -64,7 +64,7 @@ QUnit.test("Deleted messages are not pinned", async () => { await click(".o-mail-Message [title='Expand']"); await click(".dropdown-item", { text: "Delete" }); await click("button", { text: "Confirm" }); - await contains(".o-discuss-PinnedMessagesPanel .o-mail-Message", 0); + await contains(".o-discuss-PinnedMessagesPanel .o-mail-Message", { count: 0 }); }); QUnit.test("Open pinned panel from notification", async () => { @@ -80,7 +80,7 @@ QUnit.test("Open pinned panel from notification", async () => { await click(".o-mail-Message:eq(0) [title='Expand']"); await click(".dropdown-item", { text: "Pin" }); await click(".modal-footer button", { text: "Yeah, pin it!" }); - await contains(".o-discuss-PinnedMessagesPanel", 0); + await contains(".o-discuss-PinnedMessagesPanel", { count: 0 }); await click(".o_mail_notification a", { text: "See all pinned messages" }); await contains(".o-discuss-PinnedMessagesPanel"); }); diff --git a/addons/mail/static/tests/discuss/typing/typing_tests.js b/addons/mail/static/tests/discuss/typing/typing_tests.js index 303b941420f..28b9fdcebe6 100644 --- a/addons/mail/static/tests/discuss/typing/typing_tests.js +++ b/addons/mail/static/tests/discuss/typing/typing_tests.js @@ -21,7 +21,7 @@ QUnit.test('receive other member typing status "is typing"', async () => { const { env, openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); // simulate receive typing notification from demo pyEnv.withUser(userId, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -29,7 +29,7 @@ QUnit.test('receive other member typing status "is typing"', async () => { is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Demo is typing..." }); + await contains(".o-discuss-Typing", { text: "Demo is typing..." }); }); QUnit.test( @@ -48,7 +48,7 @@ QUnit.test( const { env, openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); // simulate receive typing notification from demo "is typing" pyEnv.withUser(userId, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -56,7 +56,7 @@ QUnit.test( is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Demo is typing..." }); + await contains(".o-discuss-Typing", { text: "Demo is typing..." }); // simulate receive typing notification from demo "is no longer typing" pyEnv.withUser(userId, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -65,7 +65,7 @@ QUnit.test( }) ); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); } ); @@ -85,7 +85,7 @@ QUnit.test( const { advanceTime, env, openDiscuss } = await start({ hasTimeControl: true }); await openDiscuss(channelId); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); // simulate receive typing notification from demo "is typing" pyEnv.withUser(userId, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -93,9 +93,9 @@ QUnit.test( is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Demo is typing..." }); + await contains(".o-discuss-Typing", { text: "Demo is typing..." }); advanceTime(OTHER_LONG_TYPING); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); } ); @@ -115,7 +115,7 @@ QUnit.test( const { advanceTime, env, openDiscuss } = await start({ hasTimeControl: true }); await openDiscuss(channelId); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); // simulate receive typing notification from demo "is typing" pyEnv.withUser(userId, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -123,7 +123,7 @@ QUnit.test( is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Demo is typing..." }); + await contains(".o-discuss-Typing", { text: "Demo is typing..." }); // simulate receive typing notification from demo "is typing" again after long time. await advanceTime(LONG_TYPING); await pyEnv.withUser(userId, () => @@ -133,9 +133,9 @@ QUnit.test( }) ); await advanceTime(LONG_TYPING); - await contains(".o-discuss-Typing", 1, { text: "Demo is typing..." }); + await contains(".o-discuss-Typing", { text: "Demo is typing..." }); advanceTime(OTHER_LONG_TYPING - LONG_TYPING); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); } ); @@ -163,7 +163,7 @@ QUnit.test('receive several other members typing status "is typing"', async () = const { env, openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); // simulate receive typing notification from other 10 (is typing) pyEnv.withUser(userId_1, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -171,7 +171,7 @@ QUnit.test('receive several other members typing status "is typing"', async () = is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Other 10 is typing..." }); + await contains(".o-discuss-Typing", { text: "Other 10 is typing..." }); // simulate receive typing notification from other 11 (is typing) pyEnv.withUser(userId_2, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -179,7 +179,7 @@ QUnit.test('receive several other members typing status "is typing"', async () = is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Other 10 and Other 11 are typing..." }); + await contains(".o-discuss-Typing", { text: "Other 10 and Other 11 are typing..." }); // simulate receive typing notification from other 12 (is typing) pyEnv.withUser(userId_3, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -187,7 +187,7 @@ QUnit.test('receive several other members typing status "is typing"', async () = is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Other 10, Other 11 and more are typing..." }); + await contains(".o-discuss-Typing", { text: "Other 10, Other 11 and more are typing..." }); // simulate receive typing notification from other 10 (no longer is typing) pyEnv.withUser(userId_1, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -195,7 +195,7 @@ QUnit.test('receive several other members typing status "is typing"', async () = is_typing: false, }) ); - await contains(".o-discuss-Typing", 1, { text: "Other 11 and Other 12 are typing..." }); + await contains(".o-discuss-Typing", { text: "Other 11 and Other 12 are typing..." }); // simulate receive typing notification from other 10 (is typing again) pyEnv.withUser(userId_1, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -203,7 +203,7 @@ QUnit.test('receive several other members typing status "is typing"', async () = is_typing: true, }) ); - await contains(".o-discuss-Typing", 1, { text: "Other 11, Other 12 and more are typing..." }); + await contains(".o-discuss-Typing", { text: "Other 11, Other 12 and more are typing..." }); }); QUnit.test("current partner notify is typing to other thread members", async (assert) => { @@ -289,7 +289,7 @@ QUnit.test( await insertText(".o-mail-Composer-input", "a"); assert.verifySteps(["notify_typing:true"]); await contains(".o-discuss-Typing"); - await contains(".o-discuss-Typing", 0, { text: "Demo is typing...)" }); + await contains(".o-discuss-Typing", { count: 0, text: "Demo is typing...)" }); } ); @@ -348,7 +348,7 @@ QUnit.test("chat: correspondent is typing in chat window", async () => { const { env } = await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains("[title='Demo is typing...']", 0); + await contains("[title='Demo is typing...']", { count: 0 }); // simulate receive typing notification from demo "is typing" pyEnv.withUser(userId, () => env.services.rpc("/discuss/channel/notify_typing", { @@ -364,5 +364,5 @@ QUnit.test("chat: correspondent is typing in chat window", async () => { is_typing: false, }) ); - await contains("[title='Demo is typing...']", 0); + await contains("[title='Demo is typing...']", { count: 0 }); }); diff --git a/addons/mail/static/tests/discuss/voice_message/voice_message_tests.js b/addons/mail/static/tests/discuss/voice_message/voice_message_tests.js index 1e7555c257a..88924752e3a 100644 --- a/addons/mail/static/tests/discuss/voice_message/voice_message_tests.js +++ b/addons/mail/static/tests/discuss/voice_message/voice_message_tests.js @@ -160,21 +160,21 @@ QUnit.test("make voice message in chat", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click("button[title='Voice Message']"); - await contains(".o-mail-VoiceRecorder", 1, { text: "00 : 00" }); + await contains(".o-mail-VoiceRecorder", { text: "00 : 00" }); await nextAnimationFrame(); // simulate 10 sec elapsed patchDate(2023, 6, 31, 13, 0, 11); // +1 so exactly 10 sec elapsed // simulate some microphone data audioProcessor.process([[new Float32Array(128)]]); - await contains(".o-mail-VoiceRecorder", 1, { text: "00 : 10" }); + await contains(".o-mail-VoiceRecorder", { text: "00 : 10" }); await click("button[title='Stop Recording']"); 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", 2); // 1 for global waveforms, 1 for played waveforms - await contains(".o-mail-VoicePlayer", 1, { text: "00 : 04" }); // duration of call_02_in_.mp3 + 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 await contains(".o-mail-VoiceRecorder button[title='Voice Message']:disabled"); cleanUp(); }); diff --git a/addons/mail/static/tests/discuss_app/discuss_tests.js b/addons/mail/static/tests/discuss_app/discuss_tests.js index 2c336207c94..d8f437bd9eb 100644 --- a/addons/mail/static/tests/discuss_app/discuss_tests.js +++ b/addons/mail/static/tests/discuss_app/discuss_tests.js @@ -31,7 +31,7 @@ QUnit.test("sanity check", async (assert) => { }); openDiscuss(); await contains(".o-mail-DiscussSidebar"); - await contains("h4", 1, { text: "Congratulations, your inbox is empty" }); + await contains("h4", { text: "Congratulations, your inbox is empty" }); assert.verifySteps([ "/mail/init_messaging", "/mail/load_message_failures", @@ -55,13 +55,13 @@ QUnit.test("can change the thread name of #general [REQUIRE FOCUS]", async (asse }); openDiscuss(channelId); await contains(".o-mail-Composer-input:focus"); - await contains("input.o-mail-Discuss-threadName", 1, { value: "general" }); + await contains("input.o-mail-Discuss-threadName", { value: "general" }); await insertText("input.o-mail-Discuss-threadName:not(:disabled)", "special", { replace: true, }); triggerHotkey("Enter"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "special" }); - await contains("input.o-mail-Discuss-threadName", 1, { value: "special" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "special" }); + await contains("input.o-mail-Discuss-threadName", { value: "special" }); assert.verifySteps(["/web/dataset/call_kw/discuss.channel/channel_rename"]); }); @@ -82,7 +82,7 @@ QUnit.test("can change the thread description of #general [REQUIRE FOCUS]", asyn }); openDiscuss(channelId); await contains(".o-mail-Composer-input:focus"); - await contains("input.o-mail-Discuss-threadDescription", 1, { + await contains("input.o-mail-Discuss-threadDescription", { value: "General announcements...", }); await insertText( @@ -91,7 +91,7 @@ QUnit.test("can change the thread description of #general [REQUIRE FOCUS]", asyn { replace: true } ); triggerHotkey("Enter"); - await contains("input.o-mail-Discuss-threadDescription", 1, { + await contains("input.o-mail-Discuss-threadDescription", { value: "I want a burger today!", }); assert.verifySteps(["/web/dataset/call_kw/discuss.channel/channel_change_description"]); @@ -140,7 +140,7 @@ QUnit.test("Posting message should transform relevant data to emoji.", async () openDiscuss(channelId); await insertText(".o-mail-Composer-input", "test :P :laughing:"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-body", 1, { text: "test 😛 😆" }); + await contains(".o-mail-Message-body", { text: "test 😛 😆" }); }); QUnit.test( @@ -156,10 +156,10 @@ QUnit.test( openDiscuss(channelId); await insertText(".o-mail-Composer-input", "abc"); await click(".o-mail-Composer button:contains(Send):not(:disabled)"); - await contains(".o-mail-Message", 1); + await contains(".o-mail-Message", { count: 1 }); await insertText(".o-mail-Composer-input", "def"); await click(".o-mail-Composer button:contains(Send):not(:disabled)"); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); await contains(".o-mail-Message-header"); // just 1, because 2nd message is squashed } ); @@ -179,7 +179,7 @@ QUnit.test("Click on avatar opens its partner chat window", async () => { await openFormView("res.partner", partnerId); await contains(".o-mail-Message-sidebar .o-mail-Message-avatarContainer img"); await click(".o-mail-Message-sidebar .o-mail-Message-avatarContainer img"); - await contains(".o-mail-ChatWindow-name", 1, { text: "testPartner" }); + await contains(".o-mail-ChatWindow-name", { text: "testPartner" }); }); QUnit.test("Can use channel command /who", async () => { @@ -192,7 +192,7 @@ QUnit.test("Can use channel command /who", async () => { openDiscuss(channelId); await insertText(".o-mail-Composer-input", "/who"); await click(".o-mail-Composer button:contains(Send):not(:disabled)"); - await contains(".o_mail_notification", 1, { text: "You are alone in this channel." }); + await contains(".o_mail_notification", { text: "You are alone in this channel." }); }); QUnit.test("sidebar: chat im_status rendering", async () => { @@ -227,7 +227,7 @@ QUnit.test("sidebar: chat im_status rendering", async () => { ]); const { openDiscuss } = await start({ hasTimeControl: true }); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel-threadIcon", 3); + await contains(".o-mail-DiscussSidebarChannel-threadIcon", { count: 3 }); await contains( ".o-mail-DiscussSidebarChannel:contains(Partner1) .o-mail-ThreadIcon div[title='Offline']" ); @@ -259,8 +259,8 @@ QUnit.test("No load more when fetch below fetch limit of 30", async (assert) => }, }); openDiscuss(channelId); - await contains(".o-mail-Message", 29); - await contains("button", 0, { text: "Load More" }); + await contains(".o-mail-Message", { count: 29 }); + await contains("button", { count: 0, text: "Load More" }); }); QUnit.test("show date separator above mesages of similar date", async (assert) => { @@ -283,7 +283,9 @@ QUnit.test("show date separator above mesages of similar date", async (assert) = await contains(".o-mail-Thread hr + span:contains(April 20, 2019) + hr") )[0].getBoundingClientRect().top; const topOfMessages = Math.min( - ...(await contains(".o-mail-Message", 29)).map((m) => m.getBoundingClientRect().top) + ...(await contains(".o-mail-Message", { count: 29 })).map( + (m) => m.getBoundingClientRect().top + ) ); console.log(topOfSeaparator, topOfMessages); assert.ok( @@ -304,7 +306,7 @@ QUnit.test("sidebar: chat custom name", async () => { }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Marc" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Marc" }); }); QUnit.test("reply to message from inbox (message linked to document) [REQUIRE FOCUS]", async () => { @@ -326,19 +328,19 @@ QUnit.test("reply to message from inbox (message linked to document) [REQUIRE FO const { openDiscuss, openFormView } = await start(); openDiscuss(); await contains(".o-mail-Message"); - await contains(".o-mail-Message-header small", 1, { text: "on Refactoring" }); + await contains(".o-mail-Message-header small", { text: "on Refactoring" }); await click("[title='Reply']"); await contains(".o-mail-Message.o-selected"); await contains(".o-mail-Composer"); - await contains(".o-mail-Composer-coreHeader span", 1, { text: "on: Refactoring" }); + await contains(".o-mail-Composer-coreHeader span", { text: "on: Refactoring" }); await insertText(".o-mail-Composer-input:focus", "Hello"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); await contains(".o-mail-Message:not(.o-selected)"); await contains('.o_notification.border-info:contains(Message posted on "Refactoring")'); openFormView("res.partner", partnerId); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Message-content", 1, { text: "Hello" }); + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Message-content", { text: "Hello" }); }); QUnit.test("Can reply to starred message", async () => { @@ -353,13 +355,13 @@ QUnit.test("Can reply to starred message", async () => { const { openDiscuss } = await start(); openDiscuss("mail.box_starred"); await click("[title='Reply']"); - await contains(".o-mail-Composer-coreHeader b", 1, { text: "RandomName" }); + await contains(".o-mail-Composer-coreHeader b", { text: "RandomName" }); await insertText(".o-mail-Composer-input", "abc"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Composer-send", 0); + await contains(".o-mail-Composer-send", { count: 0 }); await contains('.o_notification:contains(Message posted on "RandomName")'); await click(".o-mail-DiscussSidebarChannel span", { text: "RandomName" }); - await contains(".o-mail-Message-content", 1, { text: "abc" }); + await contains(".o-mail-Message-content", { text: "abc" }); }); QUnit.test("Can reply to history message", async () => { @@ -380,22 +382,22 @@ QUnit.test("Can reply to history message", async () => { const { openDiscuss } = await start(); openDiscuss("mail.box_history"); await click("[title='Reply']"); - await contains(".o-mail-Composer-coreHeader b", 1, { text: "RandomName" }); + await contains(".o-mail-Composer-coreHeader b", { text: "RandomName" }); await insertText(".o-mail-Composer-input", "abc"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Composer-send", 0); + await contains(".o-mail-Composer-send", { count: 0 }); await contains('.o_notification:contains(Message posted on "RandomName")'); await click(".o-mail-DiscussSidebarChannel span", { text: "RandomName" }); - await contains(".o-mail-Message-content", 1, { text: "abc" }); + await contains(".o-mail-Message-content", { text: "abc" }); }); QUnit.test("receive new needaction messages", async () => { const { openDiscuss, pyEnv } = await start(); openDiscuss(); - await contains("button div", 1, { text: "Inbox" }); + await contains("button div", { text: "Inbox" }); await contains("button:contains(Inbox).o-active"); - await contains("button:contains(Inbox) .badge", 0); - await contains(".o-mail-Thread .o-mail-Message", 0); + await contains("button:contains(Inbox) .badge", { count: 0 }); + await contains(".o-mail-Thread .o-mail-Message", { count: 0 }); // simulate receiving a new needaction message pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.message/inbox", { @@ -406,9 +408,9 @@ QUnit.test("receive new needaction messages", async () => { res_id: 20, }); await contains("button:contains(Inbox) .badge"); - await contains("button:contains(Inbox) .badge", 1, { text: "1" }); + await contains("button:contains(Inbox) .badge", { text: "1" }); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { text: "not empty 1" }); + await contains(".o-mail-Message-content", { text: "not empty 1" }); // simulate receiving another new needaction message pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.message/inbox", { @@ -418,10 +420,10 @@ QUnit.test("receive new needaction messages", async () => { model: "res.partner", res_id: 20, }); - await contains("button:contains(Inbox) .badge", 1, { text: "2" }); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Message-content", 1, { text: "not empty 1" }); - await contains(".o-mail-Message-content", 1, { text: "not empty 2" }); + await contains("button:contains(Inbox) .badge", { text: "2" }); + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Message-content", { text: "not empty 1" }); + await contains(".o-mail-Message-content", { text: "not empty 2" }); }); QUnit.test("basic rendering", async () => { @@ -435,12 +437,12 @@ QUnit.test("basic rendering", async () => { QUnit.test("basic rendering: sidebar", async () => { const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebar button div", 1, { text: "Inbox" }); - await contains(".o-mail-DiscussSidebar button div", 1, { text: "Starred" }); - await contains(".o-mail-DiscussSidebar button div", 1, { text: "History" }); - await contains(".o-mail-DiscussSidebarCategory", 2); - await contains(".o-mail-DiscussSidebarCategory-channel", 1, { text: "Channels" }); - await contains(".o-mail-DiscussSidebarCategory-chat", 1, { text: "Direct messages" }); + await contains(".o-mail-DiscussSidebar button div", { text: "Inbox" }); + await contains(".o-mail-DiscussSidebar button div", { text: "Starred" }); + await contains(".o-mail-DiscussSidebar button div", { text: "History" }); + await contains(".o-mail-DiscussSidebarCategory", { count: 2 }); + await contains(".o-mail-DiscussSidebarCategory-channel", { text: "Channels" }); + await contains(".o-mail-DiscussSidebarCategory-chat", { text: "Direct messages" }); }); QUnit.test("sidebar: Inbox should have icon", async () => { @@ -470,7 +472,7 @@ QUnit.test("sidebar: basic channel rendering", async () => { pyEnv["discuss.channel"].create({ name: "General" }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains(".o-mail-DiscussSidebarChannel img[data-alt='Thread Image']"); await contains(".o-mail-DiscussSidebarChannel .o-mail-DiscussSidebarChannel-commands.d-none"); await contains( @@ -487,7 +489,7 @@ QUnit.test("channel become active", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-DiscussSidebarChannel.o-active", 0); + await contains(".o-mail-DiscussSidebarChannel.o-active", { count: 0 }); await click(".o-mail-DiscussSidebarChannel"); await contains(".o-mail-DiscussSidebarChannel.o-active"); }); @@ -517,8 +519,8 @@ QUnit.test("sidebar: channel rendering with needaction counter", async () => { }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "general" }); - await contains(".o-mail-DiscussSidebarChannel:contains(general) .badge", 1, { text: "1" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "general" }); + await contains(".o-mail-DiscussSidebarChannel:contains(general) .badge", { text: "1" }); }); QUnit.test("sidebar: chat rendering with unread counter", async () => { @@ -531,10 +533,10 @@ QUnit.test("sidebar: chat rendering with unread counter", async () => { }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel .badge", 1, { text: "100" }); + await contains(".o-mail-DiscussSidebarChannel .badge", { text: "100" }); await contains( ".o-mail-DiscussSidebarChannel .o-mail-DiscussSidebarChannel-commands:contains(Unpin Conversation)", - 0 + { count: 0 } ); }); @@ -580,15 +582,15 @@ QUnit.test("basic top bar rendering", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains("button:contains(Mark all read):disabled"); - await contains(".o-mail-Discuss-threadName", 1, { value: "Inbox" }); + await contains(".o-mail-Discuss-threadName", { value: "Inbox" }); await click("button", { text: "Starred" }); await contains("button:contains(Unstar all):disabled"); - await contains(".o-mail-Discuss-threadName", 1, { value: "Starred" }); + await contains(".o-mail-Discuss-threadName", { value: "Starred" }); await click(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains(".o-mail-Discuss-header button[title='Add Users']"); - await contains(".o-mail-Discuss-threadName", 1, { value: "General" }); + await contains(".o-mail-Discuss-threadName", { value: "General" }); }); QUnit.test("rendering of inbox message", async () => { @@ -610,14 +612,14 @@ QUnit.test("rendering of inbox message", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-Message"); - await contains(".o-mail-Message-header small", 1, { text: "on Refactoring" }); - await contains(".o-mail-Message-actions i", 4); + await contains(".o-mail-Message-header small", { text: "on Refactoring" }); + await contains(".o-mail-Message-actions i", { count: 4 }); await contains("[title='Reply']"); await contains("[title='Mark as Todo']"); await contains("[title='Mark as Read']"); await contains("[title='Expand']"); await click("[title='Expand']"); - await contains(".o-mail-Message-actions i", 5); + await contains(".o-mail-Message-actions i", { count: 5 }); await contains("[title='Reply']"); await contains("[title='Mark as Todo']"); await contains("[title='Mark as Read']"); @@ -659,7 +661,7 @@ QUnit.test("Unfollow message", async function () { const { openDiscuss } = await start(); openDiscuss(); // 2 messages about "Thread followed" with unfollow button and 1 message about "Thread not followed" without it - await contains(".o-mail-Message", 3); + await contains(".o-mail-Message", { count: 3 }); for (const id of [0, 1]) { await contains( `.o-mail-Message:eq(${id}) .o-mail-Message-header:contains(on Thread followed)` @@ -667,23 +669,23 @@ QUnit.test("Unfollow message", async function () { await click(`.o-mail-Message:eq(${id}) [title='Expand']`); await contains(`.o-mail-Message:eq(${id}) [title='Unfollow']`); } - await contains(".o-mail-Message:eq(2) .o-mail-Message-header small", 1, { + await contains(".o-mail-Message:eq(2) .o-mail-Message-header small", { text: "on Thread not followed", }); await click(".o-mail-Message:eq(2) [title='Expand']"); await contains(".o-mail-Message:eq(2) .o-mail-Message-moreMenu"); - await contains(".o-mail-Message:eq(2) [title='Unfollow']", 0); + await contains(".o-mail-Message:eq(2) [title='Unfollow']", { count: 0 }); await click(".o-mail-Message:eq(0) [title='Expand']"); await click(".o-mail-Message:eq(0) [title='Unfollow']"); - await contains(".o-mail-Message", 2); // Unfollowing message 0 marks it as read -> Message removed - await contains(".o-mail-Message-header small", 1, { text: "on Thread followed" }); - await contains(".o-mail-Message-header small", 1, { text: "on Thread not followed" }); + await contains(".o-mail-Message", { count: 2 }); // Unfollowing message 0 marks it as read -> Message removed + await contains(".o-mail-Message-header small", { text: "on Thread followed" }); + await contains(".o-mail-Message-header small", { text: "on Thread not followed" }); for (const id of [0, 1]) { await click(`.o-mail-Message:eq(${id}) [title='Expand']`); await contains(`.o-mail-Message:eq(${id}) .o-mail-Message-moreMenu`); - await contains(`.o-mail-Message:eq(${id}) [title='Unfollow']`, 0); + await contains(`.o-mail-Message:eq(${id}) [title='Unfollow']`, { count: 0 }); } }); @@ -719,23 +721,23 @@ QUnit.test('messages marked as read move to "History" mailbox', async () => { const { openDiscuss } = await start(); openDiscuss("mail.box_history"); await contains("button:contains(History).o-active"); - await contains(".o-mail-Thread h4", 1, { text: "No history messages" }); + await contains(".o-mail-Thread h4", { text: "No history messages" }); await click("button div", { text: "Inbox" }); await contains("button:contains(Inbox).o-active"); - await contains(".o-mail-Thread h4", 0, { text: "Congratulations, your inbox is empty" }); + await contains(".o-mail-Thread h4", { count: 0, text: "Congratulations, your inbox is empty" }); - await contains(".o-mail-Thread .o-mail-Message", 2); + await contains(".o-mail-Thread .o-mail-Message", { count: 2 }); await click("button", { text: "Mark all read" }); await contains("button:contains(Inbox).o-active"); - await contains(".o-mail-Thread h4", 1, { text: "Congratulations, your inbox is empty" }); + await contains(".o-mail-Thread h4", { text: "Congratulations, your inbox is empty" }); await click("button div", { text: "History" }); await contains("button:contains(History).o-active"); - await contains(".o-mail-Thread h4", 0, { text: "No history messages" }); + await contains(".o-mail-Thread h4", { count: 0, text: "No history messages" }); - await contains(".o-mail-Thread .o-mail-Message", 2); + await contains(".o-mail-Thread .o-mail-Message", { count: 2 }); }); QUnit.test( @@ -769,20 +771,20 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_history"); await contains("button:contains(History).o-active"); - await contains(".o-mail-Thread h4", 1, { text: "No history messages" }); + await contains(".o-mail-Thread h4", { text: "No history messages" }); await click("button div", { text: "Inbox" }); await contains("button:contains(Inbox).o-active"); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); await click(".o-mail-Message:contains(not empty 1) [title='Mark as Read']"); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { text: "not empty 2" }); + await contains(".o-mail-Message-content", { text: "not empty 2" }); await click("button div", { text: "History" }); await contains("button:contains(History).o-active"); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { text: "not empty 1" }); + await contains(".o-mail-Message-content", { text: "not empty 1" }); } ); @@ -801,14 +803,14 @@ QUnit.test('all messages in "Inbox" in "History" after marked all as read', asyn } const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); await click("button", { text: "Mark all read" }); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); await click("button div", { text: "History" }); - await contains(".o-mail-Message", 30); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 30 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", 0); - await contains(".o-mail-Message", 40); + await contains(".o-mail-Message", { count: 40 }); }); QUnit.test("post a simple message", async (assert) => { @@ -827,23 +829,23 @@ QUnit.test("post a simple message", async (assert) => { }, }); openDiscuss(channelId); - await contains(".o-mail-Thread .o-mail-Thread-empty", 1, { + await contains(".o-mail-Thread .o-mail-Thread-empty", { text: "There are no messages in this conversation.", }); - await contains(".o-mail-Message", 0); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Message", { count: 0 }); + await contains(".o-mail-Composer-input", { value: "" }); // insert some HTML in editable await insertText(".o-mail-Composer-input", "Test"); - await contains(".o-mail-Composer-input", 1, { value: "Test" }); + await contains(".o-mail-Composer-input", { value: "Test" }); await click(".o-mail-Composer-send:not(:disabled)"); await contains(".o-mail-Message"); assert.verifySteps(["message_post"]); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-input", { value: "" }); pyEnv["mail.message"].search([], { order: "id DESC" }); const $message = $(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { text: "Test" }); + await contains(".o-mail-Message-content", { text: "Test" }); assert.strictEqual($message.find(".o-mail-Message-author").text(), "Mitchell Admin"); assert.strictEqual($message.find(".o-mail-Message-body").text(), "Test"); }); @@ -856,11 +858,11 @@ QUnit.test("starred: unstar all", async (assert) => { ]); const { openDiscuss } = await start(); openDiscuss("mail.box_starred"); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); assert.strictEqual($("button:contains(Starred) .badge").text(), "2"); await click("button:contains(Unstar all):not(:disabled)"); - await contains("button:contains(Starred) .badge", 0); - await contains(".o-mail-Message", 0); + await contains("button:contains(Starred) .badge", { count: 0 }); + await contains(".o-mail-Message", { count: 0 }); await contains("button:contains(Unstar all):disabled"); }); @@ -879,13 +881,13 @@ QUnit.test("auto-focus composer on opening thread", async (assert) => { ]); const { openDiscuss } = await start(); openDiscuss(); - await contains("button div", 1, { text: "Inbox" }); + await contains("button div", { text: "Inbox" }); await contains("button:contains(Inbox).o-active"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); assert.doesNotHaveClass($(".o-mail-DiscussSidebarChannel:contains(General)"), "o-active"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Demo User" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Demo User" }); assert.doesNotHaveClass($(".o-mail-DiscussSidebarChannel:contains(Demo User)"), "o-active"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); await click(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains(".o-mail-DiscussSidebarChannel:contains(General).o-active"); @@ -1065,7 +1067,7 @@ QUnit.test("should auto-pin chat when receiving a new DM", async () => { const { env, openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-chat"); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "Demo" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "Demo" }); // simulate receiving the first message on channel 11 pyEnv.withUser(userId, () => @@ -1075,7 +1077,7 @@ QUnit.test("should auto-pin chat when receiving a new DM", async () => { thread_model: "discuss.channel", }) ); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Demo" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Demo" }); }); QUnit.test("'Add Users' button should be displayed in the topbar of channels", async () => { @@ -1122,8 +1124,8 @@ QUnit.test("'Add Users' button should be displayed in the topbar of groups", asy QUnit.test("'Add Users' button should not be displayed in the topbar of mailboxes", async () => { const { openDiscuss } = await start(); openDiscuss("mail.box_starred"); - await contains("button", 1, { text: "Unstar all" }); - await contains("button[title='Add Users']", 0); + await contains("button", { text: "Unstar all" }); + await contains("button[title='Add Users']", { count: 0 }); }); QUnit.test( @@ -1280,15 +1282,15 @@ QUnit.test("Channel is added to discuss after invitation", async () => { const { env, openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-channel"); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "General" }); pyEnv.withUser(userId, () => env.services.orm.call("discuss.channel", "add_members", [[channelId]], { partner_ids: [pyEnv.adminPartnerId], }) ); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); - await contains(".o_notification.border-info .o_notification_content", 1, { + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); + await contains(".o_notification.border-info .o_notification_content", { text: "You have been invited to #General", }); }); @@ -1298,20 +1300,20 @@ QUnit.test("select another mailbox", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-Discuss"); - await contains(".o-mail-Discuss-threadName", 1, { value: "Inbox" }); + await contains(".o-mail-Discuss-threadName", { value: "Inbox" }); await click("button", { text: "Starred" }); await contains("button:contains(Unstar all):disabled"); - await contains(".o-mail-Discuss-threadName", 1, { value: "Starred" }); + await contains(".o-mail-Discuss-threadName", { value: "Starred" }); }); QUnit.test('auto-select "Inbox nav bar" when discuss had inbox as active thread', async () => { patchUiSize({ height: 360, width: 640 }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-Discuss-threadName", 1, { value: "Inbox" }); + await contains(".o-mail-Discuss-threadName", { value: "Inbox" }); await contains(".o-mail-MessagingMenu-navbar:contains(Mailboxes) .fw-bolder"); await contains("button:contains(Inbox).o-active"); - await contains("h4", 1, { text: "Congratulations, your inbox is empty" }); + await contains("h4", { text: "Congratulations, your inbox is empty" }); }); QUnit.test( @@ -1374,7 +1376,7 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss(channelId_2); await click("button", { text: "Bla" }); - await contains(".o-unread", 0); + await contains(".o-unread", { count: 0 }); } ); @@ -1443,9 +1445,9 @@ QUnit.test("new messages separator [REQUIRE FOCUS]", async () => { pyEnv["discuss.channel.member"].write([memberId], { seen_message_id: lastMessageId }); const { env, openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 25); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); - await contains(".o-mail-Discuss-content .o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 25 }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); + await contains(".o-mail-Discuss-content .o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Discuss-content .o-mail-Thread", 0); // composer is focused by default, we remove that focus $(".o-mail-Composer-input")[0].blur(); @@ -1457,12 +1459,12 @@ QUnit.test("new messages separator [REQUIRE FOCUS]", async () => { thread_model: "discuss.channel", }) ); - await contains(".o-mail-Message", 26); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Message", { count: 26 }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); await scroll(".o-mail-Discuss-content .o-mail-Thread", "bottom"); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); $(".o-mail-Composer-input")[0].focus(); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); }); QUnit.test("failure on loading messages should display error", async () => { @@ -1479,7 +1481,7 @@ QUnit.test("failure on loading messages should display error", async () => { }, }); openDiscuss(channelId, { waitUntilMessagesLoaded: false }); - await contains(".o-mail-Thread-error", 1, { + await contains(".o-mail-Thread-error", { text: "An error occurred while fetching messages.", }); }); @@ -1498,7 +1500,7 @@ QUnit.test("failure on loading messages should prompt retry button", async () => }, }); openDiscuss(channelId, { waitUntilMessagesLoaded: false }); - await contains("button", 1, { text: "Click here to retry" }); + await contains("button", { text: "Click here to retry" }); }); QUnit.test( @@ -1530,14 +1532,14 @@ QUnit.test( }, }); openDiscuss(channelId); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); messageFetchShouldFail = true; await click("button", { text: "Load More" }); - await contains(".o-mail-Thread-error", 1, { + await contains(".o-mail-Thread-error", { text: "An error occurred while fetching messages.", }); - await contains("button", 1, { text: "Click here to retry" }); - await contains("button", 0, { text: "Load More" }); + await contains("button", { text: "Click here to retry" }); + await contains("button", { count: 0, text: "Load More" }); } ); @@ -1572,12 +1574,12 @@ QUnit.test( }, }); openDiscuss(channelId); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); messageFetchShouldFail = true; await click("button", { text: "Load More" }); messageFetchShouldFail = false; await click("button", { text: "Click here to retry" }); - await contains(".o-mail-Message", 60); + await contains(".o-mail-Message", { count: 60 }); } ); @@ -1629,17 +1631,17 @@ QUnit.test("composer state: attachments save and restore", async () => { ".o-mail-Composer:has(textarea[placeholder='Message #Special…']) input[type=file]", files ); - await contains(".o-mail-Composer .o-mail-AttachmentCard:not(.o-isUploading)", 3); + await contains(".o-mail-Composer .o-mail-AttachmentCard:not(.o-isUploading)", { count: 3 }); // Switch back to #general await click("button", { text: "General" }); await contains(".o-mail-Composer .o-mail-AttachmentCard"); - await contains(".o-mail-AttachmentCard div", 1, { text: "text.txt" }); + await contains(".o-mail-AttachmentCard div", { text: "text.txt" }); // Switch back to #special await click("button", { text: "Special" }); - await contains(".o-mail-Composer .o-mail-AttachmentCard", 3); - await contains(".o-mail-AttachmentCard div", 1, { text: "text2.txt" }); - await contains(".o-mail-AttachmentCard div", 1, { text: "text3.txt" }); - await contains(".o-mail-AttachmentCard div", 1, { text: "text4.txt" }); + await contains(".o-mail-Composer .o-mail-AttachmentCard", { count: 3 }); + await contains(".o-mail-AttachmentCard div", { text: "text2.txt" }); + await contains(".o-mail-AttachmentCard div", { text: "text3.txt" }); + await contains(".o-mail-AttachmentCard div", { text: "text4.txt" }); }); QUnit.test( @@ -1655,8 +1657,8 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains("button", 1, { text: "General" }); - await contains("div[title='Leave this channel']", 0); + await contains("button", { text: "General" }); + await contains("div[title='Leave this channel']", { count: 0 }); } ); @@ -1682,18 +1684,18 @@ QUnit.test("restore thread scroll position", async () => { } const { openDiscuss } = await start(); openDiscuss(channelId_1); - await contains(".o-mail-Message", 25); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 25 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", 0); await click("button", { text: "Channel2" }); - await contains(".o-mail-Message", 24); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 24 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await click("button", { text: "Channel1" }); - await contains(".o-mail-Message", 25); - await contains(".o-mail-Thread", 1, { scroll: 0 }); + await contains(".o-mail-Message", { count: 25 }); + await contains(".o-mail-Thread", { scroll: 0 }); await click("button", { text: "Channel2" }); - await contains(".o-mail-Message", 24); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 24 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); }); QUnit.test("Message shows up even if channel data is incomplete", async () => { @@ -1739,7 +1741,7 @@ QUnit.test("Message shows up even if channel data is incomplete", async () => { await click( ".o-mail-DiscussSidebarCategory-chat + .o-mail-DiscussSidebarChannel:contains(Albert)" ); - await contains(".o-mail-Message-content", 1, { text: "hello world" }); + await contains(".o-mail-Message-content", { text: "hello world" }); }); QUnit.test("Correct breadcrumb when open discuss from chat window then see settings", async () => { @@ -1751,7 +1753,7 @@ QUnit.test("Correct breadcrumb when open discuss from chat window then see setti await click("[title='Open Actions Menu']"); await click("[title='Open in Discuss']"); await click(".o-mail-DiscussSidebarChannel:contains(General) [title='Channel settings']"); - await contains(".o_breadcrumb", 1, { text: "DiscussGeneral" }); + await contains(".o_breadcrumb", { text: "DiscussGeneral" }); }); QUnit.test( @@ -1777,9 +1779,9 @@ QUnit.test( openDiscuss(); await click(".o_main_navbar i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Discuss", 0); + await contains(".o-mail-Discuss", { count: 0 }); await contains(".o_form_view .o-mail-Chatter"); - await contains(".o_form_view .o_last_breadcrumb_item", 1, { text: "TestPartner" }); + await contains(".o_form_view .o_last_breadcrumb_item", { text: "TestPartner" }); await contains( ".o-mail-Chatter .o-mail-Message:contains(A needaction message to have it in messaging menu)" ); @@ -1816,15 +1818,15 @@ QUnit.test( openDiscuss(); await click(".o-mail-DiscussSidebarCategory-add[title='Start a conversation']"); await insertText(".o-discuss-ChannelSelector input", "m"); - await contains(".o-mail-NavigableList-item", 1, { text: "Loading" }); + await contains(".o-mail-NavigableList-item", { text: "Loading" }); await insertText(".o-discuss-ChannelSelector input", "a"); await insertText(".o-discuss-ChannelSelector input", "r"); deferred1.resolve(); await Promise.resolve(); assert.verifySteps(["First RPC"]); deferred2.resolve(); - await contains(".o-discuss-ChannelSelector-suggestion", 1, { text: "Mario" }); - await contains(".o-discuss-ChannelSelector-suggestion", 0, { text: "Mama" }); + await contains(".o-discuss-ChannelSelector-suggestion", { text: "Mario" }); + await contains(".o-discuss-ChannelSelector-suggestion", { count: 0, text: "Mama" }); assert.verifySteps(["Second RPC"]); } diff --git a/addons/mail/static/tests/discuss_app/inbox_tests.js b/addons/mail/static/tests/discuss_app/inbox_tests.js index 48aaffd9975..c28f7d55482 100644 --- a/addons/mail/static/tests/discuss_app/inbox_tests.js +++ b/addons/mail/static/tests/discuss_app/inbox_tests.js @@ -41,7 +41,7 @@ QUnit.test("reply: discard on reply button toggle", async (assert) => { await click("[title='Reply']"); await contains(".o-mail-Composer"); await click("[title='Reply']"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); }); QUnit.test("reply: discard on pressing escape", async () => { @@ -74,19 +74,19 @@ QUnit.test("reply: discard on pressing escape", async () => { await click(".o-mail-Composer button[aria-label='Emojis']"); await contains(".o-EmojiPicker"); triggerHotkey("Escape"); - await contains(".o-EmojiPicker", 0); + await contains(".o-EmojiPicker", { count: 0 }); await contains(".o-mail-Composer"); // Escape on suggestion prompt does not stop replying await insertText(".o-mail-Composer-input", "@"); await contains(".o-mail-Composer-suggestionList .o-open"); triggerHotkey("Escape"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); await contains(".o-mail-Composer"); click(".o-mail-Composer-input").catch(() => {}); triggerHotkey("Escape"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); }); QUnit.test( @@ -123,7 +123,7 @@ QUnit.test( await contains(".o-mail-Composer [placeholder='Log an internal note…']"); await insertText(".o-mail-Composer-input", "Test"); await click(".o-mail-Composer-send:not(:disabled)", { text: "Log" }); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); assert.verifySteps(["/mail/message/post"]); } ); @@ -162,7 +162,7 @@ QUnit.test( await contains(".o-mail-Composer [placeholder='Send a message to followers…']"); await insertText(".o-mail-Composer-input", "Test"); await click(".o-mail-Composer-send:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Composer-send", 0); + await contains(".o-mail-Composer-send", { count: 0 }); assert.verifySteps(["/mail/message/post"]); } ); @@ -185,7 +185,7 @@ QUnit.test("show subject of message in Inbox", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { + await contains(".o-mail-Message-content", { text: "Subject: Salutations, voyageurnot empty", }); }); @@ -208,7 +208,7 @@ QUnit.test("show subject of message in history", async () => { const { openDiscuss } = await start(); openDiscuss("mail.box_history"); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { + await contains(".o-mail-Message-content", { text: "Subject: Salutations, voyageurnot empty", }); }); @@ -232,7 +232,8 @@ QUnit.test("subject should not be shown when subject is the same as the thread n const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); }); @@ -258,7 +259,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); } @@ -285,7 +287,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); } @@ -312,7 +315,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); } @@ -339,7 +343,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); } @@ -366,7 +371,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); } @@ -393,7 +399,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss("mail.box_inbox"); await contains(".o-mail-Message-content"); - await contains(".o-mail-Message-content", 0, { + await contains(".o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); } @@ -430,15 +437,15 @@ QUnit.test("inbox: mark all messages as read", async (assert) => { ]); const { openDiscuss } = await start(); openDiscuss(); - await contains("button:contains(Inbox) .badge", 1, { text: "2" }); - await contains(".o-mail-DiscussSidebarChannel:contains(General) .badge", 1, { text: "2" }); - await contains(".o-mail-Discuss-content .o-mail-Message", 2); + await contains("button:contains(Inbox) .badge", { text: "2" }); + await contains(".o-mail-DiscussSidebarChannel:contains(General) .badge", { text: "2" }); + await contains(".o-mail-Discuss-content .o-mail-Message", { count: 2 }); assert.notOk($("button:contains(Mark all read)")[0].disabled); await click(".o-mail-Discuss-header button", { text: "Mark all read" }); - await contains("button:contains(Inbox) .badge", 0); - await contains(".o-mail-DiscussSidebarChannel:contains(General) .badge", 0); - await contains(".o-mail-Message", 0); + await contains("button:contains(Inbox) .badge", { count: 0 }); + await contains(".o-mail-DiscussSidebarChannel:contains(General) .badge", { count: 0 }); + await contains(".o-mail-Message", { count: 0 }); assert.ok($("button:contains(Mark all read)")[0].disabled); }); @@ -526,15 +533,15 @@ QUnit.test("inbox messages are never squashed", async () => { ]); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Message:not(.o-squashed) .o-mail-Message-content", 1, { + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Message:not(.o-squashed) .o-mail-Message-content", { text: "body1", }); - await contains(".o-mail-Message:not(.o-squashed) .o-mail-Message-content", 1, { + await contains(".o-mail-Message:not(.o-squashed) .o-mail-Message-content", { text: "body2", }); await click(".o-mail-DiscussSidebarChannel span", { text: "test" }); - await contains(".o-mail-Message.o-squashed .o-mail-Message-content", 1, { text: "body2" }); + await contains(".o-mail-Message.o-squashed .o-mail-Message-content", { text: "body2" }); }); QUnit.test("reply: stop replying button click", async () => { @@ -562,7 +569,7 @@ QUnit.test("reply: stop replying button click", async () => { await contains("i[title='Stop replying']"); await click("i[title='Stop replying']"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); }); QUnit.test("error notifications should not be shown in Inbox", async () => { @@ -584,11 +591,11 @@ QUnit.test("error notifications should not be shown in Inbox", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-Message"); - await contains(".o-mail-Message-header small", 1, { text: "on Demo User" }); + await contains(".o-mail-Message-header small", { text: "on Demo User" }); await contains( `.o-mail-Message-header a:contains(Demo User)[href*='/web#model=res.partner&id=${partnerId}']` ); - await contains(".o-mail-Message-notification", 0); + await contains(".o-mail-Message-notification", { count: 0 }); }); QUnit.test("emptying inbox displays rainbow man in inbox", async () => { @@ -635,12 +642,12 @@ QUnit.test("emptying inbox doesn't display rainbow man in another thread", async ]); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains("button:contains(Inbox) .badge", 1, { text: "1" }); + await contains("button:contains(Inbox) .badge", { text: "1" }); pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.message/mark_as_read", { message_ids: [messageId], needaction_inbox_counter: 0, }); await afterNextRender(() => mockTimeout().execRegisteredTimeouts); - await contains("button:contains(Inbox) .badge", 0); - await contains(".o_reward_rainbow", 0); + await contains("button:contains(Inbox) .badge", { count: 0 }); + await contains(".o_reward_rainbow", { count: 0 }); }); diff --git a/addons/mail/static/tests/discuss_app/jump_to_present_tests.js b/addons/mail/static/tests/discuss_app/jump_to_present_tests.js index cb7ebe215b5..d71f93ff362 100644 --- a/addons/mail/static/tests/discuss_app/jump_to_present_tests.js +++ b/addons/mail/static/tests/discuss_app/jump_to_present_tests.js @@ -26,21 +26,22 @@ QUnit.test("Basic jump to present when scrolling to outdated messages", async (a } const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 20); + await contains(".o-mail-Message", { count: 20 }); assert.ok( (await contains(".o-mail-Thread"))[0].scrollHeight > PRESENT_THRESHOLD, "should have enough scroll height to trigger jump to present" ); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", 0); - await contains(".o-mail-Thread-jumpPresent", 1, { + await contains(".o-mail-Thread-jumpPresent", { text: "You're viewing older messagesJump to Present", }); await click(".o-mail-Thread-jumpPresent"); - await contains(".o-mail-Thread-jumpPresent", 0, { + await contains(".o-mail-Thread-jumpPresent", { + count: 0, text: "You're viewing older messagesJump to Present", }); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Thread", { scroll: "bottom" }); }); QUnit.test("Jump to old reply should prompt jump to presence", async (assert) => { @@ -80,23 +81,24 @@ QUnit.test("Jump to old reply should prompt jump to presence", async (assert) => }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); await click(".o-mail-MessageInReply .cursor-pointer"); - await contains(".o-mail-Message", 46); + await contains(".o-mail-Message", { count: 46 }); assert.isVisible((await contains(".o-mail-Message:contains(Hello world!):eq(0)"))[0]); assert.strictEqual( $(".o-mail-Message-body:contains(Hello world!):eq(0)").text(), "Hello world!", "should correctly execute HTML tags in parent message when using 'load around' feature" ); - await contains(".o-mail-Thread-jumpPresent", 1, { + await contains(".o-mail-Thread-jumpPresent", { text: "You're viewing older messagesJump to Present", }); await click(".o-mail-Thread-jumpPresent"); - await contains(".o-mail-Thread-jumpPresent", 0, { + await contains(".o-mail-Thread-jumpPresent", { + count: 0, text: "You're viewing older messagesJump to Present", }); - await contains(".o-mail-Message", 30); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 30 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); }); diff --git a/addons/mail/static/tests/discuss_app/sidebar_tests.js b/addons/mail/static/tests/discuss_app/sidebar_tests.js index 6db6bafb38e..63c86ab0be8 100644 --- a/addons/mail/static/tests/discuss_app/sidebar_tests.js +++ b/addons/mail/static/tests/discuss_app/sidebar_tests.js @@ -23,11 +23,11 @@ QUnit.test("toggling category button hide category items", async () => { }); const { openDiscuss } = await start(); openDiscuss(); - await contains("button.o-active", 1, { text: "Inbox" }); + await contains("button.o-active", { text: "Inbox" }); await contains(".o-mail-DiscussSidebarChannel"); await click(".o-mail-DiscussSidebarCategory-icon:eq(0)"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); }); QUnit.test("toggling category button does not hide active category items", async () => { @@ -38,7 +38,7 @@ QUnit.test("toggling category button does not hide active category items", async ]); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-DiscussSidebarChannel", 2); + await contains(".o-mail-DiscussSidebarChannel", { count: 2 }); await contains(".o-mail-DiscussSidebarChannel.o-active"); await click(".o-mail-DiscussSidebarCategory-icon:eq(0)"); @@ -117,8 +117,8 @@ QUnit.test("channel - command: should not have add command when category is fold }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Channels" }); - await contains("i[title='Add or join a channel']", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Channels" }); + await contains("i[title='Add or join a channel']", { count: 0 }); }); QUnit.test("channel - states: close manually by clicking the title", async () => { @@ -130,9 +130,9 @@ QUnit.test("channel - states: close manually by clicking the title", async () => }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "general" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "general" }); await click(".o-mail-DiscussSidebarCategory-channel span", { text: "Channels" }); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "general" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "general" }); }); QUnit.test("channel - states: open manually by clicking the title", async () => { @@ -144,11 +144,11 @@ QUnit.test("channel - states: open manually by clicking the title", async () => }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory-channel span", 1, { text: "Channels" }); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "general" }); + await contains(".o-mail-DiscussSidebarCategory-channel span", { text: "Channels" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "general" }); await click(".o-mail-DiscussSidebarCategory-channel span", { text: "Channels" }); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "general" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "general" }); }); QUnit.test("sidebar: inbox with counter", async () => { @@ -159,7 +159,7 @@ QUnit.test("sidebar: inbox with counter", async () => { }); const { openDiscuss } = await start(); openDiscuss(); - await contains("button:contains(Inbox) .badge", 1, { text: "1" }); + await contains("button:contains(Inbox) .badge", { text: "1" }); }); QUnit.test("default thread rendering", async () => { @@ -167,10 +167,10 @@ QUnit.test("default thread rendering", async () => { pyEnv["discuss.channel"].create({ name: "General" }); const { openDiscuss } = await start(); openDiscuss(); - await contains("button div", 1, { text: "Inbox" }); - await contains("button div", 1, { text: "Starred" }); - await contains("button div", 1, { text: "History" }); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); + await contains("button div", { text: "Inbox" }); + await contains("button div", { text: "Starred" }); + await contains("button div", { text: "History" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains("button:contains(Inbox).o-active"); await contains( ".o-mail-Thread:contains(Congratulations, your inbox is empty New messages appear here.)" @@ -190,7 +190,7 @@ QUnit.test("default thread rendering", async () => { await click(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains(".o-mail-DiscussSidebarChannel:contains(General).o-active"); - await contains(".o-mail-Thread .o-mail-Thread-empty", 1, { + await contains(".o-mail-Thread .o-mail-Thread-empty", { text: "There are no messages in this conversation.", }); }); @@ -202,22 +202,22 @@ QUnit.test("sidebar quick search at 20 or more pinned channels", async () => { } const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 20); + await contains(".o-mail-DiscussSidebarChannel span", { count: 20 }); await contains(".o-mail-DiscussSidebar input[placeholder='Quick search...']"); await insertText(".o-mail-DiscussSidebar input[placeholder='Quick search...']", "1"); - await contains(".o-mail-DiscussSidebarChannel span", 11); + await contains(".o-mail-DiscussSidebarChannel span", { count: 11 }); await insertText(".o-mail-DiscussSidebar input[placeholder='Quick search...']", "12", { replace: true, }); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "channel12" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "channel12" }); await insertText(".o-mail-DiscussSidebar input[placeholder='Quick search...']", "123", { replace: true, }); - await contains(".o-mail-DiscussSidebarChannel span", 0); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0 }); }); QUnit.test("sidebar: basic chat rendering", async () => { @@ -233,12 +233,12 @@ QUnit.test("sidebar: basic chat rendering", async () => { const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarChannel"); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Demo" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Demo" }); await contains(".o-mail-DiscussSidebarChannel img[data-alt='Thread Image']"); await contains( ".o-mail-DiscussSidebarChannel .o-mail-DiscussSidebarChannel-commands div[title='Unpin Conversation']" ); - await contains(".o-mail-DiscussSidebarChannel .badge", 0); + await contains(".o-mail-DiscussSidebarChannel .badge", { count: 0 }); }); QUnit.test("sidebar: show pinned channel", async () => { @@ -246,7 +246,7 @@ QUnit.test("sidebar: show pinned channel", async () => { pyEnv["discuss.channel"].create({ name: "General" }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); }); QUnit.test("sidebar: open pinned channel", async () => { @@ -256,7 +256,7 @@ QUnit.test("sidebar: open pinned channel", async () => { openDiscuss(); await click(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains(".o-mail-Composer-input[placeholder='Message #General…']"); - await contains(".o-mail-Discuss-threadName", 1, { value: "General" }); + await contains(".o-mail-Discuss-threadName", { value: "General" }); }); QUnit.test("sidebar: open channel and leave it", async (assert) => { @@ -285,9 +285,9 @@ QUnit.test("sidebar: open channel and leave it", async (assert) => { await click(".o-mail-DiscussSidebarChannel:contains(General) .btn[title='Leave this channel']"); assert.verifySteps(["action_unfollow"]); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "General" }); - await contains(".o-mail-Discuss-threadName", 0, { value: "General" }); + await contains(".o-mail-Discuss-threadName", { count: 0, value: "General" }); }); QUnit.test("sidebar: unpin channel from bus", async () => { @@ -295,18 +295,18 @@ QUnit.test("sidebar: unpin channel from bus", async () => { const channelId = pyEnv["discuss.channel"].create({ name: "General" }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); await click(".o-mail-DiscussSidebarChannel span", { text: "General" }); await contains(".o-mail-Composer-input[placeholder='Message #General…']"); - await contains(".o-mail-Discuss-threadName", 1, { value: "General" }); + await contains(".o-mail-Discuss-threadName", { value: "General" }); // Simulate receiving a leave channel notification // (e.g. from user interaction from another device or browser tab) pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "discuss.channel/unpin", { id: channelId }); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "General" }); - await contains(".o-mail-Discuss-threadName", 0, { value: "General" }); + await contains(".o-mail-Discuss-threadName", { count: 0, value: "General" }); }); QUnit.test("chat - channel should count unread message [REQUIRE FOCUS]", async (assert) => { @@ -334,7 +334,7 @@ QUnit.test("chat - channel should count unread message [REQUIRE FOCUS]", async ( assert.strictEqual($(".o-discuss-badge").text(), "1"); await click(".o-mail-DiscussSidebarChannel span", { text: "Demo" }); - await contains(".o-discuss-badge", 0); + await contains(".o-discuss-badge", { count: 0 }); }); QUnit.test("mark channel as seen on last message visible [REQUIRE FOCUS]", async () => { @@ -367,8 +367,8 @@ QUnit.test( pyEnv["discuss.channel"].create({ name: "general" }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Channels" }); - await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Channels" }); + await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", { count: 0 }); } ); @@ -410,8 +410,8 @@ QUnit.test( ]); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Channels" }); - await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Channels" }); + await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", { count: 0 }); } ); @@ -426,8 +426,8 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Channels" }); - await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Channels" }); + await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", { count: 0 }); } ); @@ -469,7 +469,7 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", 1, { + await contains(".o-mail-DiscussSidebarCategory:contains(Channels) .badge", { text: "2", }); } @@ -491,8 +491,10 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Direct messages" }); - await contains(".o-mail-DiscussSidebarCategory:contains(Direct messages) .badge", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Direct messages" }); + await contains(".o-mail-DiscussSidebarCategory:contains(Direct messages) .badge", { + count: 0, + }); } ); @@ -515,8 +517,10 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Direct messages" }); - await contains(".o-mail-DiscussSidebarCategory:contains(Direct messages) .badge", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Direct messages" }); + await contains(".o-mail-DiscussSidebarCategory:contains(Direct messages) .badge", { + count: 0, + }); } ); @@ -536,8 +540,10 @@ QUnit.test( }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Direct messages" }); - await contains(".o-mail-DiscussSidebarCategory:contains(Direct messages) .badge", 0); + await contains(".o-mail-DiscussSidebarCategory", { text: "Direct messages" }); + await contains(".o-mail-DiscussSidebarCategory:contains(Direct messages) .badge", { + count: 0, + }); } ); @@ -593,10 +599,10 @@ QUnit.test("chat - command: should not have add command when category is folded" }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarCategory", 1, { text: "Direct messages" }); + await contains(".o-mail-DiscussSidebarCategory", { text: "Direct messages" }); await contains( ".o-mail-DiscussSidebarCategory:contains(Direct messages) i[title='Start a conversation']", - 0 + { count: 0 } ); }); @@ -611,7 +617,7 @@ QUnit.test("chat - states: close manually by clicking the title", async () => { openDiscuss(); await contains(".o-mail-DiscussSidebarChannel"); await click(".o-mail-DiscussSidebarCategory:contains(Direct messages) div:eq(0)"); - await contains(".o-mail-DiscussSidebarChannel", 0); + await contains(".o-mail-DiscussSidebarChannel", { count: 0 }); }); QUnit.test("sidebar channels should be ordered case insensitive alphabetically", async () => { @@ -638,7 +644,7 @@ QUnit.test("sidebar: public channel rendering", async () => { }); const { openDiscuss } = await start(); openDiscuss(); - await contains("button", 1, { text: "channel1" }); + await contains("button", { text: "channel1" }); await contains("button:contains(channel1) .fa-globe"); }); @@ -663,7 +669,7 @@ QUnit.test("channel - avatar: should update avatar url from bus", async (assert) openDiscuss(channelId); await contains( `img[data-src='${getOrigin()}/discuss/channel/${channelId}/avatar_128?unique=101010']`, - 2 + { count: 2 } ); await afterNextRender(() => { env.services.orm.call("discuss.channel", "write", [ @@ -675,7 +681,7 @@ QUnit.test("channel - avatar: should update avatar url from bus", async (assert) const newCacheKey = result[0]["avatarCacheKey"]; await contains( `img[data-src='${getOrigin()}/discuss/channel/${channelId}/avatar_128?unique=${newCacheKey}']`, - 2 + { count: 2 } ); }); @@ -748,7 +754,7 @@ QUnit.test("channel - states: close from the bus", async () => { }); }); await contains(".o-mail-DiscussSidebarCategory-channel .oi-chevron-right"); - await contains("button", 0, { text: "channel1" }); + await contains("button", { count: 0, text: "channel1" }); }); QUnit.test("channel - states: open from the bus", async () => { @@ -769,7 +775,7 @@ QUnit.test("channel - states: open from the bus", async () => { }); }); await contains(".o-mail-DiscussSidebarCategory-channel .oi-chevron-down"); - await contains("button", 1, { text: "channel1" }); + await contains("button", { text: "channel1" }); }); QUnit.test( @@ -784,10 +790,10 @@ QUnit.test( await click(".o-mail-DiscussSidebarCategory span", { text: "Channels" }); await contains(".o-mail-DiscussSidebarCategory-channel .oi-chevron-right"); - await contains("button", 1, { text: "channel1" }); + await contains("button", { text: "channel1" }); await click("button div", { text: "Inbox" }); - await contains("button", 0, { text: "channel1" }); + await contains("button", { count: 0, text: "channel1" }); } ); @@ -803,7 +809,7 @@ QUnit.test("chat - states: open manually by clicking the title", async () => { const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebarCategory-chat span", { text: "Direct messages" }); - await contains("button", 1, { text: "Mitchell Admin" }); + await contains("button", { text: "Mitchell Admin" }); }); QUnit.test("chat - states: close should call update server data", async (assert) => { @@ -874,7 +880,7 @@ QUnit.test("chat - states: close from the bus", async () => { }, }); await contains(".o-mail-DiscussSidebarCategory-chat .oi-chevron-right"); - await contains("button", 0, { text: "Mitchell Admin" }); + await contains("button", { count: 0, text: "Mitchell Admin" }); }); QUnit.test("chat - states: open from the bus", async () => { @@ -895,7 +901,7 @@ QUnit.test("chat - states: open from the bus", async () => { }); }); await contains(".o-mail-DiscussSidebarCategory-chat .oi-chevron-down"); - await contains("button", 1, { text: "Mitchell Admin" }); + await contains("button", { text: "Mitchell Admin" }); }); QUnit.test( @@ -906,18 +912,18 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss(); await contains(".o-mail-DiscussSidebarCategory-chat .oi-chevron-down"); - await contains("button", 1, { text: "Mitchell Admin" }); + await contains("button", { text: "Mitchell Admin" }); await click("button", { text: "Mitchell Admin" }); await contains("button:contains(Mitchell Admin).o-active"); await click(".o-mail-DiscussSidebarCategory-chat span", { text: "Direct messages" }); await contains(".o-mail-DiscussSidebarCategory-chat .oi-chevron-right"); - await contains("button", 1, { text: "Mitchell Admin" }); + await contains("button", { text: "Mitchell Admin" }); await click("button div", { text: "Inbox" }); await contains(".o-mail-DiscussSidebarCategory-chat .oi-chevron-right"); - await contains("button", 0, { text: "Mitchell Admin" }); + await contains("button", { count: 0, text: "Mitchell Admin" }); } ); @@ -993,9 +999,9 @@ QUnit.test("Can unpin chat channel", async () => { pyEnv["discuss.channel"].create({ channel_type: "chat" }); const { openDiscuss } = await start(); openDiscuss(); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "Mitchell Admin" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "Mitchell Admin" }); await click(".o-mail-DiscussSidebarChannel [title='Unpin Conversation']"); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "Mitchell Admin" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "Mitchell Admin" }); }); QUnit.test("Unpinning chat should display notification", async () => { @@ -1004,7 +1010,7 @@ QUnit.test("Unpinning chat should display notification", async () => { const { openDiscuss } = await start(); openDiscuss(); await click(".o-mail-DiscussSidebarChannel [title='Unpin Conversation']"); - await contains(".o-mail-DiscussSidebarChannel span", 0); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0 }); await contains( ".o_notification.border-info:contains(You unpinned your conversation with Mitchell Admin)" ); @@ -1015,9 +1021,9 @@ QUnit.test("Can leave channel", async () => { const channelId = pyEnv["discuss.channel"].create({ name: "General" }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-DiscussSidebarChannel span", 1, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { text: "General" }); await click("[title='Leave this channel']"); - await contains(".o-mail-DiscussSidebarChannel span", 0, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel span", { count: 0, text: "General" }); }); QUnit.test("Do no channel_info after unpin", async (assert) => { @@ -1075,7 +1081,7 @@ QUnit.test("Group unread counter up to date after mention is marked as seen", as openDiscuss(); await contains(".o-mail-DiscussSidebarChannel .o-discuss-badge"); click(".o-mail-DiscussSidebarChannel"); - await contains(".o-discuss-badge", 0); + await contains(".o-discuss-badge", { count: 0 }); }); QUnit.test("Unpinning channel closes its chat window", async () => { @@ -1085,9 +1091,9 @@ QUnit.test("Unpinning channel closes its chat window", async () => { await openFormView("discuss.channel"); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Sales" }); + await contains(".o-mail-ChatWindow-name", { text: "Sales" }); openDiscuss(); await click(".o-mail-DiscussSidebarChannel:contains(Sales) [title='Leave this channel']"); await openFormView("discuss.channel"); - await contains(".o-mail-ChatWindow", 0, { text: "Sales" }); + await contains(".o-mail-ChatWindow", { count: 0, text: "Sales" }); }); diff --git a/addons/mail/static/tests/emoji/emoji_tests.js b/addons/mail/static/tests/emoji/emoji_tests.js index cb935291299..9e1ecaaed24 100644 --- a/addons/mail/static/tests/emoji/emoji_tests.js +++ b/addons/mail/static/tests/emoji/emoji_tests.js @@ -14,7 +14,7 @@ QUnit.test("search emoji from keywords", async () => { openDiscuss(channelId); await click("button[aria-label='Emojis']"); await insertText("input[placeholder='Search for an emoji']", "mexican"); - await contains(".o-Emoji", 1, { text: "🌮" }); + await contains(".o-Emoji", { text: "🌮" }); }); QUnit.test("search emoji from keywords should be case insensitive", async () => { @@ -24,7 +24,7 @@ QUnit.test("search emoji from keywords should be case insensitive", async () => openDiscuss(channelId); await click("button[aria-label='Emojis']"); await insertText("input[placeholder='Search for an emoji']", "ok"); - await contains(".o-Emoji", 1, { text: "🆗" }); // all search terms are uppercase OK + await contains(".o-Emoji", { text: "🆗" }); // all search terms are uppercase OK }); QUnit.test("search emoji from keywords with special regex character", async () => { @@ -34,7 +34,7 @@ QUnit.test("search emoji from keywords with special regex character", async () = openDiscuss(channelId); await click("button[aria-label='Emojis']"); await insertText("input[placeholder='Search for an emoji']", "(blood"); - await contains(".o-Emoji", 1, { text: "🆎" }); + await contains(".o-Emoji", { text: "🆎" }); }); QUnit.test("Press Escape in emoji picker closes the emoji picker", async () => { @@ -44,7 +44,7 @@ QUnit.test("Press Escape in emoji picker closes the emoji picker", async () => { openDiscuss(channelId); await click("button[aria-label='Emojis']"); triggerHotkey("Escape"); - await contains(".o-EmojiPicker", 0); + await contains(".o-EmojiPicker", { count: 0 }); }); QUnit.test("Basic keyboard navigation", async () => { @@ -64,8 +64,8 @@ QUnit.test("Basic keyboard navigation", async () => { await contains(".o-EmojiPicker-content .o-Emoji[data-index=0].bg-200"); const codepoints = $(".o-EmojiPicker-content .o-Emoji[data-index=0].bg-200").data("codepoints"); triggerHotkey("Enter"); - await contains(".o-EmojiPicker", 0); - await contains(".o-mail-Composer-input", 1, { value: codepoints }); + await contains(".o-EmojiPicker", { count: 0 }); + await contains(".o-mail-Composer-input", { value: codepoints }); }); QUnit.test("recent category (basic)", async () => { @@ -74,7 +74,7 @@ QUnit.test("recent category (basic)", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click("button[aria-label='Emojis']"); - await contains(".o-EmojiPicker-navbar [title='Frequently used']", 0); + await contains(".o-EmojiPicker-navbar [title='Frequently used']", { count: 0 }); await click(".o-EmojiPicker-content .o-Emoji", { text: "😀" }); await click("button[aria-label='Emojis']"); await contains(".o-EmojiPicker-navbar [title='Frequently used']"); @@ -155,6 +155,6 @@ QUnit.test( ); await contains(".o-EmojiPicker-navbar [title='Frequently used']"); await contains(".o-EmojiPicker"); - await contains(".o-mail-Composer-input", 1, { value: "👺" }); + await contains(".o-mail-Composer-input", { value: "👺" }); } ); diff --git a/addons/mail/static/tests/gif_picker/gif_picker_test.js b/addons/mail/static/tests/gif_picker/gif_picker_test.js index 4231d399675..ce8b022970b 100644 --- a/addons/mail/static/tests/gif_picker/gif_picker_test.js +++ b/addons/mail/static/tests/gif_picker/gif_picker_test.js @@ -113,7 +113,7 @@ QUnit.test("Searching for a GIF", async () => { await click("button[aria-label='GIFs']"); insertText((await contains("input[placeholder='Search for a gif']"))[0], "search"); await contains("i[aria-label='back']"); - await contains(".o-discuss-Gif", 2); + await contains(".o-discuss-Gif", { count: 2 }); }); QUnit.test("Open a GIF category trigger the search for the category", async () => { @@ -132,8 +132,8 @@ QUnit.test("Open a GIF category trigger the search for the category", async () = openDiscuss(channelId); await click("button[aria-label='GIFs']"); await click("img[data-src='https://media.tenor.com/6uIlQAHIkNoAAAAM/cry.gif']"); - await contains(".o-discuss-Gif", 2); - await contains("input[placeholder='Search for a gif']", 1, { value: "cry" }); + await contains(".o-discuss-Gif", { count: 2 }); + await contains("input[placeholder='Search for a gif']", { value: "cry" }); }); QUnit.test("Reopen GIF category list when going back", async () => { @@ -184,7 +184,7 @@ QUnit.test("Chatter should not have the GIF button", async () => { const partnerId = pyEnv["res.partner"].create({ name: "John Doe" }); openFormView("res.partner", partnerId); await click("button", { text: "Log note" }); - await contains("button[aria-label='GIFs']", 0); + await contains("button[aria-label='GIFs']", { count: 0 }); }); QUnit.test( @@ -197,7 +197,7 @@ QUnit.test( openDiscuss(channelId, { waitUntilMessagesLoaded: false }); await click("span", { text: "General" }); await click("button[aria-label='GIFs']"); - await contains(".popover .o-discuss-GifPicker", 0); + await contains(".popover .o-discuss-GifPicker", { count: 0 }); await contains(".o-mail-Composer-footer .o-discuss-GifPicker"); } ); diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js index f63c0517439..2a9d7215edb 100644 --- a/addons/mail/static/tests/helpers/test_utils.js +++ b/addons/mail/static/tests/helpers/test_utils.js @@ -614,7 +614,7 @@ export { * @param {Object} [options={}] forwarded to `contains` */ export async function click(selector, options) { - await contains(selector, 1, { click: true, ...options }); + await contains(selector, { click: true, ...options }); } /** @@ -626,7 +626,7 @@ export async function click(selector, options) { * @param {Object} [options={}] forwarded to `contains` */ export async function scroll(selector, scrollTop, options) { - await contains(selector, 1, { setScroll: scrollTop, ...options }); + await contains(selector, { setScroll: scrollTop, ...options }); } let hasUsedContainsPositively = false; @@ -636,9 +636,9 @@ QUnit.testStart(() => (hasUsedContainsPositively = false)); * `options.target`. * * @param {string} selector - * @param {number} [count=1] * @param {Object} [options={}] * @param {boolean} [options.click] if provided, clicks on the found element + * @param {number} [count=1] * @param {number|"bottom"} [options.scroll] if provided, the scrollTop of the found element(s) * must match. * Note: when using one of the scrollTop options, it is advised to ensure the height is not going @@ -652,8 +652,7 @@ QUnit.testStart(() => (hasUsedContainsPositively = false)); */ export function contains( selector, - count = 1, - { click, scroll, setScroll, target = getFixture(), text, value } = {} + { click, count = 1, scroll, setScroll, target = getFixture(), text, value } = {} ) { if (count) { hasUsedContainsPositively = true; diff --git a/addons/mail/static/tests/mail_utils_tests.js b/addons/mail/static/tests/mail_utils_tests.js index c31c592b6f9..9faba3d8de2 100644 --- a/addons/mail/static/tests/mail_utils_tests.js +++ b/addons/mail/static/tests/mail_utils_tests.js @@ -76,7 +76,7 @@ QUnit.test("addLink: linkify inside text node (1 occurrence)", async (assert) => fragment.appendChild(div); div.innerHTML = linkified; assert.strictEqual(div.textContent, "some text https://somelink.com"); - await contains("a", 1, { target: div }); + await contains("a", { target: div }); assert.strictEqual(div.querySelector(":scope a").textContent, "https://somelink.com"); }); @@ -108,7 +108,7 @@ QUnit.test("url", async () => { const messageBody = "https://odoo.com?test=~^|`{}[]#"; await insertText(".o-mail-Composer-input", messageBody); await click("button:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Message a", 1, { text: messageBody }); + await contains(".o-mail-Message a", { text: messageBody }); }); QUnit.test("url with comma at the end", async () => { @@ -119,8 +119,8 @@ QUnit.test("url with comma at the end", async () => { const messageBody = "Go to https://odoo.com, it's great!"; await insertText(".o-mail-Composer-input", messageBody); await click("button:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Message a", 1, { text: "https://odoo.com" }); - await contains(".o-mail-Message-content", 1, { text: messageBody }); + await contains(".o-mail-Message a", { text: "https://odoo.com" }); + await contains(".o-mail-Message-content", { text: messageBody }); }); QUnit.test("url with dot at the end", async () => { @@ -131,8 +131,8 @@ QUnit.test("url with dot at the end", async () => { const messageBody = "Go to https://odoo.com. It's great!"; await insertText(".o-mail-Composer-input", messageBody); await click("button:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Message a", 1, { text: "https://odoo.com" }); - await contains(".o-mail-Message-content", 1, { text: messageBody }); + await contains(".o-mail-Message a", { text: "https://odoo.com" }); + await contains(".o-mail-Message-content", { text: messageBody }); }); QUnit.test("url with semicolon at the end", async () => { @@ -143,8 +143,8 @@ QUnit.test("url with semicolon at the end", async () => { const messageBody = "Go to https://odoo.com; it's great!"; await insertText(".o-mail-Composer-input", messageBody); await click("button:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Message a", 1, { text: "https://odoo.com" }); - await contains(".o-mail-Message-content", 1, { text: messageBody }); + await contains(".o-mail-Message a", { text: "https://odoo.com" }); + await contains(".o-mail-Message-content", { text: messageBody }); }); QUnit.test("url with ellipsis at the end", async () => { @@ -155,8 +155,8 @@ QUnit.test("url with ellipsis at the end", async () => { const messageBody = "Go to https://odoo.com... it's great!"; await insertText(".o-mail-Composer-input", messageBody); await click("button:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Message a", 1, { text: "https://odoo.com" }); - await contains(".o-mail-Message-content", 1, { text: messageBody }); + await contains(".o-mail-Message a", { text: "https://odoo.com" }); + await contains(".o-mail-Message-content", { text: messageBody }); }); QUnit.test("url with number in subdomain", async () => { @@ -167,7 +167,7 @@ QUnit.test("url with number in subdomain", async () => { const messageBody = "https://www.45017478-master-all.runbot134.odoo.com/web"; await insertText(".o-mail-Composer-input", messageBody); await click("button:not(:disabled)", { text: "Send" }); - await contains(".o-mail-Message a", 1, { + await contains(".o-mail-Message a", { text: "https://www.45017478-master-all.runbot134.odoo.com/web", }); }); diff --git a/addons/mail/static/tests/message/link_preview_test.js b/addons/mail/static/tests/message/link_preview_test.js index 47fc77ca1fe..92b3a365e58 100644 --- a/addons/mail/static/tests/message/link_preview_test.js +++ b/addons/mail/static/tests/message/link_preview_test.js @@ -75,8 +75,8 @@ QUnit.test("simplest card layout", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-LinkPreviewCard"); - await contains(".o-mail-LinkPreviewCard h6", 1, { text: "Article title" }); - await contains(".o-mail-LinkPreviewCard p", 1, { text: "Description" }); + await contains(".o-mail-LinkPreviewCard h6", { text: "Article title" }); + await contains(".o-mail-LinkPreviewCard p", { text: "Description" }); }); QUnit.test("simplest card layout with image", async () => { @@ -99,8 +99,8 @@ QUnit.test("simplest card layout with image", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-LinkPreviewCard"); - await contains(".o-mail-LinkPreviewCard h6", 1, { text: "Article title" }); - await contains(".o-mail-LinkPreviewCard p", 1, { text: "Description" }); + await contains(".o-mail-LinkPreviewCard h6", { text: "Article title" }); + await contains(".o-mail-LinkPreviewCard p", { text: "Description" }); await contains(".o-mail-LinkPreviewCard img"); }); @@ -124,8 +124,8 @@ QUnit.test("Link preview video layout", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-LinkPreviewVideo"); - await contains(".o-mail-LinkPreviewVideo h6", 1, { text: "video title" }); - await contains(".o-mail-LinkPreviewVideo p", 1, { text: "Description" }); + await contains(".o-mail-LinkPreviewVideo h6", { text: "video title" }); + await contains(".o-mail-LinkPreviewVideo p", { text: "Description" }); await contains(".o-mail-LinkPreviewVideo-overlay"); }); @@ -170,9 +170,9 @@ QUnit.test("Remove link preview Gif", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click(".o-mail-LinkPreviewImage button[aria-label='Remove']"); - await contains("p", 1, { text: "Do you really want to delete this preview?" }); + await contains("p", { text: "Do you really want to delete this preview?" }); await click(".modal-footer button", { text: "Ok" }); - await contains(".o-mail-LinkPreviewImage", 0); + await contains(".o-mail-LinkPreviewImage", { count: 0 }); }); QUnit.test("Remove link preview card", async () => { @@ -194,9 +194,9 @@ QUnit.test("Remove link preview card", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click(".o-mail-LinkPreviewCard button[aria-label='Remove']"); - await contains("p", 1, { text: "Do you really want to delete this preview?" }); + await contains("p", { text: "Do you really want to delete this preview?" }); await click(".modal-footer button", { text: "Ok" }); - await contains(".o-mail-LinkPreviewCard", 0); + await contains(".o-mail-LinkPreviewCard", { count: 0 }); }); QUnit.test("Remove link preview video", async () => { @@ -219,9 +219,9 @@ QUnit.test("Remove link preview video", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click(".o-mail-LinkPreviewVideo button[aria-label='Remove']"); - await contains("p", 1, { text: "Do you really want to delete this preview?" }); + await contains("p", { text: "Do you really want to delete this preview?" }); await click(".modal-footer button", { text: "Ok" }); - await contains(".o-mail-LinkPreviewVideo", 0); + await contains(".o-mail-LinkPreviewVideo", { count: 0 }); }); QUnit.test("Remove link preview image", async () => { @@ -242,9 +242,9 @@ QUnit.test("Remove link preview image", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await click(".o-mail-LinkPreviewImage button[aria-label='Remove']"); - await contains("p", 1, { text: "Do you really want to delete this preview?" }); + await contains("p", { text: "Do you really want to delete this preview?" }); await click(".modal-footer button", { text: "Ok" }); - await contains(".o-mail-LinkPreviewImage", 0); + await contains(".o-mail-LinkPreviewImage", { count: 0 }); }); QUnit.test("No crash on receiving link preview of non-known message", async (assert) => { @@ -292,7 +292,7 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-LinkPreviewImage"); - await contains(".o-mail-Message-bubble", 0); + await contains(".o-mail-Message-bubble", { count: 0 }); } ); diff --git a/addons/mail/static/tests/message/message_seen_indicator_tests.js b/addons/mail/static/tests/message/message_seen_indicator_tests.js index 44f144bd38d..f2430dfc101 100644 --- a/addons/mail/static/tests/message/message_seen_indicator_tests.js +++ b/addons/mail/static/tests/message/message_seen_indicator_tests.js @@ -105,7 +105,7 @@ QUnit.test("rendering when just one has seen the message", async (assert) => { await openDiscuss(channelId); await contains(".o-mail-MessageSeenIndicator"); assert.doesNotHaveClass($(".o-mail-MessageSeenIndicator"), "o-all-seen"); - await contains(".o-mail-MessageSeenIndicator i", 2); + await contains(".o-mail-MessageSeenIndicator i", { count: 2 }); }); QUnit.test("rendering when just one has seen & received the message", async (assert) => { @@ -139,7 +139,7 @@ QUnit.test("rendering when just one has seen & received the message", async (ass await openDiscuss(channelId); await contains(".o-mail-MessageSeenIndicator"); assert.doesNotHaveClass($(".o-mail-MessageSeenIndicator"), "o-all-seen"); - await contains(".o-mail-MessageSeenIndicator i", 2); + await contains(".o-mail-MessageSeenIndicator i", { count: 2 }); }); QUnit.test("rendering when just everyone has seen the message", async (assert) => { @@ -170,7 +170,7 @@ QUnit.test("rendering when just everyone has seen the message", async (assert) = await openDiscuss(channelId); await contains(".o-mail-MessageSeenIndicator"); assert.hasClass($(".o-mail-MessageSeenIndicator"), "o-all-seen"); - await contains(".o-mail-MessageSeenIndicator i", 2); + await contains(".o-mail-MessageSeenIndicator i", { count: 2 }); }); QUnit.test("'channel_fetch' notification received is correctly handled", async () => { @@ -193,7 +193,7 @@ QUnit.test("'channel_fetch' notification received is correctly handled", async ( const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-MessageSeenIndicator i", 0); + await contains(".o-mail-MessageSeenIndicator i", { count: 0 }); const channel = pyEnv["discuss.channel"].searchRead([["id", "=", channelId]])[0]; // Simulate received channel fetched notification @@ -227,7 +227,7 @@ QUnit.test("'channel_seen' notification received is correctly handled", async () const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-MessageSeenIndicator i", 0); + await contains(".o-mail-MessageSeenIndicator i", { count: 0 }); const channel = pyEnv["discuss.channel"].searchRead([["id", "=", channelId]])[0]; // Simulate received channel seen notification @@ -238,7 +238,7 @@ QUnit.test("'channel_seen' notification received is correctly handled", async () partner_id: partnerId, }); }); - await contains(".o-mail-MessageSeenIndicator i", 2); + await contains(".o-mail-MessageSeenIndicator i", { count: 2 }); }); QUnit.test( @@ -263,7 +263,7 @@ QUnit.test( const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-MessageSeenIndicator i", 0); + await contains(".o-mail-MessageSeenIndicator i", { count: 0 }); const channel = pyEnv["discuss.channel"].searchRead([["id", "=", channelId]])[0]; // Simulate received channel fetched notification @@ -284,7 +284,7 @@ QUnit.test( partner_id: partnerId, }); }); - await contains(".o-mail-MessageSeenIndicator i", 2); + await contains(".o-mail-MessageSeenIndicator i", { count: 2 }); } ); @@ -312,7 +312,7 @@ QUnit.test( const { openDiscuss } = await start(); await openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-MessageSeenIndicator", 0); + await contains(".o-mail-MessageSeenIndicator", { count: 0 }); } ); @@ -347,13 +347,13 @@ QUnit.test( pyEnv["discuss.channel.member"].write(memberIds, { seen_message_id: messageId_2 }); const { openDiscuss } = await start(); await openDiscuss(channelId); - await contains(".o-mail-Message-content", 1, { text: "Message before last seen" }); + await contains(".o-mail-Message-content", { text: "Message before last seen" }); await contains( ".o-mail-Message:contains(Message before last seen) .o-mail-MessageSeenIndicator" ); await contains( ".o-mail-Message:contains(Message before last seen) .o-mail-MessageSeenIndicator i", - 0 + { count: 0 } ); } ); diff --git a/addons/mail/static/tests/message/message_tests.js b/addons/mail/static/tests/message/message_tests.js index 510c6369c86..cf2fbe9840b 100644 --- a/addons/mail/static/tests/message/message_tests.js +++ b/addons/mail/static/tests/message/message_tests.js @@ -40,7 +40,7 @@ QUnit.test("Start edition on click edit", async () => { openDiscuss(channelId); await click(".o-mail-Message [title='Expand']"); await click(".o-mail-Message [title='Edit']"); - await contains(".o-mail-Message-editable .o-mail-Composer-input", 1, { value: "Hello world" }); + await contains(".o-mail-Message-editable .o-mail-Composer-input", { value: "Hello world" }); }); QUnit.test("Can edit message comment in chatter", async () => { @@ -59,7 +59,7 @@ QUnit.test("Can edit message comment in chatter", async () => { await click(".o-mail-Message [title='Edit']"); await insertText(".o-mail-Message .o-mail-Composer-input", "edited message", { replace: true }); await click(".o-mail-Message a", { text: "save" }); - await contains(".o-mail-Message-content", 1, { text: "edited message" }); + await contains(".o-mail-Message-content", { text: "edited message" }); }); QUnit.test("Cursor is at end of composer input on edit", async (assert) => { @@ -102,7 +102,7 @@ QUnit.test("Stop edition on click cancel", async () => { await click(".o-mail-Message [title='Expand']"); await click(".o-mail-Message [title='Edit']"); await click(".o-mail-Message a", { text: "cancel" }); - await contains(".o-mail-Message-editable .o-mail-Composer", 0); + await contains(".o-mail-Message-editable .o-mail-Composer", { count: 0 }); }); QUnit.test("Stop edition on press escape", async () => { @@ -123,7 +123,7 @@ QUnit.test("Stop edition on press escape", async () => { await click(".o-mail-Message [title='Expand']"); await click(".o-mail-Message [title='Edit']"); triggerHotkey("Escape", false); - await contains(".o-mail-Message-editable .o-mail-Composer", 0); + await contains(".o-mail-Message-editable .o-mail-Composer", { count: 0 }); }); QUnit.test("Stop edition on click save", async () => { @@ -144,7 +144,7 @@ QUnit.test("Stop edition on click save", async () => { await click(".o-mail-Message [title='Expand']"); await click(".o-mail-Message [title='Edit']"); await click(".o-mail-Message a", { text: "save" }); - await contains(".o-mail-Message-editable .o-mail-Composer", 0); + await contains(".o-mail-Message-editable .o-mail-Composer", { count: 0 }); }); QUnit.test("Stop edition on press enter", async () => { @@ -165,7 +165,7 @@ QUnit.test("Stop edition on press enter", async () => { await click(".o-mail-Message [title='Expand']"); await click(".o-mail-Message [title='Edit']"); triggerHotkey("Enter", false); - await contains(".o-mail-Message-editable .o-mail-Composer", 0); + await contains(".o-mail-Message-editable .o-mail-Composer", { count: 0 }); }); QUnit.test("Do not stop edition on click away when clicking on emoji", async () => { @@ -209,7 +209,7 @@ QUnit.test("Edit and click save", async () => { await click(".o-mail-Message [title='Edit']"); await insertText(".o-mail-Message .o-mail-Composer-input", "Goodbye World", { replace: true }); await click(".o-mail-Message a", { text: "save" }); - await contains(".o-mail-Message-body", 1, { text: "Goodbye World" }); + await contains(".o-mail-Message-body", { text: "Goodbye World" }); }); QUnit.test("Do not call server on save if no changes", async (assert) => { @@ -264,7 +264,7 @@ QUnit.test("Update the link previews when a message is edited", async (assert) = await click(".o-mail-Message [title='Edit']"); await insertText(".o-mail-Message .o-mail-Composer-input", "Goodbye World", { replace: true }); await click(".o-mail-Message a", { text: "save" }); - await contains(".o-mail-Message-body", 1, { text: "Goodbye World" }); + await contains(".o-mail-Message-body", { text: "Goodbye World" }); assert.verifySteps(["link_preview"]); }); @@ -287,7 +287,7 @@ QUnit.test("Scroll bar to the top when edit starts", async (assert) => { await click(".o-mail-Message [title='Edit']"); const $textarea = await contains(".o-mail-Message .o-mail-Composer-input"); assert.ok($textarea[0].scrollHeight > $textarea[0].clientHeight); - await contains(".o-mail-Message .o-mail-Composer-input", 1, { scroll: 0 }); + await contains(".o-mail-Message .o-mail-Composer-input", { scroll: 0 }); }); QUnit.test("mentions are kept when editing message", async () => { @@ -343,7 +343,7 @@ QUnit.test("can add new mentions when editing message", async () => { await click(".o-mail-Message [title='Edit']"); await insertText(".o-mail-Message .o-mail-Composer-input", " @"); await click(".o-mail-Composer-suggestion strong", { text: "TestPartner" }); - await contains(".o-mail-Composer-input", 1, { value: "Hello @TestPartner " }); + await contains(".o-mail-Composer-input", { value: "Hello @TestPartner " }); await click(".o-mail-Message a", { text: "save" }); await contains( ".o-mail-Message-body:contains(Hello @TestPartner) a.o_mail_redirect:contains(@TestPartner)" @@ -362,12 +362,12 @@ QUnit.test("Other messages are grayed out when replying to another one", async ( ]); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); await click(".o-mail-Message:contains(Hello world) [title='Reply']"); - await contains(".o-mail-Message.opacity-50 .o-mail-Message-content", 1, { + await contains(".o-mail-Message.opacity-50 .o-mail-Message-content", { text: "Goodbye world", }); - await contains(".o-mail-Message:not(.opacity_50) .o-mail-Message-content", 1, { + await contains(".o-mail-Message:not(.opacity_50) .o-mail-Message-content", { text: "Hello world", }); }); @@ -420,7 +420,7 @@ QUnit.test( const input = (await contains(".o-mail-Message .o-mail-Composer-input"))[0]; insertText(input, "Goodbye World", { replace: true }); triggerHotkey("Enter", false); - await contains(".o-mail-MessageInReply-message", 1, { text: "Goodbye World" }); + await contains(".o-mail-MessageInReply-message", { text: "Goodbye World" }); assert.strictEqual($(".o-mail-MessageInReply-message")[0].innerText, "Goodbye World"); } ); @@ -445,7 +445,7 @@ QUnit.test("Deleting parent message of a reply should adapt reply visual", async await click(".o-mail-Message [title='Expand']"); await click(".o-mail-Message [title='Delete']"); await click("button", { text: "Confirm" }); - await contains(".o-mail-MessageInReply", 1, { text: "Original message was deleted" }); + await contains(".o-mail-MessageInReply", { text: "Original message was deleted" }); }); QUnit.test("Can open emoji picker after edit mode", async () => { @@ -485,7 +485,7 @@ QUnit.test("Can add a reaction", async () => { openDiscuss(channelId); await click("[title='Add a Reaction']"); await click(".o-Emoji", { text: "😅" }); - await contains(".o-mail-MessageReaction", 1, { text: "😅1" }); + await contains(".o-mail-MessageReaction", { text: "😅1" }); }); QUnit.test("Can remove a reaction", async () => { @@ -505,7 +505,7 @@ QUnit.test("Can remove a reaction", async () => { await click("[title='Add a Reaction']"); await click(".o-Emoji", { text: "😅" }); await click(".o-mail-MessageReaction"); - await contains(".o-mail-MessageReaction", 0); + await contains(".o-mail-MessageReaction", { count: 0 }); }); QUnit.test("Two users reacting with the same emoji", async () => { @@ -535,9 +535,9 @@ QUnit.test("Two users reacting with the same emoji", async () => { ]); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-MessageReaction", 1, { text: "😅2" }); + await contains(".o-mail-MessageReaction", { text: "😅2" }); await click(".o-mail-MessageReaction"); - await contains(".o-mail-MessageReaction", 1, { text: "😅1" }); + await contains(".o-mail-MessageReaction", { text: "😅1" }); }); QUnit.test("Reaction summary", async () => { @@ -590,7 +590,7 @@ QUnit.test("Add the same reaction twice from the emoji picker", async () => { await click(".o-Emoji", { text: "😅" }); await click("[title='Add a Reaction']"); await click(".o-Emoji", { text: "😅" }); - await contains(".o-mail-MessageReaction", 1, { text: "😅1" }); + await contains(".o-mail-MessageReaction", { text: "😅1" }); }); QUnit.test("basic rendering of message", async () => { @@ -607,11 +607,11 @@ QUnit.test("basic rendering of message", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-Message .o-mail-Message-content", 1, { text: "body" }); + await contains(".o-mail-Message .o-mail-Message-content", { text: "body" }); await contains( `.o-mail-Message .o-mail-Message-sidebar .o-mail-Message-avatarContainer img[data-src='${getOrigin()}/discuss/channel/${channelId}/partner/${partnerId}/avatar_128']` ); - await contains(".o-mail-Message .o-mail-Message-header .o-mail-Message-author", 1, { + await contains(".o-mail-Message .o-mail-Message-header .o-mail-Message-author", { text: "Demo", }); await contains( @@ -629,7 +629,7 @@ QUnit.test("should not be able to reply to temporary/transient messages", async // these user interactions is to forge a transient message response from channel command "/who" await insertText(".o-mail-Composer-input", "/who"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message [title='Reply']", 0); + await contains(".o-mail-Message [title='Reply']", { count: 0 }); }); QUnit.test("message comment of same author within 1min. should be squashed", async () => { @@ -659,19 +659,17 @@ QUnit.test("message comment of same author within 1min. should be squashed", asy ]); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Message-content", 1, { text: "body1" }); - await contains(".o-mail-Message-content", 1, { text: "body2" }); + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Message-content", { text: "body1" }); + await contains(".o-mail-Message-content", { text: "body2" }); await contains(".o-mail-Message:contains(body1) .o-mail-Message-header"); - await contains(".o-mail-Message:contains(body2) .o-mail-Message-header", 0); - await contains( - ".o-mail-Message:contains(body1) .o-mail-Message-sidebar .o-mail-Message-date", - 0 - ); - await contains( - ".o-mail-Message:contains(body2) .o-mail-Message-sidebar .o-mail-Message-date", - 0 - ); + await contains(".o-mail-Message:contains(body2) .o-mail-Message-header", { count: 0 }); + await contains(".o-mail-Message:contains(body1) .o-mail-Message-sidebar .o-mail-Message-date", { + count: 0, + }); + await contains(".o-mail-Message:contains(body2) .o-mail-Message-sidebar .o-mail-Message-date", { + count: 0, + }); await click(".o-mail-Message", { text: "body2" }); await contains(".o-mail-Message:contains(body2) .o-mail-Message-sidebar .o-mail-Message-date"); }); @@ -698,11 +696,11 @@ QUnit.test("redirect to author (open chat)", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId_1); - await contains(".o-mail-DiscussSidebarChannel.o-active", 1, { text: "General" }); + await contains(".o-mail-DiscussSidebarChannel.o-active", { text: "General" }); await contains(".o-mail-Discuss-content .o-mail-Message-avatarContainer img"); await click(".o-mail-Discuss-content .o-mail-Message-avatarContainer img"); - await contains(".o-mail-DiscussSidebarChannel.o-active", 1, { text: "Demo" }); + await contains(".o-mail-DiscussSidebarChannel.o-active", { text: "Demo" }); }); QUnit.test("open chat from avatar should not work on self-authored messages", async () => { @@ -726,8 +724,8 @@ QUnit.test("open chat from avatar should not work on self-authored messages", as await contains(".o-mail-Message-author:not(.cursor-pointer)"); await click(".o-mail-Message-avatar"); // weak test, no guarantee that we waited long enough to open the chat/view - await contains(".o-mail-DiscussSidebarChannel.o-active", 0, { text: "Mitchell Admin" }); - await contains(".breadcrumb", 0, { text: "Mitchell Admin" }); + await contains(".o-mail-DiscussSidebarChannel.o-active", { count: 0, text: "Mitchell Admin" }); + await contains(".breadcrumb", { count: 0, text: "Mitchell Admin" }); }); QUnit.test("toggle_star message", async (assert) => { @@ -750,16 +748,16 @@ QUnit.test("toggle_star message", async (assert) => { await contains(".o-mail-Message"); await contains(".o-mail-Message [title='Mark as Todo']"); await contains(".o-mail-Message [title='Mark as Todo'] i.fa-star-o"); - await contains("button:contains(Starred) .badge", 0); + await contains("button:contains(Starred) .badge", { count: 0 }); await click("[title='Mark as Todo']"); - await contains("button:contains(Starred) .badge", 1, { text: "1" }); + await contains("button:contains(Starred) .badge", { text: "1" }); assert.verifySteps(["rpc:toggle_message_starred"]); await contains(".o-mail-Message"); await contains(".o-mail-Message [title='Mark as Todo'] i.fa-star"); await click("[title='Mark as Todo']"); - await contains("button:contains(Starred) .badge", 0); + await contains("button:contains(Starred) .badge", { count: 0 }); assert.verifySteps(["rpc:toggle_message_starred"]); await contains(".o-mail-Message"); await contains(".o-mail-Message [title='Mark as Todo'] i.fa-star-o"); @@ -814,7 +812,7 @@ QUnit.test( await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message-author", 0); + await contains(".o-mail-Message-author", { count: 0 }); } ); @@ -867,7 +865,7 @@ QUnit.test("Notification Sent", async (assert) => { await contains(".o-mail-MessageNotificationPopover"); await contains(".o-mail-MessageNotificationPopover i"); assert.hasClass($(".o-mail-MessageNotificationPopover i"), "fa-check"); - await contains(".o-mail-MessageNotificationPopover", 1, { text: "Someone" }); + await contains(".o-mail-MessageNotificationPopover", { text: "Someone" }); }); QUnit.test("Notification Error", async (assert) => { @@ -939,7 +937,7 @@ QUnit.test( await contains(".o-mail-Message"); triggerHotkey("ArrowUp"); await contains(".o-mail-Message .o-mail-Message-editable"); - await contains(".o-mail-Message .o-mail-Composer-input", 1, { value: "not empty" }); + await contains(".o-mail-Message .o-mail-Composer-input", { value: "not empty" }); } ); @@ -966,7 +964,7 @@ QUnit.test("Editing a message to clear its composer opens message delete dialog. "" ); triggerHotkey("Enter"); - await contains(".modal-body p", 1, { text: "Are you sure you want to delete this message?" }); + await contains(".modal-body p", { text: "Are you sure you want to delete this message?" }); }); QUnit.test( @@ -997,10 +995,9 @@ QUnit.test( "" ); triggerHotkey("Enter"); - await contains( - ".modal-body p:contains('Are you sure you want to delete this message?')", - 0 - ); + await contains(".modal-body p:contains('Are you sure you want to delete this message?')", { + count: 0, + }); } ); @@ -1082,7 +1079,7 @@ QUnit.test("allow attachment delete on authored message", async (assert) => { assert.strictEqual($(".modal-body").text(), 'Do you really want to delete "BLAH"?'); await click(".modal-footer .btn-primary"); - await contains(".o-mail-AttachmentCard", 0); + await contains(".o-mail-AttachmentCard", { count: 0 }); }); QUnit.test("prevent attachment delete on non-authored message in channels", async () => { @@ -1110,7 +1107,7 @@ QUnit.test("prevent attachment delete on non-authored message in channels", asyn const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-AttachmentImage"); - await contains(".o-mail-AttachmentImage div[title='Remove']", 0); + await contains(".o-mail-AttachmentImage div[title='Remove']", { count: 0 }); }); QUnit.test("Toggle star should update starred counter on all tabs", async () => { @@ -1131,7 +1128,7 @@ QUnit.test("Toggle star should update starred counter on all tabs", async () => await tab1.openDiscuss(channelId); await tab2.openDiscuss(); await click(".o-mail-Message [title='Mark as Todo']", { target: tab1.target }); - await contains("button:contains(Starred) .badge", 1, { target: tab2.target, text: "1" }); + await contains("button:contains(Starred) .badge", { target: tab2.target, text: "1" }); }); QUnit.test("allow attachment image download on message", async () => { @@ -1171,7 +1168,7 @@ QUnit.test("chat with author should be opened after clicking on their avatar", a assert.hasClass($(".o-mail-Message-avatarContainer"), "cursor-pointer"); await click(".o-mail-Message-avatar"); await contains(".o-mail-ChatWindow-content"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Partner_2" }); + await contains(".o-mail-ChatWindow-name", { text: "Partner_2" }); }); QUnit.test("chat with author should be opened after clicking on their name", async () => { @@ -1186,11 +1183,11 @@ QUnit.test("chat with author should be opened after clicking on their name", asy }); const { openFormView } = await start(); openFormView("res.partner", partnerId); - await contains(".o-mail-Message span", 1, { text: "Demo User" }); + await contains(".o-mail-Message span", { text: "Demo User" }); await click(".o-mail-Message span", { text: "Demo User" }); await contains(".o-mail-ChatWindow"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Demo User" }); + await contains(".o-mail-ChatWindow-name", { text: "Demo User" }); }); QUnit.test("subtype description should be displayed if it is different than body", async () => { @@ -1205,7 +1202,7 @@ QUnit.test("subtype description should be displayed if it is different than body }); const { openFormView } = await start(); openFormView("res.partner", threadId); - await contains(".o-mail-Message-body", 1, { text: "HelloBonjour" }); + await contains(".o-mail-Message-body", { text: "HelloBonjour" }); }); QUnit.test("subtype description should not be displayed if it is similar to body", async () => { @@ -1220,7 +1217,7 @@ QUnit.test("subtype description should not be displayed if it is similar to body }); const { openFormView } = await start(); openFormView("res.partner", threadId); - await contains(".o-mail-Message-body", 1, { text: "Hello" }); + await contains(".o-mail-Message-body", { text: "Hello" }); }); QUnit.test("data-oe-id & data-oe-model link redirection on click", async (assert) => { @@ -1257,11 +1254,11 @@ QUnit.test("Chat with partner should be opened after clicking on their mention", await click("button", { text: "Send message" }); await insertText(".o-mail-Composer-input", "@Te"); await click(".o-mail-Composer-suggestion strong", { text: "Test Partner" }); - await contains(".o-mail-Composer-input", 1, { value: "@Test Partner " }); + await contains(".o-mail-Composer-input", { value: "@Test Partner " }); await click(".o-mail-Composer-send:not(:disabled)"); await click(".o_mail_redirect"); await contains(".o-mail-ChatWindow-content"); - await contains(".o-mail-ChatWindow-name", 1, { text: "Test Partner" }); + await contains(".o-mail-ChatWindow-name", { text: "Test Partner" }); }); QUnit.test( @@ -1291,7 +1288,7 @@ QUnit.test( click(".o-mail-Message-avatar").catch(() => {}); await nextAnimationFrame(); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); } ); @@ -1307,7 +1304,7 @@ QUnit.test("Channel should be opened after clicking on its mention", async () => await click(".o-mail-Composer-send:not(:disabled)"); await click(".o_channel_redirect"); await contains(".o-mail-ChatWindow-content"); - await contains(".o-mail-ChatWindow-name", 1, { text: "my-channel" }); + await contains(".o-mail-ChatWindow-name", { text: "my-channel" }); }); QUnit.test( @@ -1331,7 +1328,7 @@ QUnit.test( await click(".o-mail-AttachmentCard button[title='Remove']"); await click(".modal button", { text: "Ok" }); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); } ); @@ -1373,7 +1370,7 @@ QUnit.test("message with subtype should be displayed (and not considered as empt const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { text: "Task created" }); + await contains(".o-mail-Message-content", { text: "Task created" }); }); QUnit.test("message considered empty", async () => { @@ -1423,7 +1420,7 @@ QUnit.test("message considered empty", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Thread-empty"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test("message with html not to be considered empty", async () => { @@ -1496,7 +1493,7 @@ QUnit.test("Mark as unread", async () => { await click("[title='Expand']"); await click("[title='Mark as Unread']"); await contains(".o-mail-Thread-newMessage"); - await contains(".o-mail-DiscussSidebarChannel .badge", 1, { text: "1" }); + await contains(".o-mail-DiscussSidebarChannel .badge", { text: "1" }); }); QUnit.test("Avatar of unknown author", async () => { @@ -1528,7 +1525,7 @@ QUnit.test("Show email_from of message without author", async () => { }); const { openFormView } = await start(); openFormView("res.partner", pyEnv.currentPartnerId); - await contains(".o-mail-Message-author", 1, { text: "md@oilcompany.fr" }); + await contains(".o-mail-Message-author", { text: "md@oilcompany.fr" }); }); QUnit.test("Message should display attachments in order", async () => { @@ -1551,7 +1548,7 @@ QUnit.test("Message should display attachments in order", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-AttachmentCard:eq(0) div", 1, { text: "A.txt" }); - await contains(".o-mail-AttachmentCard:eq(1) div", 1, { text: "B.txt" }); - await contains(".o-mail-AttachmentCard:eq(2) div", 1, { text: "C.txt" }); + await contains(".o-mail-AttachmentCard:eq(0) div", { text: "A.txt" }); + await contains(".o-mail-AttachmentCard:eq(1) div", { text: "B.txt" }); + await contains(".o-mail-AttachmentCard:eq(2) div", { text: "C.txt" }); }); diff --git a/addons/mail/static/tests/messaging/messaging_tests.js b/addons/mail/static/tests/messaging/messaging_tests.js index 4da294b995d..d9fa61d9fd8 100644 --- a/addons/mail/static/tests/messaging/messaging_tests.js +++ b/addons/mail/static/tests/messaging/messaging_tests.js @@ -25,7 +25,7 @@ QUnit.test("Receiving a new message out of discuss app should open a chat window thread_model: "discuss.channel", }) ); - await contains(".o-mail-ChatWindow-name", 1, { text: "Dumbledore" }); + await contains(".o-mail-ChatWindow-name", { text: "Dumbledore" }); }); QUnit.test( @@ -53,7 +53,7 @@ QUnit.test( ); // leaving discuss. await openFormView("res.partner", partnerId); - await contains(".o-mail-ChatWindow-name", 1, { text: "Dumbledore" }); + await contains(".o-mail-ChatWindow-name", { text: "Dumbledore" }); } ); @@ -76,6 +76,6 @@ QUnit.test( // leaving discuss. await openFormView("res.partner", partnerId); // weak test, no guarantee that we waited long enough for the potential chat window to open - await contains(".o-mail-ChatWindow-name", 0, { text: "Dumbledore" }); + await contains(".o-mail-ChatWindow-name", { count: 0, text: "Dumbledore" }); } ); diff --git a/addons/mail/static/tests/messaging_menu/messaging_menu_tests.js b/addons/mail/static/tests/messaging_menu/messaging_menu_tests.js index e60b0070ba8..c7663ce34c3 100644 --- a/addons/mail/static/tests/messaging_menu/messaging_menu_tests.js +++ b/addons/mail/static/tests/messaging_menu/messaging_menu_tests.js @@ -19,7 +19,7 @@ QUnit.module("messaging menu"); QUnit.test("should have messaging menu button in systray", async () => { await start(); await contains(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-MessagingMenu", 0); + await contains(".o-mail-MessagingMenu", { count: 0 }); await contains(".o_menu_systray i[aria-label='Messages'].fa-comments"); }); @@ -27,14 +27,14 @@ QUnit.test("messaging menu should have topbar buttons", async () => { await start(); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-MessagingMenu"); - await contains(".o-mail-MessagingMenu-header button", 4); - await contains("button", 1, { text: "All" }); - await contains("button", 1, { text: "Chats" }); - await contains("button", 1, { text: "Channels" }); - await contains("button", 1, { text: "New Message" }); + await contains(".o-mail-MessagingMenu-header button", { count: 4 }); + await contains("button", { text: "All" }); + await contains("button", { text: "Chats" }); + await contains("button", { text: "Channels" }); + await contains("button", { text: "New Message" }); await contains("button:contains(All).fw-bolder"); - await contains("button:contains(Chats).fw-bolder", 0); - await contains("button:contains(Channels).fw-bolder", 0); + await contains("button:contains(Chats).fw-bolder", { count: 0 }); + await contains("button:contains(Channels).fw-bolder", { count: 0 }); }); QUnit.test("counter is taking into account failure notification", async (assert) => { @@ -74,23 +74,23 @@ QUnit.test("rendering with OdooBot has a request (default)", async (assert) => { .data("src") .includes("/web/image?field=avatar_128&id=2&model=res.partner") ); - await contains(".o-mail-NotificationItem-name", 1, { text: "OdooBot has a request" }); + await contains(".o-mail-NotificationItem-name", { text: "OdooBot has a request" }); }); QUnit.test("rendering without OdooBot has a request (denied)", async () => { patchBrowserNotification("denied"); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-MessagingMenu-counter", 0); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-MessagingMenu-counter", { count: 0 }); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("rendering without OdooBot has a request (accepted)", async () => { patchBrowserNotification("granted"); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-MessagingMenu-counter", 0); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-MessagingMenu-counter", { count: 0 }); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("respond to notification prompt (denied)", async () => { @@ -101,9 +101,9 @@ QUnit.test("respond to notification prompt (denied)", async () => { await contains( ".o_notification.border-warning:contains(Odoo will not send notifications on this device.)" ); - await contains(".o-mail-MessagingMenu-counter", 0); + await contains(".o-mail-MessagingMenu-counter", { count: 0 }); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("respond to notification prompt (granted)", async () => { @@ -124,33 +124,33 @@ QUnit.test("no 'OdooBot has a request' in mobile app", async () => { }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-MessagingMenu-counter", 0); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-MessagingMenu-counter", { count: 0 }); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("Is closed after clicking on new message", async () => { await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click("button", { text: "New Message" }); - await contains(".o-mail-MessagingMenu", 0); + await contains(".o-mail-MessagingMenu", { count: 0 }); }); QUnit.test("no 'New Message' button when discuss is open", async () => { const { openDiscuss, openView } = await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains("button", 1, { text: "New Message" }); + await contains("button", { text: "New Message" }); await openDiscuss(); - await contains("button", 0, { text: "New Message" }); + await contains("button", { count: 0, text: "New Message" }); await openView({ res_model: "res.partner", views: [[false, "form"]], }); - await contains("button", 1, { text: "New Message" }); + await contains("button", { text: "New Message" }); await openDiscuss(); - await contains("button", 0, { text: "New Message" }); + await contains("button", { count: 0, text: "New Message" }); }); QUnit.test("grouped notifications by document", async () => { @@ -184,8 +184,8 @@ QUnit.test("grouped notifications by document", async () => { await start(); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-NotificationItem"); - await contains(".o-mail-NotificationItem:contains(Partner) .badge", 1, { text: "2" }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-NotificationItem:contains(Partner) .badge", { text: "2" }); + await contains(".o-mail-ChatWindow", { count: 0 }); await click(".o-mail-NotificationItem"); await contains(".o-mail-ChatWindow"); @@ -243,7 +243,7 @@ QUnit.test("grouped notifications by document model", async (assert) => { }, }); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem:contains(Partner) .badge", 1, { text: "2" }); + await contains(".o-mail-NotificationItem:contains(Partner) .badge", { text: "2" }); $(".o-mail-NotificationItem")[0].click(); assert.verifySteps(["do_action"]); @@ -291,7 +291,7 @@ QUnit.test( ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); assert.ok($(".o-mail-NotificationItem:eq(0)").text().includes("Company")); assert.ok($(".o-mail-NotificationItem:eq(1)").text().includes("Partner")); } @@ -312,7 +312,7 @@ QUnit.test("non-failure notifications are ignored", async () => { }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("mark unread channel as read", async (assert) => { @@ -348,8 +348,8 @@ QUnit.test("mark unread channel as read", async (assert) => { assert.verifySteps(["set_last_seen_message"]); await contains(".o-mail-NotificationItem.o-muted"); await triggerEvent($(".o-mail-NotificationItem")[0], null, "mouseenter"); - await contains(".o-mail-NotificationItem [title='Mark As Read']", 0); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-NotificationItem [title='Mark As Read']", { count: 0 }); + await contains(".o-mail-ChatWindow", { count: 0 }); }); QUnit.test("mark failure as read", async () => { @@ -371,17 +371,18 @@ QUnit.test("mark failure as read", async () => { }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Channel" }); - await contains(".o-mail-NotificationItem-text", 1, { + await contains(".o-mail-NotificationItem-name", { text: "Channel" }); + await contains(".o-mail-NotificationItem-text", { text: "An error occurred when sending an email", }); await triggerEvent($(".o-mail-NotificationItem:contains(Channel)")[0], null, "mouseenter"); await contains(".o-mail-NotificationItem:contains(Channel) [title='Mark As Read']"); await click(".o-mail-NotificationItem [title='Mark As Read']"); - await contains(".o-mail-NotificationItem-name", 0, { text: "Channel" }); + await contains(".o-mail-NotificationItem-name", { count: 0, text: "Channel" }); - await contains("o-mail-NotificationItem-text", 0, { + await contains("o-mail-NotificationItem-text", { + count: 0, text: "An error occurred when sending an email", }); }); @@ -430,7 +431,7 @@ QUnit.test("different discuss.channel are not grouped", async () => { ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 4); + await contains(".o-mail-NotificationItem", { count: 4 }); await click(".o-mail-NotificationItem:contains(Channel):first"); await contains(".o-mail-ChatWindow"); }); @@ -457,34 +458,34 @@ QUnit.test('"Start a conversation" in mobile shows channel selector (+ click awa const { openDiscuss } = await start(); await openDiscuss(); await click("button", { text: "Chat" }); - await contains("button", 1, { text: "Start a conversation" }); - await contains("input[placeholder='Start a conversation']", 0); + await contains("button", { text: "Start a conversation" }); + await contains("input[placeholder='Start a conversation']", { count: 0 }); await click("button", { text: "Start a conversation" }); - await contains("button", 0, { text: "Start a conversation" }); + await contains("button", { count: 0, text: "Start a conversation" }); await contains("input[placeholder='Start a conversation']"); await click(".o-mail-MessagingMenu"); - await contains("button", 1, { text: "Start a conversation" }); - await contains("input[placeholder='Start a conversation']", 0); + await contains("button", { text: "Start a conversation" }); + await contains("input[placeholder='Start a conversation']", { count: 0 }); }); QUnit.test('"New Channel" in mobile shows channel selector (+ click away)', async () => { patchUiSize({ height: 360, width: 640 }); const { openDiscuss } = await start(); await openDiscuss(); await click("button", { text: "Channel" }); - await contains("button", 1, { text: "New Channel" }); - await contains("input[placeholder='Add or join a channel']", 0); + await contains("button", { text: "New Channel" }); + await contains("input[placeholder='Add or join a channel']", { count: 0 }); await click("button", { text: "New Channel" }); - await contains("button", 0, { text: "New Channel" }); + await contains("button", { count: 0, text: "New Channel" }); await contains("input[placeholder='Add or join a channel']"); await click(".o-mail-MessagingMenu"); - await contains("button", 1, { text: "New Channel" }); - await contains("input[placeholder='Add or join a channel']", 0); + await contains("button", { text: "New Channel" }); + await contains("input[placeholder='Add or join a channel']", { count: 0 }); }); QUnit.test("'New Message' button should open a chat window in mobile", async () => { @@ -523,7 +524,7 @@ QUnit.test("Counter is updated when receiving new message", async () => { }) ) ); - await contains(".o-mail-MessagingMenu-counter", 1, { text: "1" }); + await contains(".o-mail-MessagingMenu-counter", { text: "1" }); }); QUnit.test("basic rendering", async (assert) => { @@ -541,19 +542,19 @@ QUnit.test("basic rendering", async (assert) => { ); await contains(".o_menu_systray i[aria-label='Messages']"); await contains('.o_menu_systray i[aria-label="Messages"].fa-comments'); - await contains(".o-mail-MessagingMenu", 0); + await contains(".o-mail-MessagingMenu", { count: 0 }); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); await contains('.o_menu_systray .dropdown:has(i[aria-label="Messages"]).show'); await contains(".o-mail-MessagingMenu"); await contains(".o-mail-MessagingMenu-header"); - await contains(".o-mail-MessagingMenu-header button", 4); + await contains(".o-mail-MessagingMenu-header button", { count: 4 }); await contains('.o-mail-MessagingMenu button:contains("All")'); await contains('.o-mail-MessagingMenu button:contains("Chats")'); await contains('.o-mail-MessagingMenu button:contains("Channels")'); await contains('.o-mail-MessagingMenu button:contains("All").fw-bolder'); await contains('.o-mail-MessagingMenu button:contains("Chats"):not(.fw-bolder)'); await contains('.o-mail-MessagingMenu button:contains("Channels"):not(.fw-bolder)'); - await contains("button", 1, { text: "New Message" }); + await contains("button", { text: "New Message" }); await contains('.o-mail-MessagingMenu:contains("No conversation yet...")'); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); assert.doesNotHaveClass( @@ -623,7 +624,7 @@ QUnit.test("filtered previews", async () => { ]); await start(); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); await contains('.o-mail-NotificationItem:contains("Mitchell Admin")'); await contains('.o-mail-NotificationItem:contains("channel1")'); await click('.o-mail-MessagingMenu button:contains("Chats")'); @@ -631,7 +632,7 @@ QUnit.test("filtered previews", async () => { await click('.o-mail-MessagingMenu button:contains("Channels")'); await contains('.o-mail-NotificationItem:contains("channel1")'); await click('.o-mail-MessagingMenu button:contains("All")'); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); await contains('.o-mail-NotificationItem:contains("Mitchell Admin")'); await click('.o-mail-MessagingMenu button:contains("Channels")'); await contains('.o-mail-NotificationItem:contains("channel1")'); @@ -650,7 +651,7 @@ QUnit.test("no code injection in message body preview", async () => { await contains( ".o-mail-NotificationItem-text:contains(You: &shoulnotberaisedthrow new Error('CodeInjectionError');)" ); - await contains(".o-mail-NotificationItem-text script", 0); + await contains(".o-mail-NotificationItem-text script", { count: 0 }); }); QUnit.test("no code injection in message body preview from sanitized message", async () => { @@ -666,7 +667,7 @@ QUnit.test("no code injection in message body preview from sanitized message", a await contains( ".o-mail-NotificationItem-text:contains(You: &shoulnotberaised)" ); - await contains(".o-mail-NotificationItem-text script", 0); + await contains(".o-mail-NotificationItem-text script", { count: 0 }); }); QUnit.test("
tags in message body preview are transformed in spaces", async () => { @@ -679,7 +680,7 @@ QUnit.test("
tags in message body preview are transformed in spaces", async }); await start(); await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Messages'])"); - await contains(".o-mail-NotificationItem-text", 1, { text: "You: a b c d" }); + await contains(".o-mail-NotificationItem-text", { text: "You: a b c d" }); }); QUnit.test( @@ -741,12 +742,12 @@ QUnit.test("click on preview should mark as read and open the thread", async () }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Frodo Baggins" }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-NotificationItem-name", { text: "Frodo Baggins" }); + await contains(".o-mail-ChatWindow", { count: 0 }); await click(".o-mail-NotificationItem-name", { text: "Frodo Baggins" }); await contains(".o-mail-ChatWindow"); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-name", 0, { text: "Frodo Baggins" }); + await contains(".o-mail-NotificationItem-name", { count: 0, text: "Frodo Baggins" }); }); QUnit.test( @@ -779,7 +780,7 @@ QUnit.test( await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name", { text: "Frodo Baggins" }); await click(".o-mail-ChatWindow-command i.fa-expand"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); assert.verifySteps(["do_action"], "should have done an action to open the form view"); } ); @@ -811,7 +812,7 @@ QUnit.test( }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-text", 1, { + await contains(".o-mail-NotificationItem-text", { text: "Stranger: I am the oldest but needaction", }); } @@ -874,8 +875,8 @@ QUnit.test("chat should show unread counter on receiving new messages", async () await start(); click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-NotificationItem"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Partner1" }); - await contains(".o-mail-NotificationItem .badge", 0, { text: "1" }); + await contains(".o-mail-NotificationItem-name", { text: "Partner1" }); + await contains(".o-mail-NotificationItem .badge", { count: 0, text: "1" }); // simulate receiving a new message const channel = pyEnv["discuss.channel"].searchRead([["id", "=", channelId]])[0]; @@ -889,7 +890,7 @@ QUnit.test("chat should show unread counter on receiving new messages", async () res_id: channelId, }, }); - await contains(".o-mail-NotificationItem .badge", 1, { text: "1" }); + await contains(".o-mail-NotificationItem .badge", { text: "1" }); }); QUnit.test("preview for channel should show latest non-deleted message", async () => { @@ -912,7 +913,7 @@ QUnit.test("preview for channel should show latest non-deleted message", async ( await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-text", 1, { text: "Partner1: message-2" }); + await contains(".o-mail-NotificationItem-text", { text: "Partner1: message-2" }); // Simulate deletion of message-2 await afterNextRender(() => env.services.rpc("/mail/message/update_content", { @@ -921,7 +922,7 @@ QUnit.test("preview for channel should show latest non-deleted message", async ( attachment_ids: [], }) ); - await contains(".o-mail-NotificationItem-text", 1, { text: "Partner1: message-1" }); + await contains(".o-mail-NotificationItem-text", { text: "Partner1: message-1" }); }); QUnit.test("failure notifications are shown before channel preview", async () => { @@ -951,10 +952,10 @@ QUnit.test("failure notifications are shown before channel preview", async () => pyEnv["discuss.channel.member"].write([memberId], { seen_message_id: messageId }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-text", 1, { + await contains(".o-mail-NotificationItem-text", { text: "An error occurred when sending an email", }); - await contains(".o-mail-NotificationItem-text", 1, { text: "Partner1: message" }); + await contains(".o-mail-NotificationItem-text", { text: "Partner1: message" }); await contains( ".o-mail-NotificationItem:contains(An error occurred when sending an email) ~ .o-mail-NotificationItem:contains(message)" ); @@ -965,7 +966,7 @@ QUnit.test("messaging menu should show new needaction messages from chatter", as const partnerId = pyEnv["res.partner"].create({ name: "Frodo Baggins" }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-text", 0, { text: "@Mitchell Admin" }); + await contains(".o-mail-NotificationItem-text", { count: 0, text: "@Mitchell Admin" }); // simulate receiving a new needaction message pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.message/inbox", { author_id: partnerId, @@ -976,5 +977,5 @@ QUnit.test("messaging menu should show new needaction messages from chatter", as res_id: partnerId, record_name: "Frodo Baggins", }); - await contains(".o-mail-NotificationItem-text", 1, { text: "@Mitchell Admin" }); + await contains(".o-mail-NotificationItem-text", { text: "@Mitchell Admin" }); }); diff --git a/addons/mail/static/tests/messaging_menu/notification_tests.js b/addons/mail/static/tests/messaging_menu/notification_tests.js index e5f94265202..bafcc2449e4 100644 --- a/addons/mail/static/tests/messaging_menu/notification_tests.js +++ b/addons/mail/static/tests/messaging_menu/notification_tests.js @@ -30,8 +30,8 @@ QUnit.test("basic layout", async () => { ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Channel" }); - await contains(".o-mail-NotificationItem-counter", 1, { text: "2" }); + await contains(".o-mail-NotificationItem-name", { text: "Channel" }); + await contains(".o-mail-NotificationItem-counter", { text: "2" }); await contains( ".o-mail-NotificationItem:contains(Channel) .o-mail-NotificationItem-date:contains(now)" ); @@ -64,7 +64,7 @@ QUnit.test("mark as read", async () => { "mouseenter" ); await click(".o-mail-NotificationItem:contains(Channel) .o-mail-NotificationItem-markAsRead"); - await contains(".o-mail-NotificationItem-name", 0, { text: "Channel" }); + await contains(".o-mail-NotificationItem-name", { count: 0, text: "Channel" }); }); QUnit.test("open non-channel failure", async (assert) => { @@ -168,7 +168,8 @@ QUnit.test("different discuss.channel are not grouped", async () => { ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-text", 2, { + await contains(".o-mail-NotificationItem-text", { + count: 2, text: "An error occurred when sending an email", }); }); @@ -213,8 +214,8 @@ QUnit.test("multiple grouped notifications by model", async () => { ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 2); - await contains(".o-mail-NotificationItem-counter", 2, { text: "2" }); + await contains(".o-mail-NotificationItem", { count: 2 }); + await contains(".o-mail-NotificationItem-counter", { count: 2, text: "2" }); }); QUnit.test("non-failure notifications are ignored", async () => { @@ -232,7 +233,7 @@ QUnit.test("non-failure notifications are ignored", async () => { }); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test( @@ -257,7 +258,7 @@ QUnit.test( ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem-name", 2); + await contains(".o-mail-NotificationItem-name", { count: 2 }); assert.strictEqual($(".o-mail-NotificationItem-name:eq(0)").text(), "Channel 2020"); assert.strictEqual($(".o-mail-NotificationItem-name:eq(1)").text(), "Channel 2019"); } @@ -283,7 +284,7 @@ QUnit.test("thread notifications are re-ordered on receiving a new message", asy ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); const channel_1 = pyEnv["discuss.channel"].searchRead([["id", "=", channelId_1]])[0]; pyEnv["bus.bus"]._sendone(channel_1, "discuss.channel/new_message", { @@ -299,7 +300,7 @@ QUnit.test("thread notifications are re-ordered on receiving a new message", asy res_id: channelId_1, }, }); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); await contains( ".o-mail-NotificationItem:eq(0) .o-mail-NotificationItem-name:contains(Channel 2019)" ); @@ -333,6 +334,6 @@ QUnit.test( ]); await start(); await contains(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-MessagingMenu-counter", 0); + await contains(".o-mail-MessagingMenu-counter", { count: 0 }); } ); diff --git a/addons/mail/static/tests/mobile/mobile_tests.js b/addons/mail/static/tests/mobile/mobile_tests.js index dbcc3f00741..901bdf6ec87 100644 --- a/addons/mail/static/tests/mobile/mobile_tests.js +++ b/addons/mail/static/tests/mobile/mobile_tests.js @@ -12,9 +12,9 @@ QUnit.test("auto-select 'Inbox' when discuss had channel as active thread", asyn patchUiSize({ height: 360, width: 640 }); const { openDiscuss } = await start(); openDiscuss(channelId, { waitUntilMessagesLoaded: false }); - await contains(".o-mail-MessagingMenu-tab.text-primary.fw-bolder", 1, { text: "Channel" }); + await contains(".o-mail-MessagingMenu-tab.text-primary.fw-bolder", { text: "Channel" }); await click("button", { text: "Mailboxes" }); - await contains(".o-mail-MessagingMenu-tab.text-primary.fw-bolder", 1, { text: "Mailboxes" }); + await contains(".o-mail-MessagingMenu-tab.text-primary.fw-bolder", { text: "Mailboxes" }); await contains("button:contains(Inbox).active"); }); diff --git a/addons/mail/static/tests/suggestion/suggestion_tests.js b/addons/mail/static/tests/suggestion/suggestion_tests.js index 6b30861b3cf..ac717f8ad93 100644 --- a/addons/mail/static/tests/suggestion/suggestion_tests.js +++ b/addons/mail/static/tests/suggestion/suggestion_tests.js @@ -39,7 +39,7 @@ QUnit.test('display partner mention suggestions on typing "@"', async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "@"); - await contains(".o-mail-Composer-suggestion strong", 3); + await contains(".o-mail-Composer-suggestion strong", { count: 3 }); }); QUnit.test( @@ -70,7 +70,7 @@ QUnit.test( await click("button:contains(Send):not(:disabled)"); await contains(".o-mail-Message"); await insertText(".o-mail-Composer-input", "@"); - await contains(".o-mail-Composer-suggestion strong", 3); + await contains(".o-mail-Composer-suggestion strong", { count: 3 }); } ); @@ -80,7 +80,7 @@ QUnit.test('display partner mention suggestions on typing "@" in chatter', async openFormView("res.partner", pyEnv.currentPartnerId); await click("button", { text: "Send message" }); await insertText(".o-mail-Composer-input", "@"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "Mitchell Admin" }); + await contains(".o-mail-Composer-suggestion strong", { text: "Mitchell Admin" }); }); QUnit.test("show other channel member in @ mention", async () => { @@ -99,7 +99,7 @@ QUnit.test("show other channel member in @ mention", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await insertText(".o-mail-Composer-input", "@"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "TestPartner" }); + await contains(".o-mail-Composer-suggestion strong", { text: "TestPartner" }); }); QUnit.test("select @ mention insert mention text in composer", async () => { @@ -119,7 +119,7 @@ QUnit.test("select @ mention insert mention text in composer", async () => { openDiscuss(channelId); await insertText(".o-mail-Composer-input", "@"); await click(".o-mail-Composer-suggestion strong", { text: "TestPartner" }); - await contains(".o-mail-Composer-input", 1, { value: "@TestPartner " }); + await contains(".o-mail-Composer-input", { value: "@TestPartner " }); }); QUnit.test("select @ mention closes suggestions", async () => { @@ -139,7 +139,7 @@ QUnit.test("select @ mention closes suggestions", async () => { openDiscuss(channelId); await insertText(".o-mail-Composer-input", "@"); await click(".o-mail-Composer-suggestion strong", { text: "TestPartner" }); - await contains(".o-mail-Composer-suggestion strong", 0); + await contains(".o-mail-Composer-suggestion strong", { count: 0 }); }); QUnit.test('display channel mention suggestions on typing "#"', async () => { @@ -151,7 +151,7 @@ QUnit.test('display channel mention suggestions on typing "#"', async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); await insertText(".o-mail-Composer-input", "#"); await contains(".o-mail-Composer-suggestionList .o-open"); }); @@ -165,11 +165,11 @@ QUnit.test("mention a channel", async () => { const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Composer-suggestionList"); - await contains(".o-mail-Composer-suggestionList .o-open", 0); - await contains(".o-mail-Composer-input", 1, { value: "" }); + await contains(".o-mail-Composer-suggestionList .o-open", { count: 0 }); + await contains(".o-mail-Composer-input", { value: "" }); await insertText(".o-mail-Composer-input", "#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "#General " }); + await contains(".o-mail-Composer-input", { value: "#General " }); }); QUnit.test("Channel suggestions do not crash after rpc returns", async (assert) => { @@ -204,9 +204,9 @@ QUnit.test("Suggestions are shown after delimiter was used in text (@)", async ( await insertText(".o-mail-Composer-input", "@"); await contains(".o-mail-Composer-suggestion"); await insertText(".o-mail-Composer-input", "NonExistingUser"); - await contains(".o-mail-Composer-suggestion strong", 0); + await contains(".o-mail-Composer-suggestion strong", { count: 0 }); await insertText(".o-mail-Composer-input", " @"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "Mitchell Admin" }); + await contains(".o-mail-Composer-suggestion strong", { text: "Mitchell Admin" }); }); QUnit.test("Suggestions are shown after delimiter was used in text (#)", async () => { @@ -217,9 +217,9 @@ QUnit.test("Suggestions are shown after delimiter was used in text (#)", async ( await insertText(".o-mail-Composer-input", "#"); await contains(".o-mail-Composer-suggestion"); await insertText(".o-mail-Composer-input", "NonExistingChannel"); - await contains(".o-mail-Composer-suggestion strong", 0); + await contains(".o-mail-Composer-suggestion strong", { count: 0 }); await insertText(".o-mail-Composer-input", " #"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "#General" }); + await contains(".o-mail-Composer-suggestion strong", { text: "#General" }); }); QUnit.test("display partner mention when typing more than 2 words if they match", async () => { @@ -242,10 +242,10 @@ QUnit.test("display partner mention when typing more than 2 words if they match" openFormView("res.partner", pyEnv.currentPartnerId); await click("button", { text: "Send message" }); await insertText(".o-mail-Composer-input", "@My "); - await contains(".o-mail-Composer-suggestion strong", 3); + await contains(".o-mail-Composer-suggestion strong", { count: 3 }); await insertText(".o-mail-Composer-input", "Test "); - await contains(".o-mail-Composer-suggestion strong", 2); + await contains(".o-mail-Composer-suggestion strong", { count: 2 }); await insertText(".o-mail-Composer-input", "Partner"); await contains(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-suggestion strong", 1, { text: "My Test Partner" }); + await contains(".o-mail-Composer-suggestion strong", { text: "My Test Partner" }); }); diff --git a/addons/mail/static/tests/thread/attachment_list_tests.js b/addons/mail/static/tests/thread/attachment_list_tests.js index 9821484f3df..88133fb71fc 100644 --- a/addons/mail/static/tests/thread/attachment_list_tests.js +++ b/addons/mail/static/tests/thread/attachment_list_tests.js @@ -31,7 +31,7 @@ QUnit.test("simplest layout", async (assert) => { await contains(".o-mail-AttachmentCard-image"); assert.hasClass($(".o-mail-AttachmentCard-image"), "o_image"); // required for mimetype.scss style assert.hasAttrValue($(".o-mail-AttachmentCard-image"), "data-mimetype", "text/plain"); // required for mimetype.scss style - await contains(".o-mail-AttachmentCard-aside button", 2); + await contains(".o-mail-AttachmentCard-aside button", { count: 2 }); await contains(".o-mail-AttachmentCard-unlink"); await contains(".o-mail-AttachmentCard-aside button[title='Download']"); }); @@ -55,8 +55,8 @@ QUnit.test("layout with card details and filename and extension", async () => { }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-AttachmentCard div", 1, { text: "test.txt" }); - await contains(".o-mail-AttachmentCard small", 1, { text: "txt" }); + await contains(".o-mail-AttachmentCard div", { text: "test.txt" }); + await contains(".o-mail-AttachmentCard small", { text: "txt" }); }); QUnit.test( @@ -90,7 +90,7 @@ QUnit.test( click(".modal-footer .btn-primary"); click(".modal-footer .btn-primary"); click(".modal-footer .btn-primary"); - await contains(".o-mail-AttachmentCard-unlink", 0); + await contains(".o-mail-AttachmentCard-unlink", { count: 0 }); assert.verifySteps(["attachment_unlink"], "The unlink method must be called once"); } ); @@ -144,7 +144,7 @@ QUnit.test("close attachment viewer", async () => { await contains(".o-FileViewer"); await click(".o-FileViewer div[aria-label='Close']"); - await contains(".o-FileViewer", 0); + await contains(".o-FileViewer", { count: 0 }); }); QUnit.test( @@ -309,13 +309,13 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-AttachmentImage[title='test.png']"); - await contains(".o-mail-AttachmentCard div", 1, { text: "test.odt" }); + await contains(".o-mail-AttachmentCard div", { text: "test.odt" }); assert.hasClass($(".o-mail-AttachmentImage[title='test.png'] img"), "o-viewable"); assert.doesNotHaveClass($(".o-mail-AttachmentCard:contains(test.odt)"), "o-viewable"); click(".o-mail-AttachmentCard:contains(test.odt)").catch(() => {}); await nextTick(); - await contains(".o-FileViewer", 0); + await contains(".o-FileViewer", { count: 0 }); await click(".o-mail-AttachmentImage[title='test.png']"); await contains(".o-FileViewer"); diff --git a/addons/mail/static/tests/thread/thread_tests.js b/addons/mail/static/tests/thread/thread_tests.js index 33206c54a56..b052bd06ea2 100644 --- a/addons/mail/static/tests/thread/thread_tests.js +++ b/addons/mail/static/tests/thread/thread_tests.js @@ -51,11 +51,11 @@ QUnit.test("load more messages from channel (auto-load on scroll)", async () => } const { openDiscuss } = await start(); openDiscuss(channelId); - await contains("button:contains(Load More) ~ .o-mail-Message", 30); - await contains(".o-mail-Message", 30); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains("button:contains(Load More) ~ .o-mail-Message", { count: 30 }); + await contains(".o-mail-Message", { count: 30 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", 0); - await contains(".o-mail-Message", 60); + await contains(".o-mail-Message", { count: 60 }); }); QUnit.test("show message subject when subject is not the same as the thread name", async () => { @@ -73,7 +73,7 @@ QUnit.test("show message subject when subject is not the same as the thread name }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message .o-mail-Message-content", { text: "Subject: Salutations, voyageurnot empty", }); }); @@ -93,10 +93,11 @@ QUnit.test("do not show message subject when subject is the same as the thread n }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message .o-mail-Message-content", { text: "not empty", }); - await contains(".o-mail-Message .o-mail-Message-content", 0, { + await contains(".o-mail-Message .o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); }); @@ -113,8 +114,8 @@ QUnit.test("auto-scroll to bottom of thread on load", async () => { } const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 25); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 25 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); }); QUnit.test("display day separator before first message of the day", async () => { @@ -148,7 +149,7 @@ QUnit.test("do not display day separator if all messages of the day are empty", const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Thread-empty"); - await contains(".o-mail-DateSection", 0); + await contains(".o-mail-DateSection", { count: 0 }); }); QUnit.test("scroll position is kept when navigating from one channel to another", async () => { @@ -169,21 +170,21 @@ QUnit.test("scroll position is kept when navigating from one channel to another" ); const { openDiscuss } = await start(); openDiscuss(channelId_1); - await contains(".o-mail-Message", 20); + await contains(".o-mail-Message", { count: 20 }); const scrollValue1 = $(".o-mail-Thread")[0].scrollHeight / 2; - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", scrollValue1); await click(".o-mail-DiscussSidebarChannel span", { text: "channel-2" }); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); const scrollValue2 = $(".o-mail-Thread")[0].scrollHeight / 3; - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", scrollValue2); await click(".o-mail-DiscussSidebarChannel span", { text: "channel-1" }); - await contains(".o-mail-Message", 20); - await contains(".o-mail-Thread", 1, { scroll: scrollValue1 }); + await contains(".o-mail-Message", { count: 20 }); + await contains(".o-mail-Thread", { scroll: scrollValue1 }); await click(".o-mail-DiscussSidebarChannel span", { text: "channel-2" }); - await contains(".o-mail-Message", 30); - await contains(".o-mail-Thread", 1, { scroll: scrollValue2 }); + await contains(".o-mail-Message", { count: 30 }); + await contains(".o-mail-Thread", { scroll: scrollValue2 }); }); QUnit.test("thread is still scrolling after scrolling up then to bottom", async () => { @@ -201,14 +202,14 @@ QUnit.test("thread is still scrolling after scrolling up then to bottom", async ); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Message", 20); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 20 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", $(".o-mail-Thread")[0].scrollHeight / 2); await scroll(".o-mail-Thread", "bottom"); await insertText(".o-mail-Composer-input", "123"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message", 21); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 21 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); }); QUnit.test("mention a channel with space in the name", async () => { @@ -218,9 +219,9 @@ QUnit.test("mention a channel with space in the name", async () => { openDiscuss(channelId); await insertText(".o-mail-Composer-input", "#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "#General good boy " }); + await contains(".o-mail-Composer-input", { value: "#General good boy " }); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-body .o_channel_redirect", 1, { text: "#General good boy" }); + await contains(".o-mail-Message-body .o_channel_redirect", { text: "#General good boy" }); }); QUnit.test('mention a channel with "&" in the name', async () => { @@ -230,9 +231,9 @@ QUnit.test('mention a channel with "&" in the name', async () => { openDiscuss(channelId); await insertText(".o-mail-Composer-input", "#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "#General & good " }); + await contains(".o-mail-Composer-input", { value: "#General & good " }); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-body .o_channel_redirect", 1, { text: "#General & good" }); + await contains(".o-mail-Message-body .o_channel_redirect", { text: "#General & good" }); }); QUnit.test( @@ -274,9 +275,9 @@ QUnit.test( ); await contains(".o-mail-Message"); assert.verifySteps(["rpc:channel_fetch"]); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); $(".o-mail-Composer-input")[0].focus(); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); assert.verifySteps(["rpc:set_last_seen_message"]); } @@ -346,8 +347,8 @@ QUnit.test( const { env } = await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message", 11); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 11 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); // simulate receiving a message pyEnv.withUser(userId, () => env.services.rpc("/mail/message/post", { @@ -356,8 +357,8 @@ QUnit.test( thread_model: "discuss.channel", }) ); - await contains(".o-mail-Message", 12); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 12 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); } ); @@ -383,8 +384,8 @@ QUnit.test( const { env } = await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem"); - await contains(".o-mail-Message", 11); - await contains(".o-mail-Thread", 1, { scroll: "bottom" }); + await contains(".o-mail-Message", { count: 11 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); await scroll(".o-mail-Thread", 0); // simulate receiving a message pyEnv.withUser(userId, () => @@ -394,8 +395,8 @@ QUnit.test( thread_model: "discuss.channel", }) ); - await contains(".o-mail-Message", 12); - await contains(".o-mail-ChatWindow .o-mail-Thread", 1, { scroll: 0 }); + await contains(".o-mail-Message", { count: 12 }); + await contains(".o-mail-ChatWindow .o-mail-Thread", { scroll: 0 }); } ); @@ -404,10 +405,10 @@ QUnit.test("show empty placeholder when thread contains no message", async () => const channelId = pyEnv["discuss.channel"].create({ name: "general" }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Thread .o-mail-Thread-empty", 1, { + await contains(".o-mail-Thread .o-mail-Thread-empty", { text: "There are no messages in this conversation.", }); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test("show empty placeholder when thread contains only empty messages", async () => { @@ -416,10 +417,10 @@ QUnit.test("show empty placeholder when thread contains only empty messages", as pyEnv["mail.message"].create({ model: "discuss.channel", res_id: channelId }); const { openDiscuss } = await start(); openDiscuss(channelId); - await contains(".o-mail-Thread .o-mail-Thread-empty", 1, { + await contains(".o-mail-Thread .o-mail-Thread-empty", { text: "There are no messages in this conversation.", }); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test( @@ -444,8 +445,8 @@ QUnit.test( const { openDiscuss } = await start(); openDiscuss(channelId); // initial load: +30 empty ; (auto) load more: +20 empty +10 non-empty - await contains(".o-mail-Message", 10); - await contains("button", 1, { text: "Load More" }); // still 40 non-empty + await contains(".o-mail-Message", { count: 10 }); + await contains("button", { text: "Load More" }); // still 40 non-empty } ); @@ -471,14 +472,14 @@ QUnit.test("no new messages separator on posting message (some message history)" const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); await insertText(".o-mail-Composer-input", "hey!"); // need to remove focus from text area to avoid set_last_seen_message (await contains(".o-mail-Composer-send:not(:disabled)"))[0].focus(); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); }); QUnit.test("new messages separator on receiving new message [REQUIRE FOCUS]", async () => { @@ -510,7 +511,7 @@ QUnit.test("new messages separator on receiving new message [REQUIRE FOCUS]", as const { env, openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Message"); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); $(".o-mail-Composer-input")[0].blur(); // simulate receiving a message @@ -523,15 +524,15 @@ QUnit.test("new messages separator on receiving new message [REQUIRE FOCUS]", as }) ) ); - await contains(".o-mail-Message", 2); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); - await contains(".o-mail-Thread-newMessage ~ .o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message", { count: 2 }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); + await contains(".o-mail-Thread-newMessage ~ .o-mail-Message .o-mail-Message-content", { text: "hu", }); $(".o-mail-Composer-input")[0].focus(); await nextTick(); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); }); QUnit.test("no new messages separator on posting message (no message history)", async () => { @@ -546,13 +547,13 @@ QUnit.test("no new messages separator on posting message (no message history)", const { openDiscuss } = await start(); openDiscuss(channelId); await contains(".o-mail-Composer-input"); - await contains(".o-mail-Message", 0); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Message", { count: 0 }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); await insertText(".o-mail-Composer-input", "hey!"); await click(".o-mail-Composer-send:not(:disabled)"); await contains(".o-mail-Message"); - await contains(".o-mail-Thread-newMessage hr + span", 0, { text: "New messages" }); + await contains(".o-mail-Thread-newMessage hr + span", { count: 0, text: "New messages" }); }); QUnit.test("Mention a partner with special character (e.g. apostrophe ')", async () => { @@ -573,7 +574,7 @@ QUnit.test("Mention a partner with special character (e.g. apostrophe ')", async await insertText(".o-mail-Composer-input", "@"); await insertText(".o-mail-Composer-input", "Pyn"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "@Pynya's spokesman " }); + await contains(".o-mail-Composer-input", { value: "@Pynya's spokesman " }); await click(".o-mail-Composer-send:not(:disabled)"); await contains( `.o-mail-Message-body .o_mail_redirect[data-oe-id="${partnerId}"][data-oe-model="res.partner"]:contains("@Pynya's spokesman")` @@ -604,10 +605,10 @@ QUnit.test("mention 2 different partners that have the same name", async () => { openDiscuss(channelId); await insertText(".o-mail-Composer-input", "@Te"); await click(".o-mail-Composer-suggestion:eq(0)"); - await contains(".o-mail-Composer-input", 1, { value: "@TestPartner " }); + await contains(".o-mail-Composer-input", { value: "@TestPartner " }); await insertText(".o-mail-Composer-input", "@Te"); await click(".o-mail-Composer-suggestion:eq(1)"); - await contains(".o-mail-Composer-input", 1, { value: "@TestPartner @TestPartner " }); + await contains(".o-mail-Composer-input", { value: "@TestPartner @TestPartner " }); await click(".o-mail-Composer-send:not(:disabled)"); await contains( `.o-mail-Message-body .o_mail_redirect[data-oe-id="${partnerId_1}"][data-oe-model="res.partner"]:contains("@TestPartner")` @@ -624,9 +625,9 @@ QUnit.test("mention a channel on a second line when the first line contains #", openDiscuss(channelId); await insertText(".o-mail-Composer-input", "#blabla\n#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "#blabla\n#General good " }); + await contains(".o-mail-Composer-input", { value: "#blabla\n#General good " }); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-body .o_channel_redirect", 1, { text: "#General good" }); + await contains(".o-mail-Message-body .o_channel_redirect", { text: "#General good" }); }); QUnit.test( @@ -638,12 +639,12 @@ QUnit.test( openDiscuss(channelId); await insertText(".o-mail-Composer-input", "#"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "#General good " }); + await contains(".o-mail-Composer-input", { value: "#General good " }); const text = $(".o-mail-Composer-input").val(); $(".o-mail-Composer-input").val(text.slice(0, -1)); await insertText(".o-mail-Composer-input", ", test"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message-body .o_channel_redirect", 1, { text: "#General good" }); + await contains(".o-mail-Message-body .o_channel_redirect", { text: "#General good" }); } ); @@ -664,10 +665,10 @@ QUnit.test("mention 2 different channels that have the same name", async () => { openDiscuss(channelId_1); await insertText(".o-mail-Composer-input", "#m"); await click(".o-mail-Composer-suggestion:eq(0)"); - await contains(".o-mail-Composer-input", 1, { value: "#my channel " }); + await contains(".o-mail-Composer-input", { value: "#my channel " }); await insertText(".o-mail-Composer-input", "#m"); await click(".o-mail-Composer-suggestion:eq(1)"); - await contains(".o-mail-Composer-input", 1, { value: "#my channel #my channel " }); + await contains(".o-mail-Composer-input", { value: "#my channel #my channel " }); await click(".o-mail-Composer-send:not(:disabled)"); await contains( `.o-mail-Message-body .o_channel_redirect[data-oe-id="${channelId_1}"][data-oe-model="discuss.channel"]:contains("#my channel")` @@ -696,7 +697,7 @@ QUnit.test( openDiscuss(channelId); await insertText(".o-mail-Composer-input", "email@odoo.com\n@Te"); await click(".o-mail-Composer-suggestion"); - await contains(".o-mail-Composer-input", 1, { value: "email@odoo.com\n@TestPartner " }); + await contains(".o-mail-Composer-input", { value: "email@odoo.com\n@TestPartner " }); await click(".o-mail-Composer-send:not(:disabled)"); await contains( `.o-mail-Message-body .o_mail_redirect[data-oe-id="${partnerId}"][data-oe-model="res.partner"]:contains("@TestPartner")` @@ -728,7 +729,7 @@ QUnit.test("basic rendering of canceled notification", async () => { await click(".o-mail-Message-notification"); await contains(".o-mail-MessageNotificationPopover"); await contains(".o-mail-MessageNotificationPopover .fa-trash-o"); - await contains(".o-mail-MessageNotificationPopover", 1, { text: "Someone" }); + await contains(".o-mail-MessageNotificationPopover", { text: "Someone" }); }); QUnit.test( @@ -765,7 +766,7 @@ QUnit.test( // send a command that leads to receiving a transient message await insertText(".o-mail-Composer-input", "/who"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); // composer is focused by default, we remove that focus $(".o-mail-Composer-input")[0].blur(); // simulate receiving a message @@ -776,8 +777,8 @@ QUnit.test( thread_model: "discuss.channel", }) ); - await contains(".o-mail-Message", 3); - await contains(".o-mail-Thread-newMessage hr + span", 1, { text: "New messages" }); + await contains(".o-mail-Message", { count: 3 }); + await contains(".o-mail-Thread-newMessage hr + span", { text: "New messages" }); await contains(".o-mail-Message[aria-label='Note'] + .o-mail-Thread-newMessage"); } ); @@ -815,7 +816,7 @@ QUnit.test("chat window header should not have unread counter for non-channel th await start(); await click(".o_menu_systray i[aria-label='Messages']"); await click(".o-mail-NotificationItem-name"); - await contains(".o-mail-ChatWindow-counter", 0, { text: "1" }); + await contains(".o-mail-ChatWindow-counter", { count: 0, text: "1" }); }); QUnit.test( @@ -852,7 +853,7 @@ QUnit.test( }); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-NotificationItem"); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-ChatWindow", { count: 0 }); await click(".o-mail-NotificationItem"); await contains(".o-mail-ChatWindow"); @@ -884,11 +885,11 @@ QUnit.test("Thread messages are only loaded once", async (assert) => { ]); openDiscuss(); await click(".o-mail-DiscussSidebarChannel:eq(0)"); - await contains(".o-mail-Message-content", 1, { text: "Message on channel1" }); + await contains(".o-mail-Message-content", { text: "Message on channel1" }); await click(".o-mail-DiscussSidebarChannel:eq(1)"); - await contains(".o-mail-Message-content", 1, { text: "Message on channel2" }); + await contains(".o-mail-Message-content", { text: "Message on channel2" }); await click(".o-mail-DiscussSidebarChannel:eq(0)"); - await contains(".o-mail-Message-content", 1, { text: "Message on channel1" }); + await contains(".o-mail-Message-content", { text: "Message on channel1" }); assert.verifySteps([`load messages - ${channelIds[0]}`, `load messages - ${channelIds[1]}`]); }); @@ -913,7 +914,7 @@ QUnit.test( // ensure focusout is triggered on composers' textarea triggerEvents((await contains(".o-mail-Composer-input"))[0], null, ["blur", "focusout"]); await click("button div", { text: "Inbox" }); - await contains("h4", 1, { text: "Congratulations, your inbox is empty" }); + await contains("h4", { text: "Congratulations, your inbox is empty" }); const messageId = pyEnv["mail.message"].create({ author_id: partnerId, body: "@Mitchel Admin", @@ -933,10 +934,10 @@ QUnit.test( [messageId], ]); pyEnv["bus.bus"]._sendone(pyEnv.currentPartner, "mail.message/inbox", formattedMessage); - await contains("button:contains(Inbox) .badge", 1, { text: "1" }); + await contains("button:contains(Inbox) .badge", { text: "1" }); await click("button span", { text: "General" }); - await contains(".o-discuss-badge", 0); - await contains("button:contains(Inbox) .badge", 0); + await contains(".o-discuss-badge", { count: 0 }); + await contains("button:contains(Inbox) .badge", { count: 0 }); assert.verifySteps(["mark-all-messages-as-read"]); } ); @@ -994,10 +995,10 @@ QUnit.test("can be marked as read while loading", async function () { }, }); openDiscuss(undefined, { waitUntilMessagesLoaded: false }); - await contains(".o-discuss-badge", 1, { text: "1" }); + await contains(".o-discuss-badge", { text: "1" }); await click(".o-mail-DiscussSidebarChannel span", { text: "Demo" }); await afterNextRender(loadDeferred.resolve); - await contains(".o-discuss-badge", 0); + await contains(".o-discuss-badge", { count: 0 }); }); QUnit.test("New message separator not appearing after showing composer on thread", async () => { @@ -1016,10 +1017,10 @@ QUnit.test("New message separator not appearing after showing composer on thread ]); const { openFormView } = await start(); openFormView("res.partner", pyEnv.currentPartnerId); - await contains("button", 1, { text: "Log note" }); - await contains(".o-mail-Thread-newMessage", 0); + await contains("button", { text: "Log note" }); + await contains(".o-mail-Thread-newMessage", { count: 0 }); await click("button", { text: "Log note" }); - await contains(".o-mail-Thread-newMessage", 0); + await contains(".o-mail-Thread-newMessage", { count: 0 }); }); QUnit.test("Transient messages are added at the end of the thread", async (assert) => { @@ -1032,7 +1033,7 @@ QUnit.test("Transient messages are added at the end of the thread", async (asser await contains(".o-mail-Message"); await insertText(".o-mail-Composer-input", "/help"); await click(".o-mail-Composer-send:not(:disabled)"); - await contains(".o-mail-Message", 2); + await contains(".o-mail-Message", { count: 2 }); const lastMessage = document.querySelectorAll(".o-mail-Message")[1]; assert.ok(lastMessage.innerText.includes("You are in channel #General")); }); diff --git a/addons/mail/static/tests/web/activity/activity_widget_tests.js b/addons/mail/static/tests/web/activity/activity_widget_tests.js index 7a11ee81313..b2d4226a55a 100644 --- a/addons/mail/static/tests/web/activity/activity_widget_tests.js +++ b/addons/mail/static/tests/web/activity/activity_widget_tests.js @@ -41,7 +41,7 @@ QUnit.test("list activity widget with no activity", async (assert) => { views: [[false, "list"]], }); await contains(".o-mail-ActivityButton i.text-muted"); - await contains(".o-mail-ListActivity-summary:eq(0)", 1, { text: "" }); + await contains(".o-mail-ListActivity-summary:eq(0)", { text: "" }); assert.verifySteps(["/web/dataset/call_kw/res.users/web_search_read"]); }); @@ -141,7 +141,7 @@ QUnit.test("list activity widget with exception", async (assert) => { views: [[false, "list"]], }); await contains(".o-mail-ActivityButton i.text-warning.fa-warning"); - await contains(".o-mail-ListActivity-summary:eq(0)", 1, { text: "Warning" }); + await contains(".o-mail-ListActivity-summary:eq(0)", { text: "Warning" }); assert.verifySteps(["/web/dataset/call_kw/res.users/web_search_read"]); }); @@ -220,12 +220,12 @@ QUnit.test("list activity widget: open dropdown", async (assert) => { res_model: "res.users", views: [[false, "list"]], }); - await contains(".o-mail-ListActivity-summary:eq(0)", 1, { text: "Call with Al" }); + await contains(".o-mail-ListActivity-summary:eq(0)", { text: "Call with Al" }); await click(".o-mail-ActivityButton"); // open the popover await click(".o-mail-ActivityListPopoverItem-markAsDone:eq(0)"); // mark the first activity as done await click(".o-mail-ActivityMarkAsDone button[aria-label='Done']"); // confirm - await contains(".o-mail-ListActivity-summary:eq(0)", 1, { text: "Meet FP" }); + await contains(".o-mail-ListActivity-summary:eq(0)", { text: "Meet FP" }); assert.verifySteps(["web_search_read", "activity_format", "action_feedback", "web_read"]); }); @@ -275,7 +275,9 @@ QUnit.test("list activity exception widget with activity", async () => { res_model: "res.users", views: [[false, "list"]], }); - await contains(".o_data_row", 2); - await contains(".o_data_row .o_activity_exception_cell:eq(0) .o-mail-ActivityException", 0); + await contains(".o_data_row", { count: 2 }); + await contains(".o_data_row .o_activity_exception_cell:eq(0) .o-mail-ActivityException", { + count: 0, + }); await contains(".o_data_row .o_activity_exception_cell:eq(1) .o-mail-ActivityException"); }); diff --git a/addons/mail/static/tests/web/attachment_box_tests.js b/addons/mail/static/tests/web/attachment_box_tests.js index c81ef002e6a..28489b58e19 100644 --- a/addons/mail/static/tests/web/attachment_box_tests.js +++ b/addons/mail/static/tests/web/attachment_box_tests.js @@ -25,8 +25,8 @@ QUnit.test("base empty rendering", async () => { views: [[false, "form"]], }); await contains(".o-mail-AttachmentBox"); - await contains("button", 1, { text: "Attach files" }); - await contains(".o-mail-Chatter .o-mail-AttachmentImage", 0); + await contains("button", { text: "Attach files" }); + await contains(".o-mail-Chatter .o-mail-AttachmentImage", { count: 0 }); }); QUnit.test("base non-empty rendering", async () => { @@ -63,7 +63,7 @@ QUnit.test("base non-empty rendering", async () => { views: [[false, "form"]], }); await contains(".o-mail-AttachmentBox"); - await contains("button", 1, { text: "Attach files" }); + await contains("button", { text: "Attach files" }); await contains(".o-mail-Chatter input[type='file']"); await contains(".o-mail-AttachmentList"); }); @@ -97,11 +97,11 @@ QUnit.test("remove attachment should ask for confirmation", async () => { await contains("button[title='Remove']"); await click("button[title='Remove']"); - await contains(".modal-body", 1, { text: 'Do you really want to delete "Blah.txt"?' }); + await contains(".modal-body", { text: 'Do you really want to delete "Blah.txt"?' }); // Confirm the deletion await click(".modal-footer .btn-primary"); - await contains(".o-mail-AttachmentImage", 0); + await contains(".o-mail-AttachmentImage", { count: 0 }); }); QUnit.test("view attachments", async () => { @@ -137,15 +137,15 @@ QUnit.test("view attachments", async () => { }); await click('.o-mail-AttachmentCard[aria-label="Blah.txt"] .o-mail-AttachmentCard-image'); await contains(".o-FileViewer"); - await contains(".o-FileViewer-header span", 1, { text: "Blah.txt" }); + await contains(".o-FileViewer-header span", { text: "Blah.txt" }); await contains(".o-FileViewer div[aria-label='Next']"); await click(".o-FileViewer div[aria-label='Next']"); - await contains(".o-FileViewer-header span", 1, { text: "Blu.txt" }); + await contains(".o-FileViewer-header span", { text: "Blu.txt" }); await contains(".o-FileViewer div[aria-label='Next']"); await click(".o-FileViewer div[aria-label='Next']"); - await contains(".o-FileViewer-header span", 1, { text: "Blah.txt" }); + await contains(".o-FileViewer-header span", { text: "Blah.txt" }); }); QUnit.test("scroll to attachment box when toggling on", async (assert) => { @@ -171,11 +171,11 @@ QUnit.test("scroll to attachment box when toggling on", async (assert) => { res_model: "res.partner", views: [[false, "form"]], }); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); await scroll(".o-mail-Chatter", "bottom"); await click("button[aria-label='Attach files']"); await contains(".o-mail-AttachmentBox"); - await contains(".o-mail-Chatter", 1, { scroll: 0 }); + await contains(".o-mail-Chatter", { scroll: 0 }); assert.isVisible($(".o-mail-AttachmentBox")); }); @@ -194,9 +194,9 @@ QUnit.test("attachment box should order attachments from newest to oldest", asyn res_model: "res.partner", views: [[false, "form"]], }); - await contains(".o-mail-Chatter [aria-label='Attach files']", 1, { text: "3" }); + await contains(".o-mail-Chatter [aria-label='Attach files']", { text: "3" }); await click(".o-mail-Chatter [aria-label='Attach files']"); // open attachment box - await contains(".o-mail-AttachmentCard:eq(0) div", 1, { text: "C.txt" }); - await contains(".o-mail-AttachmentCard:eq(1) div", 1, { text: "B.txt" }); - await contains(".o-mail-AttachmentCard:eq(2) div", 1, { text: "A.txt" }); + await contains(".o-mail-AttachmentCard:eq(0) div", { text: "C.txt" }); + await contains(".o-mail-AttachmentCard:eq(1) div", { text: "B.txt" }); + await contains(".o-mail-AttachmentCard:eq(2) div", { text: "A.txt" }); }); diff --git a/addons/mail/static/tests/web/chatter_tests.js b/addons/mail/static/tests/web/chatter_tests.js index 15efc4d9469..4bc262bca6a 100644 --- a/addons/mail/static/tests/web/chatter_tests.js +++ b/addons/mail/static/tests/web/chatter_tests.js @@ -68,14 +68,14 @@ QUnit.test("can post a message on a record thread", async (assert) => { }, }); openFormView("res.partner", partnerId); - await contains("button", 1, { text: "Send message" }); - await contains(".o-mail-Composer", 0); + await contains("button", { text: "Send message" }); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Send message" }); await contains(".o-mail-Composer"); await insertText(".o-mail-Composer-input", "hey"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); await click(".o-mail-Composer button:contains(Send):not(:disabled)"); await contains(".o-mail-Message"); @@ -109,14 +109,14 @@ QUnit.test("can post a note on a record thread", async (assert) => { }, }); openFormView("res.partner", partnerId); - await contains("button", 1, { text: "Log note" }); - await contains(".o-mail-Composer", 0); + await contains("button", { text: "Log note" }); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Log note" }); await contains(".o-mail-Composer"); await insertText(".o-mail-Composer-input", "hey"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); await click(".o-mail-Composer button:contains(Log):not(:disabled)"); await contains(".o-mail-Message"); @@ -127,7 +127,7 @@ QUnit.test("No attachment loading spinner when creating records", async () => { const { openFormView } = await start(); openFormView("res.partner"); await contains("button[aria-label='Attach files']"); - await contains("button[aria-label='Attach files'] .fa-spin", 0); + await contains("button[aria-label='Attach files'] .fa-spin", { count: 0 }); }); QUnit.test( @@ -147,7 +147,7 @@ QUnit.test( await advanceTime(DELAY_FOR_SPINNER); await contains("button[aria-label='Attach files'] .fa-spin"); await click(".o_form_button_create:eq(0)"); - await contains("button[aria-label='Attach files'] .fa-spin", 0); + await contains("button[aria-label='Attach files'] .fa-spin", { count: 0 }); } ); @@ -174,7 +174,7 @@ QUnit.test("Textarea content is kept when switching from aside to bottom", async patchUiSize({ size: SIZES.LG }); window.dispatchEvent(new Event("resize")); await contains(".o-mail-Form-chatter:not(.o-aside) .o-mail-Composer-input"); - await contains(".o-mail-Composer-input", 1, { value: "Hello world !" }); + await contains(".o-mail-Composer-input", { value: "Hello world !" }); }); QUnit.test("Composer type is kept when switching from aside to bottom", async (assert) => { @@ -217,10 +217,10 @@ QUnit.test("chatter: drop attachments", async (assert) => { ]; await afterNextRender(() => dragenterFiles($(".o-mail-Chatter")[0])); await contains(".o-mail-Dropzone"); - await contains(".o-mail-AttachmentCard", 0); + await contains(".o-mail-AttachmentCard", { count: 0 }); await afterNextRender(() => dropFiles($(".o-mail-Dropzone")[0], files)); - await contains(".o-mail-AttachmentCard", 2); + await contains(".o-mail-AttachmentCard", { count: 2 }); await afterNextRender(() => dragenterFiles($(".o-mail-Chatter")[0])); files = [ @@ -231,7 +231,7 @@ QUnit.test("chatter: drop attachments", async (assert) => { }), ]; await afterNextRender(() => dropFiles($(".o-mail-Dropzone")[0], files)); - await contains(".o-mail-AttachmentCard", 3); + await contains(".o-mail-AttachmentCard", { count: 3 }); }); QUnit.test("should display subject when subject isn't infered from the record", async () => { @@ -249,7 +249,7 @@ QUnit.test("should display subject when subject isn't infered from the record", res_model: "res.partner", views: [[false, "form"]], }); - await contains(".o-mail-Message-content", 1, { + await contains(".o-mail-Message-content", { text: "Subject: Salutations, voyageurnot empty", }); }); @@ -269,7 +269,7 @@ QUnit.test("should not display user notification messages in chatter", async () views: [[false, "form"]], }); await contains(".o-mail-Thread-empty"); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test('post message with "CTRL-Enter" keyboard shortcut in chatter', async () => { @@ -282,7 +282,7 @@ QUnit.test('post message with "CTRL-Enter" keyboard shortcut in chatter', async views: [[false, "form"]], }); await click("button", { text: "Send message" }); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); await insertText(".o-mail-Composer-input", "Test"); triggerHotkey("control+Enter"); await contains(".o-mail-Message"); @@ -306,9 +306,9 @@ QUnit.test("base rendering when chatter has no attachment", async (assert) => { }); await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); - await contains(".o-mail-AttachmentBox", 0); + await contains(".o-mail-AttachmentBox", { count: 0 }); await contains(".o-mail-Thread"); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); }); QUnit.test("base rendering when chatter has no record", async (assert) => { @@ -319,14 +319,14 @@ QUnit.test("base rendering when chatter has no record", async (assert) => { }); await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); - await contains(".o-mail-AttachmentBox", 0); + await contains(".o-mail-AttachmentBox", { count: 0 }); await contains(".o-mail-Chatter .o-mail-Thread"); await contains(".o-mail-Message"); assert.strictEqual($(".o-mail-Message-body").text(), "Creating a new record..."); - await contains("button", 0, { text: "Load More" }); + await contains("button", { count: 0, text: "Load More" }); await contains(".o-mail-Message-actions"); - await contains(".o-mail-Message-actions i", 0); + await contains(".o-mail-Message-actions i", { count: 0 }); }); QUnit.test("base rendering when chatter has attachments", async () => { @@ -354,7 +354,7 @@ QUnit.test("base rendering when chatter has attachments", async () => { }); await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); - await contains(".o-mail-AttachmentBox", 0); + await contains(".o-mail-AttachmentBox", { count: 0 }); }); QUnit.test("show attachment box", async () => { @@ -383,8 +383,8 @@ QUnit.test("show attachment box", async () => { await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); await contains("button[aria-label='Attach files']"); - await contains("button[aria-label='Attach files']", 1, { text: "2" }); - await contains(".o-mail-AttachmentBox", 0); + await contains("button[aria-label='Attach files']", { text: "2" }); + await contains(".o-mail-AttachmentBox", { count: 0 }); await click("button[aria-label='Attach files']"); await contains(".o-mail-AttachmentBox"); @@ -399,9 +399,9 @@ QUnit.test("composer show/hide on log note/send message [REQUIRE FOCUS]", async res_model: "res.partner", views: [[false, "form"]], }); - await contains("button", 1, { text: "Send message" }); - await contains("button", 1, { text: "Log note" }); - await contains(".o-mail-Composer", 0); + await contains("button", { text: "Send message" }); + await contains("button", { text: "Log note" }); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Send message" }); await contains(".o-mail-Composer"); @@ -412,13 +412,13 @@ QUnit.test("composer show/hide on log note/send message [REQUIRE FOCUS]", async assert.strictEqual(document.activeElement, $(".o-mail-Composer-input")[0]); await click("button", { text: "Log note" }); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Send message" }); await contains(".o-mail-Composer"); await click("button", { text: "Send message" }); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); }); QUnit.test('do not post message with "Enter" keyboard shortcut', async () => { @@ -431,11 +431,11 @@ QUnit.test('do not post message with "Enter" keyboard shortcut', async () => { views: [[false, "form"]], }); await click("button", { text: "Send message" }); - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); await insertText(".o-mail-Composer-input", "Test"); triggerHotkey("Enter"); // weak test, no guarantee that we waited long enough for the potential message to be posted - await contains(".o-mail-Message", 0); + await contains(".o-mail-Message", { count: 0 }); }); QUnit.test("should not display subject when subject is the same as the thread name", async () => { @@ -455,10 +455,11 @@ QUnit.test("should not display subject when subject is the same as the thread na res_model: "res.partner", views: [[false, "form"]], }); - await contains(".o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message .o-mail-Message-content", { text: "not empty", }); - await contains(".o-mail-Message .o-mail-Message-content", 0, { + await contains(".o-mail-Message .o-mail-Message-content", { + count: 0, text: "Subject: Salutations, voyageurnot empty", }); }); @@ -481,20 +482,20 @@ QUnit.test("scroll position is kept when navigating from one record to another", ); const { openFormView } = await start(); openFormView("res.partner", partnerId_1); - await contains(".o-mail-Message", 20); + await contains(".o-mail-Message", { count: 20 }); const scrollValue1 = $(".o-mail-Chatter")[0].scrollHeight / 2; - await contains(".o-mail-Chatter", 1, { scroll: 0 }); + await contains(".o-mail-Chatter", { scroll: 0 }); await scroll(".o-mail-Chatter", scrollValue1); openFormView("res.partner", partnerId_2); - await contains(".o-mail-Message", 30); + await contains(".o-mail-Message", { count: 30 }); const scrollValue2 = $(".o-mail-Chatter")[0].scrollHeight / 3; await scroll(".o-mail-Chatter", scrollValue2); openFormView("res.partner", partnerId_1); - await contains(".o-mail-Message", 20); - await contains(".o-mail-Chatter", 1, { scroll: scrollValue1 }); + await contains(".o-mail-Message", { count: 20 }); + await contains(".o-mail-Chatter", { scroll: scrollValue1 }); openFormView("res.partner", partnerId_2); - await contains(".o-mail-Message", 30); - await contains(".o-mail-Chatter", 1, { scroll: scrollValue2 }); + await contains(".o-mail-Message", { count: 30 }); + await contains(".o-mail-Chatter", { scroll: scrollValue2 }); }); QUnit.test("basic chatter rendering", async () => { @@ -542,7 +543,7 @@ QUnit.test("basic chatter rendering without activities", async () => { await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); await contains("button[aria-label='Attach files']"); - await contains("button", 0, { text: "Activities" }); + await contains("button", { count: 0, text: "Activities" }); await contains(".o-mail-Followers"); await contains(".o-mail-Thread"); @@ -572,7 +573,7 @@ QUnit.test( }); await click(".o_form_button_create:eq(0)"); await contains(".o-mail-Message"); - await contains(".o-mail-Message-body", 1, { text: "Creating a new record..." }); + await contains(".o-mail-Message-body", { text: "Creating a new record..." }); } ); @@ -589,7 +590,7 @@ QUnit.test( }); const { openFormView } = await start(); openFormView("res.fake", fakeId); - await contains(".o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message .o-mail-Message-content", { text: "Subject: Another Subjectnot empty", }); } @@ -608,10 +609,11 @@ QUnit.test( }); const { openFormView } = await start(); openFormView("res.fake", fakeId); - await contains(".o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message .o-mail-Message-content", { text: "not empty", }); - await contains(".o-mail-Message .o-mail-Message-content", 0, { + await contains(".o-mail-Message .o-mail-Message-content", { + count: 0, text: "Subject: Custom Default Subjectnot empty", }); } @@ -630,10 +632,11 @@ QUnit.test( }); const { openFormView } = await start(); openFormView("res.fake", fakeId); - await contains(".o-mail-Message .o-mail-Message-content", 1, { + await contains(".o-mail-Message .o-mail-Message-content", { text: "not empty", }); - await contains(".o-mail-Message .o-mail-Message-content", 0, { + await contains(".o-mail-Message .o-mail-Message-content", { + count: 0, text: "Subject: Custom Default Subjectnot empty", }); } @@ -664,9 +667,9 @@ QUnit.test("basic chatter rendering without followers", async () => { await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); await contains("button[aria-label='Attach files']"); - await contains("button", 1, { text: "Activities" }); + await contains("button", { text: "Activities" }); await contains(".o-mail-Chatter .o-mail-Thread"); - await contains(".o-mail-Followers", 0); + await contains(".o-mail-Followers", { count: 0 }); }); QUnit.test("basic chatter rendering without messages", async () => { @@ -694,9 +697,9 @@ QUnit.test("basic chatter rendering without messages", async () => { await contains(".o-mail-Chatter"); await contains(".o-mail-Chatter-topbar"); await contains("button[aria-label='Attach files']"); - await contains("button", 1, { text: "Activities" }); + await contains("button", { text: "Activities" }); await contains(".o-mail-Followers"); - await contains(".o-mail-Chatter .o-mail-Thread", 0); + await contains(".o-mail-Chatter .o-mail-Thread", { count: 0 }); }); QUnit.test("chatter updating", async () => { @@ -750,7 +753,7 @@ QUnit.test("post message on draft record", async () => { await insertText(".o-mail-Composer-input", "Test"); await click(".o-mail-Composer button:contains(Send):not(:disabled)"); await contains(".o-mail-Message"); - await contains(".o-mail-Message-content", 1, { text: "Test" }); + await contains(".o-mail-Message-content", { text: "Test" }); }); QUnit.test( @@ -770,7 +773,7 @@ QUnit.test( const { openFormView } = await start({ serverData: { views } }); openFormView("res.partner"); await click("button", { text: "Activities" }); - await contains(".o_dialog h4", 1, { text: "Schedule Activity" }); + await contains(".o_dialog h4", { text: "Schedule Activity" }); } ); @@ -799,15 +802,15 @@ QUnit.test("upload attachment on draft record", async () => { name: "text.txt", }), ]); - await contains(".button[aria-label='Attach files']", 0, { text: "1" }); + await contains(".button[aria-label='Attach files']", { count: 0, text: "1" }); dragenterFiles(chatter[0]); dropFiles((await contains(".o-mail-Dropzone"))[0], [file]); - await contains("button[aria-label='Attach files']", 1, { text: "1" }); + await contains("button[aria-label='Attach files']", { text: "1" }); }); QUnit.test("Follower count of draft record is set to 0", async (assert) => { const { openView } = await start(); await openView({ res_model: "res.partner", views: [[false, "form"]] }); - await contains(".o-mail-Followers", 1, { text: "0" }); + await contains(".o-mail-Followers", { text: "0" }); }); diff --git a/addons/mail/static/tests/web/chatter_topbar_tests.js b/addons/mail/static/tests/web/chatter_topbar_tests.js index 08878e11a08..b9ebe1c70e4 100644 --- a/addons/mail/static/tests/web/chatter_topbar_tests.js +++ b/addons/mail/static/tests/web/chatter_topbar_tests.js @@ -23,9 +23,9 @@ QUnit.test("base rendering", async () => { views: [[false, "form"]], }); await contains(".o-mail-Chatter-topbar"); - await contains("button", 1, { text: "Send message" }); - await contains("button", 1, { text: "Log note" }); - await contains("button", 1, { text: "Activities" }); + await contains("button", { text: "Send message" }); + await contains("button", { text: "Log note" }); + await contains("button", { text: "Activities" }); await contains("button[aria-label='Attach files']"); await contains(".o-mail-Followers"); }); @@ -61,7 +61,7 @@ QUnit.test("rendering with multiple partner followers", async (assert) => { await click(".o-mail-Followers-button"); await contains(".o-mail-Followers-dropdown"); - await contains(".o-mail-Follower", 2); + await contains(".o-mail-Follower", { count: 2 }); assert.strictEqual($(".o-mail-Follower:eq(0)").text().trim(), "Jean Michang"); assert.strictEqual($(".o-mail-Follower:eq(1)").text().trim(), "Eden Hazard"); }); @@ -75,9 +75,9 @@ QUnit.test("log note toggling", async () => { res_model: "res.partner", views: [[false, "form"]], }); - await contains("button", 1, { text: "Log note" }); + await contains("button", { text: "Log note" }); await contains("button:contains(Log note):not(.active)"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Log note" }); await contains("button:contains(Log note).active"); @@ -85,7 +85,7 @@ QUnit.test("log note toggling", async () => { await click("button", { text: "Log note" }); await contains("button:contains(Log note):not(.active)"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); }); QUnit.test("send message toggling", async () => { @@ -97,9 +97,9 @@ QUnit.test("send message toggling", async () => { res_model: "res.partner", views: [[false, "form"]], }); - await contains("button", 1, { text: "Send message" }); + await contains("button", { text: "Send message" }); await contains("button:contains(Send message):not(.active)"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Send message" }); await contains("button:contains(Send message).active"); @@ -107,7 +107,7 @@ QUnit.test("send message toggling", async () => { await click("button", { text: "Send message" }); await contains("button:contains(Send message):not(.active)"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); }); QUnit.test("log note/send message switching", async () => { @@ -119,11 +119,11 @@ QUnit.test("log note/send message switching", async () => { res_model: "res.partner", views: [[false, "form"]], }); - await contains("button", 1, { text: "Send message" }); + await contains("button", { text: "Send message" }); await contains("button:contains(Send message):not(.active)"); - await contains("button", 1, { text: "Log note" }); + await contains("button", { text: "Log note" }); await contains("button:contains(Log note):not(.active)"); - await contains(".o-mail-Composer", 0); + await contains(".o-mail-Composer", { count: 0 }); await click("button", { text: "Send message" }); await contains("button:contains(Send message).active"); @@ -146,7 +146,7 @@ QUnit.test("attachment counter without attachments", async () => { views: [[false, "form"]], }); await contains("button[aria-label='Attach files']"); - await contains("button[aria-label='Attach files']", 0, { text: "0" }); + await contains("button[aria-label='Attach files']", { count: 0, text: "0" }); }); QUnit.test("attachment counter with attachments", async () => { @@ -172,7 +172,7 @@ QUnit.test("attachment counter with attachments", async () => { res_model: "res.partner", views: [[false, "form"]], }); - await contains("button[aria-label='Attach files']", 1, { text: "2" }); + await contains("button[aria-label='Attach files']", { text: "2" }); }); QUnit.test("attachment counter while loading attachments", async () => { @@ -194,7 +194,7 @@ QUnit.test("attachment counter while loading attachments", async () => { await contains("button[aria-label='Attach files']"); await advanceTime(DELAY_FOR_SPINNER); await contains("button[aria-label='Attach files'] .fa-spin"); - await contains("button[aria-label='Attach files']", 0, { text: "0" }); + await contains("button[aria-label='Attach files']", { count: 0, text: "0" }); }); QUnit.test("attachment counter transition when attachments become loaded", async () => { @@ -218,7 +218,7 @@ QUnit.test("attachment counter transition when attachments become loaded", async await advanceTime(DELAY_FOR_SPINNER); await contains("button[aria-label='Attach files'] .fa-spin"); deferred.resolve(); - await contains("button[aria-label='Attach files'] .fa-spin", 0); + await contains("button[aria-label='Attach files'] .fa-spin", { count: 0 }); }); QUnit.test( @@ -233,7 +233,7 @@ QUnit.test( views: [[false, "form"]], }); await contains(".o-mail-Chatter-fileUploader"); - await contains(".o-mail-AttachmentBox", 0); + await contains(".o-mail-AttachmentBox", { count: 0 }); } ); @@ -257,8 +257,8 @@ QUnit.test( views: [[false, "form"]], }); await contains("button[aria-label='Attach files']"); - await contains(".o-mail-AttachmentBox", 0); - await contains(".o-mail-Chatter-fileUploader", 0); + await contains(".o-mail-AttachmentBox", { count: 0 }); + await contains(".o-mail-Chatter-fileUploader", { count: 0 }); await click("button[aria-label='Attach files']"); await contains(".o-mail-AttachmentBox"); await contains(".o-mail-Chatter-fileUploader"); @@ -271,16 +271,16 @@ QUnit.test("composer state conserved when clicking on another topbar button", as const { openFormView } = await start(); await openFormView("res.partner", partnerId); await contains(".o-mail-Chatter-topbar"); - await contains("button", 1, { text: "Send message" }); - await contains("button", 1, { text: "Log note" }); + 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", 0); + await contains("button:contains(Send message).active", { count: 0 }); $(`button[aria-label='Attach files']`)[0].click(); await nextAnimationFrame(); await contains("button:contains(Log note).active"); - await contains("button:contains(Send message).active", 0); + await contains("button:contains(Send message).active", { count: 0 }); }); diff --git a/addons/mail/static/tests/web/fields/avatar_tests.js b/addons/mail/static/tests/web/fields/avatar_tests.js index 1569cbcefbf..5475a127307 100644 --- a/addons/mail/static/tests/web/fields/avatar_tests.js +++ b/addons/mail/static/tests/web/fields/avatar_tests.js @@ -21,8 +21,8 @@ QUnit.test("basic rendering", async () => { await contains(".o-mail-Avatar img"); await contains(".o-mail-Avatar img[data-src='/web/image/res.users/2/avatar_128']"); await contains(".o-mail-Avatar span"); - await contains(".o-mail-Avatar span", 1, { text: "User display name" }); - await contains(".o-mail-ChatWindow", 0); + await contains(".o-mail-Avatar span", { text: "User display name" }); + await contains(".o-mail-ChatWindow", { count: 0 }); await click(".o-mail-Avatar img"); await contains(".o-mail-ChatWindow"); }); diff --git a/addons/mail/static/tests/web/fields/m2x_avatar_user_tests.js b/addons/mail/static/tests/web/fields/m2x_avatar_user_tests.js index 12185004d46..f6afc1f1542 100644 --- a/addons/mail/static/tests/web/fields/m2x_avatar_user_tests.js +++ b/addons/mail/static/tests/web/fields/m2x_avatar_user_tests.js @@ -125,7 +125,7 @@ QUnit.test( view_mode: "form", views: [[false, "form"]], }); - await contains(".o_field_many2one_avatar_user input", 1, { value: "Mario" }); + await contains(".o_field_many2one_avatar_user input", { value: "Mario" }); triggerHotkey("control+k"); await nextTick(); @@ -142,7 +142,7 @@ QUnit.test( ); await click(document.body, "#o_command_3"); await nextTick(); - await contains(".o_field_many2one_avatar_user input", 1, { value: "Luigi" }); + await contains(".o_field_many2one_avatar_user input", { value: "Luigi" }); } ); @@ -169,7 +169,7 @@ QUnit.test( view_mode: "form", views: [[false, "form"]], }); - await contains(".o_field_many2one_avatar_user input", 1, { value: "Mario" }); + await contains(".o_field_many2one_avatar_user input", { value: "Mario" }); triggerHotkey("control+k"); await nextTick(); const idx = [...document.querySelectorAll(".o_command")] @@ -180,14 +180,14 @@ QUnit.test( // Assign me (Luigi) triggerHotkey("alt+shift+i"); await nextTick(); - await contains(".o_field_many2one_avatar_user input", 1, { value: "Luigi" }); + await contains(".o_field_many2one_avatar_user input", { value: "Luigi" }); // Unassign me triggerHotkey("control+k"); await nextTick(); await click([...document.querySelectorAll(".o_command")][idx]); await nextTick(); - await contains(".o_field_many2one_avatar_user input", 1, { value: "" }); + await contains(".o_field_many2one_avatar_user input", { value: "" }); } ); @@ -402,7 +402,7 @@ QUnit.test("avatar card preview", async (assert) => { // Close card await triggerEvent(document, ".o_control_panel", "mouseover"); assert.verifySteps(["setTimeout of 400ms"]); - await contains(".o_avatar_card", 0); + await contains(".o_avatar_card", { count: 0 }); }); QUnit.test( diff --git a/addons/mail/static/tests/web/fields/many2many_tags_email_tests.js b/addons/mail/static/tests/web/fields/many2many_tags_email_tests.js index c074602fa18..de78d9b3ade 100644 --- a/addons/mail/static/tests/web/fields/many2many_tags_email_tests.js +++ b/addons/mail/static/tests/web/fields/many2many_tags_email_tests.js @@ -53,13 +53,15 @@ QUnit.test("fieldmany2many tags email (edition)", async (assert) => { // add an other existing tag await selectDropdownItem(document.body, "partner_ids", "silver"); await contains(".modal-content .o_form_view"); - await contains(".modal-content .o_form_view .o_input#name_0", 1, { value: "silver" }); + await contains(".modal-content .o_form_view .o_input#name_0", { value: "silver" }); await contains(".modal-content .o_form_view .o_input#email_0"); // set the email and save the modal (will rerender the form view) await insertText(".modal-content .o_form_view .o_input#email_0", "coucou@petite.perruche"); await click(".modal-content .o_form_button_save"); - await contains('.o_field_many2many_tags_email[name="partner_ids"] .badge.o_tag_color_0', 2); + await contains('.o_field_many2many_tags_email[name="partner_ids"] .badge.o_tag_color_0', { + count: 2, + }); const firstTag = $('.o_field_many2many_tags_email[name="partner_ids"] .badge.o_tag_color_0')[0]; assert.strictEqual( firstTag.querySelector(".o_badge_text").innerText, @@ -90,10 +92,10 @@ QUnit.test("many2many_tags_email widget can load more than 40 records", async () views: [[false, "form"]], }); - await contains('.o_field_widget[name="partner_ids"] .badge', 100); + await contains('.o_field_widget[name="partner_ids"] .badge', { count: 100 }); await contains(".o_form_editable"); // add a record to the relation await selectDropdownItem(document.body, "partner_ids", "Public user"); - await contains('.o_field_widget[name="partner_ids"] .badge', 101); + await contains('.o_field_widget[name="partner_ids"] .badge', { count: 101 }); }); diff --git a/addons/mail/static/tests/web/follow_button_tests.js b/addons/mail/static/tests/web/follow_button_tests.js index 20d8d7bd823..02d334b4654 100644 --- a/addons/mail/static/tests/web/follow_button_tests.js +++ b/addons/mail/static/tests/web/follow_button_tests.js @@ -29,11 +29,11 @@ QUnit.test("hover following button", async () => { res_model: "res.partner", views: [[false, "form"]], }); - await contains(".fa-check + span", 1, { text: "Following" }); - await contains(".fa-times + span", 0, { text: "Following" }); + await contains(".fa-check + span", { text: "Following" }); + await contains(".fa-times + span", { count: 0, text: "Following" }); $("button:contains(Following)")[0].dispatchEvent(new window.MouseEvent("mouseenter")); - await contains(".fa-times + span", 1, { text: "Unfollow" }); - await contains(".fa-check + span", 0, { text: "Unfollow" }); + await contains(".fa-times + span", { text: "Unfollow" }); + await contains(".fa-check + span", { count: 0, text: "Unfollow" }); }); QUnit.test('click on "follow" button', async () => { @@ -43,10 +43,10 @@ QUnit.test('click on "follow" button', async () => { res_model: "res.partner", views: [[false, "form"]], }); - await contains("button span", 1, { text: "Follow" }); + await contains("button span", { text: "Follow" }); await click("button span", { text: "Follow" }); - await contains("button span", 1, { text: "Following" }); + await contains("button span", { text: "Following" }); }); QUnit.test('Click on "follow" button should save draft record', async () => { @@ -63,7 +63,7 @@ QUnit.test('Click on "follow" button should save draft record', async () => { }; const { openFormView } = await start({ serverData: { views } }); openFormView("res.partner"); - await contains("button span", 1, { text: "Follow" }); + await contains("button span", { text: "Follow" }); await contains("div.o_field_char"); await click("button span", { text: "Follow" }); await contains("div.o_field_invalid"); @@ -85,5 +85,5 @@ QUnit.test('click on "unfollow" button', async () => { views: [[false, "form"]], }); await click(".fa-check + span", { text: "Following" }); - await contains("button span", 1, { text: "Follow" }); + await contains("button span", { text: "Follow" }); }); diff --git a/addons/mail/static/tests/web/follower_list_menu_tests.js b/addons/mail/static/tests/web/follower_list_menu_tests.js index 619eededbe4..be6dec9fd6b 100644 --- a/addons/mail/static/tests/web/follower_list_menu_tests.js +++ b/addons/mail/static/tests/web/follower_list_menu_tests.js @@ -23,9 +23,9 @@ QUnit.test("base rendering not editable", async () => { ); await contains(".o-mail-Followers"); await contains(".o-mail-Followers-button:disabled"); - await contains(".o-mail-Followers-dropdown", 0); + await contains(".o-mail-Followers-dropdown", { count: 0 }); await click(".o-mail-Followers-button"); - await contains(".o-mail-Followers-dropdown", 0); + await contains(".o-mail-Followers-dropdown", { count: 0 }); }); QUnit.test("base rendering editable", async (assert) => { @@ -49,7 +49,7 @@ QUnit.test("base rendering editable", async (assert) => { await contains(".o-mail-Followers"); await contains(".o-mail-Followers-button"); assert.notOk($(".o-mail-Followers-button")[0].disabled); - await contains(".o-mail-Followers-dropdown", 0); + await contains(".o-mail-Followers-dropdown", { count: 0 }); await click(".o-mail-Followers-button"); await contains(".o-mail-Followers-dropdown"); @@ -110,15 +110,15 @@ QUnit.test('click on "add followers" button', async (assert) => { await click(".o-mail-Followers-button"); await contains(".o-mail-Followers-dropdown"); - await contains("a", 1, { text: "Add Followers" }); + await contains("a", { text: "Add Followers" }); await click("a", { text: "Add Followers" }); - await contains(".o-mail-Followers-dropdown", 0); + await contains(".o-mail-Followers-dropdown", { count: 0 }); assert.verifySteps(["action:open_view"]); assert.strictEqual($(".o-mail-Followers-counter").text(), "2"); await click(".o-mail-Followers-button"); - await contains(".o-mail-Follower", 2); + await contains(".o-mail-Follower", { count: 2 }); assert.strictEqual($(".o-mail-Follower").text(), "François PerussePartner3"); }); @@ -162,7 +162,7 @@ QUnit.test("click on remove follower", async (assert) => { await click("button[title='Remove this follower']"); assert.verifySteps(["message_unsubscribe"]); - await contains(".o-mail-Follower", 0); + await contains(".o-mail-Follower", { count: 0 }); }); QUnit.test( @@ -204,7 +204,7 @@ QUnit.test( }); await click(".o-mail-Followers-button"); - await contains("a", 0, { text: "Add Followers" }); + await contains("a", { count: 0, text: "Add Followers" }); await contains(".o-mail-Follower:eq(0) button[title='Edit subscription']"); await contains(".o-mail-Follower:eq(0) button[title='Remove this follower']"); @@ -230,17 +230,17 @@ QUnit.test("Load 100 followers at once", async () => { ); const { openFormView } = await start(); await openFormView("res.partner", partnerIds[0]); - await contains("button[title='Show Followers']", 1, { text: "210" }); + await contains("button[title='Show Followers']", { text: "210" }); await click("button[title='Show Followers']"); - await contains(".o-mail-Follower", 1, { text: "Mitchell Admin" }); - await contains(".o-mail-Follower", 100); + 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-Follower", 200); + 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 contains(".o-mail-Follower", 210); - await contains(".o-mail-Followers-dropdown span", 0, { text: "Load more" }); + await contains(".o-mail-Follower", { count: 210 }); + await contains(".o-mail-Followers-dropdown span", { count: 0, text: "Load more" }); }); QUnit.test("Load 100 recipients at once", async () => { @@ -264,20 +264,20 @@ QUnit.test("Load 100 recipients at once", async () => { ); const { openFormView } = await start(); await openFormView("res.partner", partnerIds[0]); - await contains("button[title='Show Followers']", 1, { text: "210" }); + await contains("button[title='Show Followers']", { text: "210" }); await click("button", { text: "Send message" }); - await contains(".o-mail-Chatter div", 1, { + await contains(".o-mail-Chatter div", { text: "To: me, partner1, partner2, partner3, partner4, …", }); await contains("button[title='Show all recipients']"); await click("button[title='Show all recipients']"); - await contains(".o-mail-RecipientList li", 100); + await contains(".o-mail-RecipientList li", { count: 100 }); $(".o-mail-RecipientList span:contains(Load more)")[0].scrollIntoView(); - await contains(".o-mail-RecipientList li", 200); + 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 contains(".o-mail-RecipientList li", 210); - await contains(".o-mail-RecipientList span", 0, { text: "Load more" }); + await contains(".o-mail-RecipientList li", { count: 210 }); + await contains(".o-mail-RecipientList span", { count: 0, text: "Load more" }); }); QUnit.test( @@ -319,7 +319,7 @@ QUnit.test( }); await click(".o-mail-Followers-button"); - await contains("a", 1, { text: "Add Followers" }); + await contains("a", { text: "Add Followers" }); await contains(".o-mail-Follower:eq(0) button[title='Edit subscription']"); await contains(".o-mail-Follower:eq(0) button[title='Remove this follower']"); await contains(".o-mail-Follower:eq(1) button[title='Edit subscription']"); diff --git a/addons/mail/static/tests/web/follower_tests.js b/addons/mail/static/tests/web/follower_tests.js index 2c61e5516b2..70f04014649 100644 --- a/addons/mail/static/tests/web/follower_tests.js +++ b/addons/mail/static/tests/web/follower_tests.js @@ -34,7 +34,7 @@ QUnit.test("base rendering not editable", async () => { await contains(".o-mail-Follower"); await contains(".o-mail-Follower-details"); await contains(".o-mail-Follower-avatar"); - await contains(".o-mail-Follower-action", 0); + await contains(".o-mail-Follower-action", { count: 0 }); }); QUnit.test("base rendering editable", async () => { @@ -121,7 +121,7 @@ QUnit.test("click on edit follower", async (assert) => { await contains("button[title='Edit subscription']"); await click("button[title='Edit subscription']"); - await contains(".o-mail-Follower", 0); + await contains(".o-mail-Follower", { count: 0 }); assert.verifySteps(["fetch_subtypes"]); await contains(".o-mail-FollowerSubtypeDialog"); }); @@ -156,7 +156,7 @@ QUnit.test("edit follower and close subtype dialog", async (assert) => { assert.verifySteps(["fetch_subtypes"]); await click(".o-mail-FollowerSubtypeDialog button", { text: "Cancel" }); - await contains(".o-mail-FollowerSubtypeDialog", 0); + await contains(".o-mail-FollowerSubtypeDialog", { count: 0 }); }); QUnit.test("remove a follower in a dirty form view", async (assert) => { @@ -184,14 +184,14 @@ QUnit.test("remove a follower in a dirty form view", async (assert) => { openFormView("res.partner", threadId); await click(".o_field_many2many_tags[name='channel_ids'] input"); await click(".dropdown-item", { text: "General" }); - await contains(".o_tag", 1, { text: "General" }); - await contains(".o-mail-Followers-counter", 1, { text: "1" }); + await contains(".o_tag", { text: "General" }); + await contains(".o-mail-Followers-counter", { text: "1" }); await editInput(document.body, ".o_field_char[name=name] input", "some value"); await click(".o-mail-Followers-button"); await click("button[title='Remove this follower']"); - await contains(".o-mail-Followers-counter", 1, { text: "0" }); - await contains(".o_field_char[name=name] input", 1, { value: "some value" }); - await contains(".o_tag", 1, { text: "General" }); + await contains(".o-mail-Followers-counter", { text: "0" }); + await contains(".o_field_char[name=name] input", { value: "some value" }); + await contains(".o_tag", { text: "General" }); }); QUnit.test("removing a follower should reload form view", async function (assert) { @@ -215,6 +215,6 @@ QUnit.test("removing a follower should reload form view", async function (assert assert.verifySteps([`read ${threadId}`]); await click(".o-mail-Followers-button"); await click("button[title='Remove this follower']"); - await contains(".o-mail-Followers-counter", 1, { text: "0" }); + await contains(".o-mail-Followers-counter", { text: "0" }); assert.verifySteps([`read ${threadId}`]); }); diff --git a/addons/mail/static/tests/web/form_renderer_tests.js b/addons/mail/static/tests/web/form_renderer_tests.js index 33fc1dc32ff..6e219a57209 100644 --- a/addons/mail/static/tests/web/form_renderer_tests.js +++ b/addons/mail/static/tests/web/form_renderer_tests.js @@ -44,16 +44,16 @@ QUnit.test("Form view not scrolled when switching record", async () => { }, { resIds: [partnerId_1, partnerId_2] } ); - await contains(".o-mail-Message", 29); - await contains(".o_content", 1, { scroll: 0 }); + await contains(".o-mail-Message", { count: 29 }); + await contains(".o_content", { scroll: 0 }); await scroll(".o_content", 150); await click(".o_pager_next"); - await contains(".o-mail-Message", 30); - await contains(".o_content", 1, { scroll: 150 }); + await contains(".o-mail-Message", { count: 30 }); + await contains(".o_content", { scroll: 150 }); await scroll(".o_content", 0); await click(".o_pager_previous"); - await contains(".o-mail-Message", 29); - await contains(".o_content", 1, { scroll: 0 }); + await contains(".o-mail-Message", { count: 29 }); + await contains(".o_content", { scroll: 0 }); }); QUnit.test( @@ -102,7 +102,7 @@ QUnit.test( resIds: [partnerId_1, partnerId_2], } ); - await contains("button[aria-label='Attach files']", 1, { text: "2" }); + await contains("button[aria-label='Attach files']", { text: "2" }); // The attachment links are updated on (re)load, // so using pager is a way to reload the record "Partner1". await click(".o_pager_next"); @@ -110,7 +110,7 @@ QUnit.test( // Simulate unlinking attachment 1 from Partner 1. pyEnv["ir.attachment"].write([attachmentId_1], { res_id: 0 }); await click(".o_pager_previous"); - await contains("button[aria-label='Attach files']", 1, { text: "1" }); + await contains("button[aria-label='Attach files']", { text: "1" }); } ); @@ -202,10 +202,10 @@ QUnit.test("read more links becomes read less after being clicked", async (asser openView(openViewAction); await contains(".o-mail-Chatter"); await contains(".o-mail-Message"); - await contains(".o-mail-read-more-less", 1, { text: "Read More" }); + await contains(".o-mail-read-more-less", { text: "Read More" }); await click(".o-mail-read-more-less"); - await contains(".o-mail-read-more-less", 1, { text: "Read Less" }); + await contains(".o-mail-read-more-less", { text: "Read Less" }); }); QUnit.test( @@ -256,13 +256,13 @@ QUnit.test( res_id: partnerId, views: [[false, "form"]], }); - await contains(".o-mail-read-more-less", 1, { text: "Read More" }); + await contains(".o-mail-read-more-less", { text: "Read More" }); await click(".o-mail-read-more-less"); - await contains(".o-mail-read-more-less", 1, { text: "Read Less" }); + await contains(".o-mail-read-more-less", { text: "Read Less" }); await click(".o-mail-Message"); - await contains(".o-mail-read-more-less", 1, { text: "Read Less" }); + await contains(".o-mail-read-more-less", { text: "Read Less" }); } ); @@ -305,5 +305,5 @@ QUnit.test("read more/less links on message of type notification", async () => { views: [[false, "form"]], }; openView(openViewAction); - await contains(".o-mail-Message a", 1, { text: "Read More" }); + await contains(".o-mail-Message a", { text: "Read More" }); }); diff --git a/addons/mrp/static/tests/mrp_document_kanban_tests.js b/addons/mrp/static/tests/mrp_document_kanban_tests.js index 37ef87e568c..e41858fd5ef 100644 --- a/addons/mrp/static/tests/mrp_document_kanban_tests.js +++ b/addons/mrp/static/tests/mrp_document_kanban_tests.js @@ -222,7 +222,7 @@ QUnit.module('MrpDocumentsKanbanView', { await click(".o_kanban_previewer"); await contains(".o-FileViewer"); await click(".o-FileViewer-headerButton .fa-times"); - await contains(".o-FileViewer", 0); + await contains(".o-FileViewer", { count: 0 }); }); }); diff --git a/addons/project_todo/static/tests/activity_menu_tests.js b/addons/project_todo/static/tests/activity_menu_tests.js index 4e9743559da..3071bb8e59c 100644 --- a/addons/project_todo/static/tests/activity_menu_tests.js +++ b/addons/project_todo/static/tests/activity_menu_tests.js @@ -7,13 +7,13 @@ import { editInput, patchDate } from "@web/../tests/helpers/utils"; QUnit.test("create todo from activity menu without date", async function () { await start(); await contains(".o_menu_systray i[aria-label='Activities']"); - await contains(".o-mail-ActivityMenu-counter", 0); + await contains(".o-mail-ActivityMenu-counter", { count: 0 }); await click(".o_menu_systray i[aria-label='Activities']"); await contains( ".o-mail-ActivityMenu:contains(Congratulations, you're done with your activities.)" ); await click(".btn", { text: "Add a To-do" }); - await contains(".btn", 0, { text: "Add a To-do" }); + await contains(".btn", { count: 0, text: "Add a To-do" }); await contains(".o-mail-ActivityMenu-show"); await insertText("input.o-mail-ActivityMenu-input", "New To-do"); @@ -23,25 +23,25 @@ QUnit.test("create todo from activity menu without date", async function () { ); // Need to reopen systray as it automatically closes when a todo is created await click(".o_menu_systray i[aria-label='Activities']"); - await contains(".o-mail-ActivityMenu-counter", 1, { text: "1" }); - await contains(".o-mail-ActivityGroup span", 1, { text: "project.task" }); - await contains(".btn", 1, { text: "1 Today" }); - await contains(".btn", 1, { text: "Add a To-do" }); - await contains(".o-mail-ActivityMenu-show", 0); - await contains(".o-mail-ActivityMenu-input", 0); + await contains(".o-mail-ActivityMenu-counter", { text: "1" }); + await contains(".o-mail-ActivityGroup span", { text: "project.task" }); + await contains(".btn", { text: "1 Today" }); + await contains(".btn", { text: "Add a To-do" }); + await contains(".o-mail-ActivityMenu-show", { count: 0 }); + await contains(".o-mail-ActivityMenu-input", { count: 0 }); await click(".btn", { text: "Add a To-do" }); - await contains(".btn", 0, { text: "Add a To-do" }); + await contains(".btn", { count: 0, text: "Add a To-do" }); await insertText("input.o-mail-ActivityMenu-input", "New To-do"); await click(".btn", { text: "SAVE" }); // Need to reopen systray as it automatically closes when a todo is created await contains( ".o_notification:contains(Your to-do has been successfully added to your tasks and scheduled for completion.)", - 2 + { count: 2 } ); await click(".o_menu_systray i[aria-label='Activities']"); - await contains(".o-mail-ActivityMenu-counter", 1, { text: "2" }); - await contains(".btn", 1, { text: "2 Today" }); + await contains(".o-mail-ActivityMenu-counter", { text: "2" }); + await contains(".btn", { text: "2 Today" }); }); QUnit.test("create to-do from activity menu with date", async function () { @@ -51,7 +51,7 @@ QUnit.test("create to-do from activity menu with date", async function () { const futureDay = today.plus({ days: 2 }); await start(); await contains(".o_menu_systray i[aria-label='Activities']"); - await contains(".o-mail-ActivityMenu-counter", 0); + await contains(".o-mail-ActivityMenu-counter", { count: 0 }); await click(".o_menu_systray i[aria-label='Activities']"); await click(".btn", { text: "Add a To-do" }); @@ -70,7 +70,7 @@ QUnit.test("create to-do from activity menu with date", async function () { ); // Need to reopen systray as it automatically closes when a todo is created await click(".o_menu_systray i[aria-label='Activities']"); - await contains(".o-mail-ActivityMenu-counter", 1, { text: "1" }); - await contains(".o-mail-ActivityGroup span", 1, { text: "project.task" }); - await contains(".btn", 1, { text: "1 Future" }); + await contains(".o-mail-ActivityMenu-counter", { text: "1" }); + await contains(".o-mail-ActivityGroup span", { text: "project.task" }); + await contains(".btn", { text: "1 Future" }); }); diff --git a/addons/sms/static/tests/messaging_menu/messaging_menu_patch_tests.js b/addons/sms/static/tests/messaging_menu/messaging_menu_patch_tests.js index 678670c8cec..d8e777e30b5 100644 --- a/addons/sms/static/tests/messaging_menu/messaging_menu_patch_tests.js +++ b/addons/sms/static/tests/messaging_menu/messaging_menu_patch_tests.js @@ -24,11 +24,11 @@ QUnit.test("mark as read", async () => { await contains(".o-mail-NotificationItem"); await triggerEvent($(".o-mail-NotificationItem")[0], null, "mouseenter"); await contains(".o-mail-NotificationItem [title='Mark As Read']"); - await contains(".o-mail-NotificationItem-text", 1, { + await contains(".o-mail-NotificationItem-text", { text: "An error occurred when sending an SMS", }); await click(".o-mail-NotificationItem [title='Mark As Read']"); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("notifications grouped by notification_type", async (assert) => { @@ -72,7 +72,7 @@ QUnit.test("notifications grouped by notification_type", async (assert) => { ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); const items = $(".o-mail-NotificationItem"); assert.ok(items[0].textContent.includes("Partner")); assert.ok(items[0].textContent.includes("2")); // counter @@ -136,7 +136,7 @@ QUnit.test("grouped notifications by document model", async (assert) => { await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-NotificationItem"); - await contains(".o-mail-NotificationItem:contains(Partner) .badge", 1, { text: "2" }); + await contains(".o-mail-NotificationItem:contains(Partner) .badge", { text: "2" }); await click(".o-mail-NotificationItem"); assert.verifySteps(["do_action"]); }); diff --git a/addons/sms/static/tests/thread/message_patch_test.js b/addons/sms/static/tests/thread/message_patch_test.js index 0f14ca242dc..5f2d5932e79 100644 --- a/addons/sms/static/tests/thread/message_patch_test.js +++ b/addons/sms/static/tests/thread/message_patch_test.js @@ -32,7 +32,7 @@ QUnit.test("Notification Sent", async (assert) => { await contains(".o-mail-MessageNotificationPopover"); await contains(".o-mail-MessageNotificationPopover i"); assert.hasClass($(".o-mail-MessageNotificationPopover i"), "fa-check"); - await contains(".o-mail-MessageNotificationPopover", 1, { text: "Someone" }); + await contains(".o-mail-MessageNotificationPopover", { text: "Someone" }); }); QUnit.test("Notification Error", async (assert) => { diff --git a/addons/snailmail/static/tests/message/message_patch_tests.js b/addons/snailmail/static/tests/message/message_patch_tests.js index 440f146dc6b..d25be805111 100644 --- a/addons/snailmail/static/tests/message/message_patch_tests.js +++ b/addons/snailmail/static/tests/message/message_patch_tests.js @@ -144,9 +144,9 @@ QUnit.test("No Price Available", async (assert) => { $(".o-snailmail-SnailmailError .modal-body").text().trim(), "The country to which you want to send the letter is not supported by our service." ); - await contains("button", 1, { text: "Cancel letter" }); + await contains("button", { text: "Cancel letter" }); await click("button", { text: "Cancel letter" }); - await contains(".o-snailmail-SnailmailError", 0); + await contains(".o-snailmail-SnailmailError", { count: 0 }); assert.verifySteps(["cancel_letter"]); }); @@ -192,10 +192,10 @@ QUnit.test("Credit Error", async (assert) => { $(".o-snailmail-SnailmailError p").text().trim(), "The letter could not be sent due to insufficient credits on your IAP account." ); - await contains("button", 1, { text: "Re-send letter" }); - await contains("button", 1, { text: "Cancel letter" }); + await contains("button", { text: "Re-send letter" }); + await contains("button", { text: "Cancel letter" }); await click("button", { text: "Re-send letter" }); - await contains(".o-snailmail-SnailmailError", 0); + await contains(".o-snailmail-SnailmailError", { count: 0 }); assert.verifySteps(["send_letter"]); }); @@ -241,10 +241,10 @@ QUnit.test("Trial Error", async (assert) => { $(".o-snailmail-SnailmailError p").text().trim(), "You need credits on your IAP account to send a letter." ); - await contains("button", 1, { text: "Re-send letter" }); - await contains("button", 1, { text: "Cancel letter" }); + await contains("button", { text: "Re-send letter" }); + await contains("button", { text: "Cancel letter" }); await click("button", { text: "Re-send letter" }); - await contains(".o-snailmail-SnailmailError", 0); + await contains(".o-snailmail-SnailmailError", { count: 0 }); assert.verifySteps(["send_letter"]); }); diff --git a/addons/snailmail/static/tests/messaging_menu/messaging_menu_patch_tests.js b/addons/snailmail/static/tests/messaging_menu/messaging_menu_patch_tests.js index b9571b63213..652a7938502 100644 --- a/addons/snailmail/static/tests/messaging_menu/messaging_menu_patch_tests.js +++ b/addons/snailmail/static/tests/messaging_menu/messaging_menu_patch_tests.js @@ -30,7 +30,7 @@ QUnit.test("mark as read", async () => { ".o-mail-NotificationItem:contains(An error occurred when sending a letter with Snailmail.)" ); await click(".o-mail-NotificationItem [title='Mark As Read']"); - await contains(".o-mail-NotificationItem", 0); + await contains(".o-mail-NotificationItem", { count: 0 }); }); QUnit.test("notifications grouped by notification_type", async (assert) => { @@ -74,7 +74,7 @@ QUnit.test("notifications grouped by notification_type", async (assert) => { ]); await start(); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-NotificationItem", 2); + await contains(".o-mail-NotificationItem", { count: 2 }); assert.ok($(".o-mail-NotificationItem:eq(0)").text().includes("Partner")); assert.ok($(".o-mail-NotificationItem:eq(0)").text().includes("2")); // counter assert.ok( @@ -145,8 +145,8 @@ QUnit.test("grouped notifications by document model", async (assert) => { }); await click(".o_menu_systray i[aria-label='Messages']"); await contains(".o-mail-NotificationItem"); - await contains(".o-mail-NotificationItem-name", 1, { text: "Partner" }); - await contains(".o-mail-NotificationItem-counter", 1, { text: "2" }); + await contains(".o-mail-NotificationItem-name", { text: "Partner" }); + await contains(".o-mail-NotificationItem-counter", { text: "2" }); await click(".o-mail-NotificationItem"); assert.verifySteps(["do_action"]); }); diff --git a/addons/test_mail/static/tests/activity_tests.js b/addons/test_mail/static/tests/activity_tests.js index 7e551f10527..2c803528a0f 100644 --- a/addons/test_mail/static/tests/activity_tests.js +++ b/addons/test_mail/static/tests/activity_tests.js @@ -680,7 +680,7 @@ QUnit.module("test_mail", {}, function () { assert.containsOnce($, ".modal.o_technical_modal", "Activity Modal should be opened"); await testUtils.dom.click($('.modal.o_technical_modal button[special="cancel"]')); - assert.containsNone($, ".modal.o_technical_modal", "Activity Modal should be closed"); + await contains(".modal.o_technical_modal", { count: 0 }); }); QUnit.test( @@ -721,17 +721,14 @@ QUnit.module("test_mail", {}, function () { const { webClient } = await start({ serverData }); await doAction(webClient, 1); - assert.containsN(document.body, ".o_m2o_avatar", 2); + await contains(".o_m2o_avatar", { count: 2 }); assert.containsOnce( document.body, `tr:nth-child(2) .o_m2o_avatar > img[data-src="/web/image/res.users/${resUsersId1}/avatar_128"]`, "should have m2o avatar image" ); - assert.containsNone( - document.body, - ".o_m2o_avatar > span", - "should not have text on many2one_avatar_user if onlyImage node option is passed" - ); + // "should not have text on many2one_avatar_user if onlyImage node option is passed" + await contains(".o_m2o_avatar > span", { count: 0 }); } ); @@ -1001,7 +998,7 @@ QUnit.module("test_mail", {}, function () { res_model: "mail.test.activity", views: [[false, "activity"]], }); - assert.containsN(document.body, ".luxon", 2); + await contains(".luxon", { count: 2 }); }); QUnit.test("test displaying image (write_date field)", async (assert) => { diff --git a/addons/test_mail/static/tests/systray_activity_menu_tests.js b/addons/test_mail/static/tests/systray_activity_menu_tests.js index e4ed86e99cf..eef4cda9fdd 100644 --- a/addons/test_mail/static/tests/systray_activity_menu_tests.js +++ b/addons/test_mail/static/tests/systray_activity_menu_tests.js @@ -38,7 +38,7 @@ QUnit.test("do not show empty text when at least some future activities", async await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Activities'])"); await contains( ".o-mail-ActivityMenu:contains(Congratulations, you're done with your activities.)", - 0 + { count: 0 } ); }); @@ -72,7 +72,7 @@ QUnit.test("activity menu widget: activity menu with 2 models", async (assert) = const { env } = await start(); await contains(".o_menu_systray i[aria-label='Activities']"); await contains(".o-mail-ActivityMenu-counter"); - await contains(".o-mail-ActivityMenu-counter", 1, { text: "5" }); + await contains(".o-mail-ActivityMenu-counter", { text: "5" }); let context = {}; patchWithCleanup(env.services.action, { doAction(action) { @@ -85,23 +85,23 @@ QUnit.test("activity menu widget: activity menu with 2 models", async (assert) = }; await click(".o_menu_systray i[aria-label='Activities']"); await contains(".o-mail-ActivityMenu"); - await contains(".o-mail-ActivityMenu .o-mail-ActivityGroup", 2); + await contains(".o-mail-ActivityMenu .o-mail-ActivityGroup", { count: 2 }); await click(".o-mail-ActivityMenu .o-mail-ActivityGroup button", { text: "1 Late" }); - await contains(".o-mail-ActivityMenu", 0); + await contains(".o-mail-ActivityMenu", { count: 0 }); context = { force_search_count: 1, search_default_activities_today: 1, }; await click(".o_menu_systray .dropdown-toggle:has(i[aria-label='Activities'])"); await click(".o-mail-ActivityMenu .o-mail-ActivityGroup button:contains('Today'):eq(0)"); - await contains(".o-mail-ActivityMenu", 0); + await contains(".o-mail-ActivityMenu", { count: 0 }); context = { force_search_count: 1, search_default_activities_upcoming_all: 1, }; await click(".o_menu_systray i[aria-label='Activities']"); await click(".o-mail-ActivityMenu .o-mail-ActivityGroup button", { text: "2 Future" }); - await contains(".o-mail-ActivityMenu", 0); + await contains(".o-mail-ActivityMenu", { count: 0 }); context = { force_search_count: 1, search_default_activities_overdue: 1, @@ -109,7 +109,7 @@ QUnit.test("activity menu widget: activity menu with 2 models", async (assert) = }; await click(".o_menu_systray i[aria-label='Activities']"); await click(".o-mail-ActivityMenu .o-mail-ActivityGroup span", { text: "mail.test.activity" }); - await contains(".o-mail-ActivityMenu", 0); + await contains(".o-mail-ActivityMenu", { count: 0 }); }); QUnit.test("activity menu widget: activity view icon", async (assert) => { @@ -141,7 +141,7 @@ QUnit.test("activity menu widget: activity view icon", async (assert) => { ]); const { env } = await start(); await click(".o_menu_systray i[aria-label='Activities']"); - await contains("button[title='Summary']", 2); + await contains("button[title='Summary']", { count: 2 }); const first = $(".o-mail-ActivityGroup:contains('res.partner') button[title='Summary']"); const second = $( ".o-mail-ActivityGroup:contains('mail.test.activity') button[title='Summary']" @@ -163,7 +163,7 @@ QUnit.test("activity menu widget: activity view icon", async (assert) => { }, }); await click(".o-mail-ActivityGroup:contains('mail.test.activity') button[title='Summary']"); - await contains(".dropdown-menu", 0); + await contains(".dropdown-menu", { count: 0 }); await click(".o_menu_systray i[aria-label='Activities']"); await click(".o-mail-ActivityGroup:contains('res.partner') button[title='Summary']"); assert.verifySteps(["do_action:mail.test.activity", "do_action:res.partner"]); @@ -174,5 +174,5 @@ QUnit.test("activity menu widget: close on messaging menu click", async (assert) await click(".o_menu_systray i[aria-label='Activities']"); await contains(".o-mail-ActivityMenu"); await click(".o_menu_systray i[aria-label='Messages']"); - await contains(".o-mail-ActivityMenu", 0); + await contains(".o-mail-ActivityMenu", { count: 0 }); }); diff --git a/addons/test_mail/static/tests/tracking_value_tests.js b/addons/test_mail/static/tests/tracking_value_tests.js index 1a32352bfe0..cb9514debc3 100644 --- a/addons/test_mail/static/tests/tracking_value_tests.js +++ b/addons/test_mail/static/tests/tracking_value_tests.js @@ -58,10 +58,10 @@ QUnit.test("basic rendering of tracking value (float type)", async function () { await contains(".o-mail-Message-trackingField"); await contains(".o-mail-Message-trackingField:contains('(Float)')"); await contains(".o-mail-Message-trackingOld"); - await contains(".o-mail-Message-trackingOld", 1, { text: "12.30" }); + await contains(".o-mail-Message-trackingOld", { text: "12.30" }); await contains(".o-mail-Message-trackingSeparator"); await contains(".o-mail-Message-trackingNew"); - await contains(".o-mail-Message-trackingNew", 1, { text: "45.67" }); + await contains(".o-mail-Message-trackingNew", { text: "45.67" }); }); QUnit.test("rendering of tracked field of type float: from non-0 to 0", async function () {