Skip to content

Commit 4967895

Browse files
Move search-result-color.goml common parts into a function
1 parent 7659ef4 commit 4967895

File tree

1 file changed

+52
-69
lines changed

1 file changed

+52
-69
lines changed

tests/rustdoc-gui/search-result-color.goml

+52-69
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
// The goal of this test is to ensure the color of the text is the one expected.
22

33
include: "utils.goml"
4+
5+
define-function: (
6+
"check-search-color",
7+
[theme, count_color, desc_color, path_color, bottom_border_color],
8+
block {
9+
call-function: ("switch-theme", {"theme": |theme|})
10+
11+
// Waiting for the search results to appear...
12+
wait-for: "#search-tabs"
13+
assert-css: (
14+
"#search-tabs > button > .count",
15+
{"color": |count_color|},
16+
ALL,
17+
)
18+
assert-css: (
19+
"//*[@class='desc'][text()='Just a normal struct.']",
20+
{"color": |desc_color|},
21+
)
22+
assert-css: (
23+
"//*[@class='result-name']//*[text()='test_docs::']",
24+
{"color": |path_color|},
25+
)
26+
27+
// Checking the color of the bottom border.
28+
assert-css: (
29+
".search-results > a",
30+
{"border-bottom-color": |bottom_border_color|}
31+
)
32+
}
33+
)
34+
435
define-function: (
536
"check-result-color",
637
[result_kind, color, hover_color],
@@ -44,29 +75,13 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
4475
show-text: true
4576

4677
// Ayu theme
47-
call-function: ("switch-theme", {"theme": "ayu"})
48-
49-
// Waiting for the search results to appear...
50-
wait-for: "#search-tabs"
51-
assert-css: (
52-
"#search-tabs > button > .count",
53-
{"color": "#888"},
54-
ALL,
55-
)
56-
assert-css: (
57-
"//*[@class='desc'][text()='Just a normal struct.']",
58-
{"color": "#c5c5c5"},
59-
)
60-
assert-css: (
61-
"//*[@class='result-name']//*[text()='test_docs::']",
62-
{"color": "#0096cf"},
63-
)
64-
65-
// Checking the color of the bottom border.
66-
assert-css: (
67-
".search-results > a",
68-
{"border-bottom-color": "#aaa3"}
69-
)
78+
call-function: ("check-search-color", {
79+
"theme": "ayu",
80+
"count_color": "#888",
81+
"desc_color": "#c5c5c5",
82+
"path_color": "#0096cf",
83+
"bottom_border_color": "#aaa3",
84+
})
7085

7186
store-value: (entry_color, "#0096cf") // color of the search entry
7287
store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry
@@ -152,29 +167,13 @@ assert-css: (
152167
)
153168

154169
// Dark theme
155-
call-function: ("switch-theme", {"theme": "dark"})
156-
157-
// Waiting for the search results to appear...
158-
wait-for: "#search-tabs"
159-
assert-css: (
160-
"#search-tabs > button > .count",
161-
{"color": "#888"},
162-
ALL,
163-
)
164-
assert-css: (
165-
"//*[@class='desc'][text()='Just a normal struct.']",
166-
{"color": "#ddd"},
167-
)
168-
assert-css: (
169-
"//*[@class='result-name']//*[text()='test_docs::']",
170-
{"color": "#ddd"},
171-
)
172-
173-
// Checking the color of the bottom border.
174-
assert-css: (
175-
".search-results > a",
176-
{"border-bottom-color": "#aaa3"}
177-
)
170+
call-function: ("check-search-color", {
171+
"theme": "dark",
172+
"count_color": "#888",
173+
"desc_color": "#ddd",
174+
"path_color": "#ddd",
175+
"bottom_border_color": "#aaa3",
176+
})
178177

179178
store-value: (entry_color, "#ddd") // color of the search entry
180179
store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry
@@ -248,29 +247,13 @@ assert-css: (
248247
)
249248

250249
// Light theme
251-
call-function: ("switch-theme", {"theme": "light"})
252-
253-
// Waiting for the search results to appear...
254-
wait-for: "#search-tabs"
255-
assert-css: (
256-
"#search-tabs > button > .count",
257-
{"color": "#888"},
258-
ALL,
259-
)
260-
assert-css: (
261-
"//*[@class='desc'][text()='Just a normal struct.']",
262-
{"color": "#000"},
263-
)
264-
assert-css: (
265-
"//*[@class='result-name']//*[text()='test_docs::']",
266-
{"color": "#000"},
267-
)
268-
269-
// Checking the color of the bottom border.
270-
assert-css: (
271-
".search-results > a",
272-
{"border-bottom-color": "#aaa3"}
273-
)
250+
call-function: ("check-search-color", {
251+
"theme": "light",
252+
"count_color": "#888",
253+
"desc_color": "#000",
254+
"path_color": "#000",
255+
"bottom_border_color": "#aaa3",
256+
})
274257

275258
store-value: (entry_color, "#000") // color of the search entry
276259
store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry

0 commit comments

Comments
 (0)