summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-gui/search-tab.goml
blob: 427201e1b5da48dccafe2d877b87b193e9e54de9 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Checking the colors of the search tab headers.
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=foo"
show-text: true

define-function: (
    "check-colors",
    (theme, background, background_selected, background_hover, border_bottom,
     border_bottom_selected, border_bottom_hover, border_top, border_top_selected,
     border_top_hover),
    block {
        // Setting the theme.
        set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
        reload:

        // These two commands are used to be sure the search will be run.
        focus: ".search-input"
        press-key: "Enter"

        wait-for: "#search-tabs"
        assert-css: ("#search-tabs > button:not(.selected)", {
            "background-color": |background|,
            "border-bottom": |border_bottom|,
            "border-top": |border_top|,
        })
        assert-css: ("#search-tabs > button.selected", {
            "background-color": |background_selected|,
            "border-bottom": |border_bottom_selected|,
            "border-top": |border_top_selected|,
        })
        move-cursor-to: "#search-tabs > button:not(.selected)"
        assert-css: ("#search-tabs > button:not(.selected):hover", {
            "background-color": |background_hover|,
            "border-bottom": |border_bottom_hover|,
            "border-top": |border_top_hover|,
        })
        // To prevent disrupting next run of this function.
        move-cursor-to: ".search-input"
    },
)

call-function: ("check-colors", {
    "theme": "ayu",
    "background": "transparent",
    "background_selected": "#141920",
    "background_hover": "transparent",
    "border_bottom": "0px none #c5c5c5",
    "border_bottom_selected": "1px solid #ffb44c",
    "border_bottom_hover": "1px solid rgba(242, 151, 24, 0.3)",
    "border_top": "0px none #c5c5c5",
    "border_top_selected": "0px none #c5c5c5",
    "border_top_hover": "0px none #c5c5c5",
})
call-function: ("check-colors", {
    "theme": "dark",
    "background": "#252525",
    "background_selected": "#353535",
    "background_hover": "#353535",
    "border_bottom": "0px none #ddd",
    "border_bottom_selected": "0px none #ddd",
    "border_bottom_hover": "0px none #ddd",
    "border_top": "2px solid #252525",
    "border_top_selected": "2px solid #0089ff",
    "border_top_hover": "2px solid #0089ff",
})
call-function: ("check-colors", {
    "theme": "light",
    "background": "#e6e6e6",
    "background_selected": "#fff",
    "background_hover": "#fff",
    "border_bottom": "0px none #000",
    "border_bottom_selected": "0px none #000",
    "border_bottom_hover": "0px none #000",
    "border_top": "2px solid #e6e6e6",
    "border_top_selected": "2px solid #0089ff",
    "border_top_hover": "2px solid #0089ff",
})

// set size wide enough that the text is in a single row
set-window-size: (851, 600)

// Check the size and count in tabs
assert-text: ("#search-tabs > button:nth-child(1) > .count", " (23) ")
assert-text: ("#search-tabs > button:nth-child(2) > .count", " (4)  ")
assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ")
store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})
assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|})
assert-property: ("#search-tabs > button:nth-child(3)", {"offsetWidth": |buttonWidth|})
store-property: ("#search-tabs > button:nth-child(1) > .count", {"offsetWidth": countWidth})
assert-property: ("#search-tabs > button:nth-child(2) > .count", {"offsetWidth": |countWidth|})
assert-property: ("#search-tabs > button:nth-child(3) > .count", {"offsetWidth": |countWidth|})

// Check that counts are in a row with each other
compare-elements-position: (
    "#search-tabs > button:nth-child(1) > .count",
    "#search-tabs > button:nth-child(2) > .count",
    ("y")
)
compare-elements-position: (
    "#search-tabs > button:nth-child(2) > .count",
    "#search-tabs > button:nth-child(3) > .count",
    ("y")
)
// Check that counts are beside the titles and haven't wrapped
compare-elements-position-near: (
    "#search-tabs > button:nth-child(1)",
    "#search-tabs > button:nth-child(1) > .count",
    {"y": 8}
)
compare-elements-position-near: (
    "#search-tabs > button:nth-child(2)",
    "#search-tabs > button:nth-child(2) > .count",
    {"y": 8}
)
compare-elements-position-near: (
    "#search-tabs > button:nth-child(2)",
    "#search-tabs > button:nth-child(2) > .count",
    {"y": 8}
)

// Set size narrow enough that they wrap.
// When I tested it, it wrapped at 811px, but I added some fudge factor to ensure it
// doesn't prematurely wrap with slightly different font kerning or whatever, with a
// @media query
set-window-size: (850, 600)

// all counts and buttons still have same size
store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})
assert-property: ("#search-tabs > button:nth-child(2)", {"offsetWidth": |buttonWidth|})
assert-property: ("#search-tabs > button:nth-child(3)", {"offsetWidth": |buttonWidth|})
store-property: ("#search-tabs > button:nth-child(1) > .count", {"offsetWidth": countWidth})
assert-property: ("#search-tabs > button:nth-child(2) > .count", {"offsetWidth": |countWidth|})
assert-property: ("#search-tabs > button:nth-child(3) > .count", {"offsetWidth": |countWidth|})

// Check that counts are still in a row with each other
compare-elements-position: (
    "#search-tabs > button:nth-child(1) > .count",
    "#search-tabs > button:nth-child(2) > .count",
    ("y")
)
compare-elements-position: (
    "#search-tabs > button:nth-child(2) > .count",
    "#search-tabs > button:nth-child(3) > .count",
    ("y")
)
// Check that counts are NOT beside the titles; now they have wrapped
compare-elements-position-near-false: (
    "#search-tabs > button:nth-child(1)",
    "#search-tabs > button:nth-child(1) > .count",
    {"y": 8}
)
compare-elements-position-near-false: (
    "#search-tabs > button:nth-child(2)",
    "#search-tabs > button:nth-child(2) > .count",
    {"y": 8}
)
compare-elements-position-near-false: (
    "#search-tabs > button:nth-child(2)",
    "#search-tabs > button:nth-child(2) > .count",
    {"y": 8}
)