Skip to content

Commit a716c79

Browse files
Update GUI tests
1 parent 0c10eb0 commit a716c79

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ assert-css: (
6161
{"color": "#c5c5c5"},
6262
)
6363
assert-css: (
64-
"//*[@class='result-name']/*[text()='test_docs::']",
64+
"//*[@class='result-name']//*[text()='test_docs::']",
6565
{"color": "#0096cf"},
6666
)
6767

@@ -138,19 +138,19 @@ call-function: (
138138
move-cursor-to: ".search-input"
139139
focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
140140
assert-css: (
141-
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
141+
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
142142
{"color": "#0096cf", "background-color": "transparent"},
143143
ALL,
144144
)
145145

146146
// Checking color and background on hover.
147147
move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
148148
assert-css: (
149-
"//*[@class='result-name']/*[text()='test_docs::']",
149+
"//*[@class='result-name']//*[text()='test_docs::']",
150150
{"color": "#fff"},
151151
)
152152
assert-css: (
153-
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
153+
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
154154
{"color": "#fff", "background-color": "rgb(60, 60, 60)"},
155155
)
156156

@@ -173,7 +173,7 @@ assert-css: (
173173
{"color": "#ddd"},
174174
)
175175
assert-css: (
176-
"//*[@class='result-name']/*[text()='test_docs::']",
176+
"//*[@class='result-name']//*[text()='test_docs::']",
177177
{"color": "#ddd"},
178178
)
179179

@@ -250,7 +250,7 @@ call-function: (
250250
move-cursor-to: ".search-input"
251251
focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
252252
assert-css: (
253-
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
253+
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
254254
{"color": "#ddd", "background-color": "transparent"},
255255
)
256256

@@ -270,7 +270,7 @@ assert-css: (
270270
{"color": "#000"},
271271
)
272272
assert-css: (
273-
"//*[@class='result-name']/*[text()='test_docs::']",
273+
"//*[@class='result-name']//*[text()='test_docs::']",
274274
{"color": "#000"},
275275
)
276276

@@ -347,7 +347,7 @@ call-function: (
347347
move-cursor-to: ".search-input"
348348
focus: ".search-input" // To ensure the `<a>` container isnt focus or hover.
349349
assert-css: (
350-
"//*[@class='result-name']/*[text()='test_docs::']/ancestor::a",
350+
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
351351
{"color": "#000", "background-color": "transparent"},
352352
)
353353

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

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-tidy-linelength
12
// Checks that the search results have the expected width.
23
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
34
set-window-size: (900, 1000)
@@ -7,15 +8,40 @@ press-key: 'Enter'
78
wait-for: "#crate-search"
89
// The width is returned by "getComputedStyle" which returns the exact number instead of the
910
// CSS rule which is "50%"...
10-
assert-size: (".search-results div.desc", {"width": 310})
11+
assert-size: (".search-results div.desc", {"width": 248})
12+
store-size: (".search-results .result-name .typename", {"width": width})
1113
set-window-size: (600, 100)
1214
// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
1315
// when computed it's larger.
1416
assert-size: (".search-results div.desc", {"width": 566})
1517

1618
// The result set is all on one line.
17-
assert-css: (".search-results .result-name > span:not(.typename)", {"display": "inline"})
18-
assert-css: (".search-results .result-name > span.typename", {"display": "inline-block"})
19+
compare-elements-position-near: (
20+
".search-results .result-name .typename",
21+
".search-results .result-name .path",
22+
{"y": 2},
23+
)
24+
compare-elements-position-near-false: (
25+
".search-results .result-name .typename",
26+
".search-results .result-name .path",
27+
{"x": 5},
28+
)
29+
// The width of the "typename" isn't fixed anymore in this display mode.
30+
store-size: (".search-results .result-name .typename", {"width": new_width})
31+
assert: |new_width| < |width| - 10
32+
33+
// Check that if the search is too long on mobile, it'll go under the "typename".
34+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName"
35+
wait-for: "#crate-search"
36+
compare-elements-position-near: (
37+
".search-results .result-name .typename",
38+
".search-results .result-name .path",
39+
{"y": 2, "x": 0},
40+
)
41+
store-size: (".search-results .result-name", {"width": width, "height": height})
42+
store-size: (".search-results .result-name .path", {"width": sub_width, "height": sub_height})
43+
assert: |width| < |sub_width| + 8 && |width| > |sub_width| - 8
44+
assert: |height| < |sub_height| + 8 && |height| > |sub_height| - 8
1945

2046
// Check that the crate filter `<select>` is correctly handled when it goes to next line.
2147
// To do so we need to update the length of one of its `<option>`.

0 commit comments

Comments
 (0)