summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/account/browser_accountHub.js
blob: 8fc459a6669b5195df2698cbdcc3f44cd25e26ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* 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/. */

"use strict";

// TODO: Defer this for when the account hub replaces the account setup tab.
// add_task(async function test_account_hub_opening_at_startup() {});

add_task(async function test_account_hub_opening() {
  // TODO: Use an actual button once it's implemented in the UI.
  // Open the dialog.
  await window.openAccountHub();

  const hub = document.querySelector("account-hub-container");
  await TestUtils.waitForCondition(
    () => hub.modal,
    "The dialog element was created"
  );

  const dialog = hub.shadowRoot.querySelector(".account-hub-dialog");
  Assert.ok(dialog.open, "The dialog element was opened");

  EventUtils.synthesizeKey("VK_ESCAPE", {}, window);
  await TestUtils.waitForCondition(
    () => !dialog.open,
    "The dialog element was closed"
  );

  // Open the dialog again.
  await window.openAccountHub();
  Assert.ok(dialog.open, "The dialog element was opened");

  // We already have a tinderbox account, so the default header should be
  // visible and the welcome header should be hidden.
  Assert.ok(
    !hub.shadowRoot.querySelector("#defaultHeader").hidden,
    "The #defaultHeader is visible"
  );
  Assert.ok(
    hub.shadowRoot.querySelector("#welcomeHeader").hidden,
    "The #welcomeHeader is hidden"
  );

  EventUtils.synthesizeMouseAtCenter(
    hub.shadowRoot.querySelector("#closeButton"),
    {},
    window
  );
  await TestUtils.waitForCondition(
    () => !dialog.open,
    "The dialog element was closed"
  );
});