summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/browser/browser_newtab_header.js
blob: adfecbe71f07ae1babd59dbdbfa1a0a440351f0d (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
"use strict";

// Tests that:
// 1. Top sites header is hidden and the topsites section is not collapsed on load.
// 2. Pocket header and section are visible and not collapsed on load.
// 3. Recent activity section and header are visible and not collapsed on load.
test_newtab({
  test: async function test_render_customizeMenu() {
    // Top sites section
    await ContentTaskUtils.waitForCondition(
      () => content.document.querySelector(".top-sites"),
      "Wait for the top sites section to load"
    );

    let topSitesSection = content.document.querySelector(".top-sites");
    let titleContainer = topSitesSection.querySelector(
      ".section-title-container"
    );
    ok(
      titleContainer && titleContainer.style.visibility === "hidden",
      "Top sites header should  not be visible"
    );

    let isTopSitesCollapsed = topSitesSection.className.includes("collapsed");
    ok(!isTopSitesCollapsed, "Top sites should not be collapsed on load");

    // Pocket section
    await ContentTaskUtils.waitForCondition(
      () =>
        content.document.querySelector("section[data-section-id='topstories']"),
      "Wait for the pocket section to load"
    );

    let pocketSection = content.document.querySelector(
      "section[data-section-id='topstories']"
    );
    let isPocketSectionCollapsed =
      pocketSection.className.includes("collapsed");
    ok(
      !isPocketSectionCollapsed,
      "Pocket section should not be collapsed on load"
    );

    let pocketHeader = content.document.querySelector(
      "section[data-section-id='topstories'] .section-title"
    );
    ok(
      pocketHeader && !pocketHeader.style.visibility,
      "Pocket header should be visible"
    );

    // Highlights (Recent activity) section.
    await ContentTaskUtils.waitForCondition(
      () =>
        content.document.querySelector("section[data-section-id='highlights']"),
      "Wait for the highlights section to load"
    );
    let highlightsSection = content.document.querySelector(
      "section[data-section-id='topstories']"
    );
    let isHighlightsSectionCollapsed =
      highlightsSection.className.includes("collapsed");
    ok(
      !isHighlightsSectionCollapsed,
      "Highlights section should not be collapsed on load"
    );

    let highlightsHeader = content.document.querySelector(
      "section[data-section-id='highlights'] .section-title"
    );
    ok(
      highlightsHeader && !highlightsHeader.style.visibility,
      "Highlights header should be visible"
    );
  },
});