summaryrefslogtreecommitdiffstats
path: root/comm/mail/base/test/browser/browser_statusFeedback.js
diff options
context:
space:
mode:
Diffstat (limited to 'comm/mail/base/test/browser/browser_statusFeedback.js')
-rw-r--r--comm/mail/base/test/browser/browser_statusFeedback.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/comm/mail/base/test/browser/browser_statusFeedback.js b/comm/mail/base/test/browser/browser_statusFeedback.js
new file mode 100644
index 0000000000..66132aa484
--- /dev/null
+++ b/comm/mail/base/test/browser/browser_statusFeedback.js
@@ -0,0 +1,71 @@
+/* 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 { MessageGenerator } = ChromeUtils.import(
+ "resource://testing-common/mailnews/MessageGenerator.jsm"
+);
+
+const statusText = document.getElementById("statusText");
+const tabmail = document.getElementById("tabmail");
+const about3Pane = tabmail.currentAbout3Pane;
+const { threadTree } = about3Pane;
+
+add_setup(async function () {
+ // Create an account for the test.
+ MailServices.accounts.createLocalMailAccount();
+ const account = MailServices.accounts.accounts[0];
+ account.addIdentity(MailServices.accounts.createIdentity());
+
+ // Create a folder for the account to store test messages.
+ const rootFolder = account.incomingServer.rootFolder;
+ rootFolder.createSubfolder("statusFeedback", null);
+ const testFolder = rootFolder
+ .getChildNamed("statusFeedback")
+ .QueryInterface(Ci.nsIMsgLocalMailFolder);
+
+ // Generate a test message.
+ const generator = new MessageGenerator();
+ testFolder.addMessage(generator.makeMessage().toMboxString());
+
+ // Use the test folder.
+ about3Pane.displayFolder(testFolder.URI);
+ await ensure_cards_view();
+
+ // Remove test account on cleanup.
+ registerCleanupFunction(() => {
+ MailServices.accounts.removeAccount(account, false);
+ });
+});
+
+/**
+ * Tests that the correct status message appears when opening a message.
+ */
+add_task(async function testMessageOpen() {
+ const row = threadTree.getRowAtIndex(0);
+ const subjectLine = row.querySelector(
+ ".thread-card-subject-container .subject"
+ );
+
+ // Click on the email.
+ const selectPromise = BrowserTestUtils.waitForEvent(threadTree, "select");
+ EventUtils.synthesizeMouseAtCenter(
+ subjectLine,
+ { clickCount: 1 },
+ about3Pane
+ );
+ await selectPromise;
+
+ // Check the value of the status message.
+ Assert.equal(
+ statusText.value,
+ "Loading Messageā€¦",
+ "correct status message is shown"
+ );
+
+ // Check that the status message eventually reset
+ await TestUtils.waitForCondition(
+ () => statusText.value == "",
+ "status message should eventually reset"
+ );
+});