From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../components/im/test/browser/browser_logs.js | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 comm/mail/components/im/test/browser/browser_logs.js (limited to 'comm/mail/components/im/test/browser/browser_logs.js') diff --git a/comm/mail/components/im/test/browser/browser_logs.js b/comm/mail/components/im/test/browser/browser_logs.js new file mode 100644 index 0000000000..2f95a2accd --- /dev/null +++ b/comm/mail/components/im/test/browser/browser_logs.js @@ -0,0 +1,97 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const { mailTestUtils } = ChromeUtils.import( + "resource://testing-common/mailnews/MailTestUtils.jsm" +); + +add_task(async function testTopicRestored() { + const account = IMServices.accounts.createAccount( + "testuser", + "prpl-mochitest" + ); + account.password = "this is a test"; + account.connect(); + + await openChatTab(); + ok(BrowserTestUtils.is_visible(document.getElementById("chatPanel"))); + + const conversation = + account.prplAccount.wrappedJSObject.makeMUC("logs topic"); + let convNode = getConversationItem(conversation); + ok(convNode); + + await EventUtils.synthesizeMouseAtCenter(convNode, {}); + + let chatConv = getChatConversationElement(conversation); + ok(chatConv, "found conversation"); + const browserDisplayed = BrowserTestUtils.waitForEvent( + chatConv.convBrowser, + "MessagesDisplayed" + ); + ok(BrowserTestUtils.is_visible(chatConv), "conversation visible"); + + conversation.addParticipant("topic"); + conversation.addMessages([ + { + who: "topic", + content: "hi", + options: { + incoming: true, + }, + }, + ]); + await browserDisplayed; + + // Close and re-open conversation to get logs + conversation.close(); + const newConversation = + account.prplAccount.wrappedJSObject.makeMUC("logs topic"); + convNode = getConversationItem(newConversation); + ok(convNode); + + let conversationLoaded = waitForConversationLoad(); + await EventUtils.synthesizeMouseAtCenter(convNode, {}); + + chatConv = getChatConversationElement(newConversation); + ok(chatConv, "found conversation"); + ok(BrowserTestUtils.is_visible(chatConv), "conversation visible"); + + const topicChanged = waitForNotification( + newConversation, + "chat-update-topic" + ); + newConversation.setTopic("foo bar", "topic"); + await topicChanged; + const logTree = document.getElementById("logTree"); + const chatTopInfo = document.querySelector("chat-conversation-info"); + + is(chatTopInfo.topic.value, "foo bar"); + + // Wait for log list to be populated, sadly there is no event and it is delayed by promises. + await TestUtils.waitForCondition(() => logTree.view.rowCount > 0); + + await conversationLoaded; + const logBrowser = document.getElementById("conv-log-browser"); + conversationLoaded = waitForConversationLoad(logBrowser); + mailTestUtils.treeClick(EventUtils, window, logTree, 0, 0, { + clickCount: 1, + }); + await conversationLoaded; + + ok(BrowserTestUtils.is_visible(logBrowser)); + is(chatTopInfo.topic.value, "", "Topic is cleared when viewing logs"); + + EventUtils.synthesizeMouseAtCenter( + document.getElementById("goToConversation"), + {} + ); + + ok(BrowserTestUtils.is_hidden(logBrowser)); + is(chatTopInfo.topic.value, "foo bar"); + + newConversation.close(); + account.disconnect(); + IMServices.accounts.deleteAccount(account.id); +}); -- cgit v1.2.3