summaryrefslogtreecommitdiffstats
path: root/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_import.js
blob: f2ec85001a417e8549c6acaf834eac4790a91fd3 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";
const IMPORT_SCREEN = {
  id: "AW_IMPORT",
  content: {
    primary_button: {
      label: "import",
      action: {
        navigate: true,
        type: "SHOW_MIGRATION_WIZARD",
      },
    },
  },
};

add_task(async function test_wait_import_modal() {
  await setAboutWelcomeMultiStage(
    JSON.stringify([IMPORT_SCREEN, { id: "AW_NEXT", content: {} }])
  );
  const { cleanup, browser } = await openMRAboutWelcome();

  // execution
  await test_screen_content(
    browser,
    "renders IMPORT screen",
    //Expected selectors
    ["main.AW_IMPORT", "button[value='primary_button']"],

    //Unexpected selectors:
    ["main.AW_NEXT"]
  );

  const wizardPromise = BrowserTestUtils.waitForMigrationWizard(window);
  const prefsTab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:preferences"
  );
  await onButtonClick(browser, "button.primary");
  const wizard = await wizardPromise;

  await test_screen_content(
    browser,
    "still shows IMPORT screen",
    //Expected selectors
    ["main.AW_IMPORT", "button[value='primary_button']"],

    //Unexpected selectors:
    ["main.AW_NEXT"]
  );

  await BrowserTestUtils.removeTab(wizard);

  await test_screen_content(
    browser,
    "moved to NEXT screen",
    //Expected selectors
    ["main.AW_NEXT"],

    //Unexpected selectors:
    []
  );

  // cleanup
  await SpecialPowers.popPrefEnv(); // for setAboutWelcomeMultiStage
  BrowserTestUtils.removeTab(prefsTab);
  await cleanup();
});

add_task(async function test_wait_import_spotlight() {
  const spotlightPromise = TestUtils.topicObserved("subdialog-loaded");
  ChromeUtils.importESModule(
    "resource:///modules/asrouter/Spotlight.sys.mjs"
  ).Spotlight.showSpotlightDialog(gBrowser.selectedBrowser, {
    content: { modal: "tab", screens: [IMPORT_SCREEN] },
  });
  const [win] = await spotlightPromise;

  const wizardPromise = BrowserTestUtils.waitForMigrationWizard(window);
  const prefsTab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:preferences"
  );
  win.document
    .querySelector(".onboardingContainer button[value='primary_button']")
    .click();
  const wizard = await wizardPromise;

  await BrowserTestUtils.removeTab(wizard);

  // cleanup
  BrowserTestUtils.removeTab(prefsTab);
});