Skip to content

Commit 5522634

Browse files
committed
Fix search engine test cases
1 parent 0746ecc commit 5522634

File tree

6 files changed

+40
-37
lines changed

6 files changed

+40
-37
lines changed

src/librustdoc/html/static/css/rustdoc.css

+9-6
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ a.anchor,
219219
.mobile-topbar h2 a,
220220
h1 a,
221221
.search-results a,
222+
.search-results li,
222223
.stab,
223224
.result-name i {
224225
color: var(--main-color);
@@ -2070,10 +2071,10 @@ in src-script.js and main.js
20702071
}
20712072

20722073
/* Display an alternating layout on tablets and phones */
2073-
.search-results > a {
2074+
.search-results > li {
20742075
padding: 5px 0px;
20752076
}
2076-
.search-results > a > div.desc, .item-table > li > div.desc {
2077+
.search-results > li > div.desc, .item-table > li > div.desc {
20772078
padding-left: 2em;
20782079
}
20792080
.search-results .result-name {
@@ -2747,17 +2748,19 @@ Original by Dempfi (https://github.com/dempfi/ayu)
27472748
border-right: 1px solid #ffb44c;
27482749
}
27492750

2750-
:root[data-theme="ayu"] .search-results a:hover,
2751-
:root[data-theme="ayu"] .search-results a:focus {
2751+
:root[data-theme="ayu"] .search-results li:hover > a,
2752+
:root[data-theme="ayu"] .search-results li:focus > a,
2753+
:root[data-theme="ayu"] .search-results li > a:hover,
2754+
:root[data-theme="ayu"] .search-results li > a:focus {
27522755
color: #fff !important;
27532756
background-color: #3c3c3c;
27542757
}
27552758

2756-
:root[data-theme="ayu"] .search-results a {
2759+
:root[data-theme="ayu"] .search-results li > a {
27572760
color: #0096cf;
27582761
}
27592762

2760-
:root[data-theme="ayu"] .search-results a div.desc {
2763+
:root[data-theme="ayu"] .search-results li div.desc {
27612764
color: #c5c5c5;
27622765
}
27632766

tests/rustdoc-gui/search-keyboard.goml

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ wait-for: "#search-tabs"
1111
press-key: "ArrowDown"
1212
press-key: "ArrowDown"
1313
press-key: "ArrowDown"
14-
assert: ".search-results.active > a:focus:nth-of-type(3)"
14+
assert: ".search-results.active > li:nth-of-type(3) > a:focus"
1515

1616
// Now switch to the second tab, then back to the first one, then arrow back up.
1717
press-key: "ArrowRight"
18-
assert: ".search-results.active:nth-of-type(2) > a:focus:nth-of-type(1)"
18+
assert: ".search-results.active:nth-of-type(2) > li:nth-of-type(1) > a:focus"
1919
press-key: "ArrowLeft"
20-
assert: ".search-results.active:nth-of-type(1) > a:focus:nth-of-type(3)"
20+
assert: ".search-results.active:nth-of-type(1) > li:nth-of-type(3) > a:focus"
2121
press-key: "ArrowUp"
22-
assert: ".search-results.active > a:focus:nth-of-type(2)"
22+
assert: ".search-results.active > li:nth-of-type(2) > a:focus"
2323
press-key: "ArrowUp"
24-
assert: ".search-results.active > a:focus:nth-of-type(1)"
24+
assert: ".search-results.active > li:nth-of-type(1) > a:focus"
2525
press-key: "ArrowUp"
2626
assert: ".search-input:focus"
2727
press-key: "ArrowDown"
28-
assert: ".search-results.active > a:focus:nth-of-type(1)"
28+
assert: ".search-results.active > li:nth-of-type(1) > a:focus"

tests/rustdoc-gui/search-reexport.goml

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0,
99
write-into: (".search-input", "TheStdReexport")
1010
// To be SURE that the search will be run.
1111
press-key: 'Enter'
12-
wait-for: "//a[@class='result-import']"
12+
wait-for: "//li[@class='result-import']"
1313
assert-attribute: (
14-
"//a[@class='result-import']",
14+
"//li[@class='result-import']/a",
1515
{"href": "../test_docs/index.html#reexport.TheStdReexport"},
1616
)
17-
assert-text: ("a.result-import .result-name", "re-export test_docs::TheStdReexport")
18-
click: "//a[@class='result-import']"
17+
assert-text: ("li.result-import .result-name", "re-export test_docs::TheStdReexport")
18+
click: "//li[@class='result-import']"
1919
// We check that it has the background modified thanks to the focus.
2020
wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "#494a3d"})
2121

2222
// We now check that the alias is working as well on the reexport.
2323
// To be SURE that the search will be run.
2424
press-key: 'Enter'
2525
write-into: (".search-input", "AliasForTheStdReexport")
26-
wait-for: "//a[@class='result-import']"
26+
wait-for: "//li[@class='result-import']"
2727
assert-text: (
28-
"a.result-import .result-name",
28+
"li.result-import .result-name",
2929
"re-export AliasForTheStdReexport - see test_docs::TheStdReexport",
3030
)
3131
// Same thing again, we click on it to ensure the background is once again set as expected.
32-
click: "//a[@class='result-import']"
32+
click: "//li[@class='result-import']"
3333
wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "#494a3d"})

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define-function: (
3030

3131
// Checking the color of the bottom border.
3232
assert-css: (
33-
".search-results > a",
33+
".search-results > li",
3434
{"border-bottom-color": |bottom_border_color|}
3535
)
3636

@@ -85,7 +85,7 @@ define-function: (
8585
move-cursor-to: ".search-input"
8686
focus: ".search-input" // To ensure the `<a>` container isn't focused or hovered.
8787
assert-css: (
88-
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
88+
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::li/a",
8989
{"color": |path_color|, "background-color": "transparent"},
9090
ALL,
9191
)
@@ -97,7 +97,7 @@ define-function: (
9797
{"color": |hover_path_color|},
9898
)
9999
assert-css: (
100-
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
100+
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::li/a",
101101
{"color": |hover_path_color|, "background-color": |hover_background|},
102102
)
103103
}
@@ -109,26 +109,26 @@ define-function: (
109109
block {
110110
assert-css: (".result-" + |result_kind| + " ." + |result_kind|, {"color": |color|}, ALL)
111111
assert-css: (
112-
".result-" + |result_kind|,
112+
".result-" + |result_kind| + "> a",
113113
{"color": |entry_color|, "background-color": |background_color|},
114114
)
115-
move-cursor-to: ".result-" + |result_kind|
115+
move-cursor-to: ".result-" + |result_kind| + "> a"
116116
assert-css: (
117-
".result-" + |result_kind| + ":hover",
117+
".result-" + |result_kind| + " > a:hover",
118118
{"color": |hover_entry_color|, "background-color": |hover_background_color|},
119119
)
120120
assert-css: (
121-
".result-" + |result_kind| + ":hover ." + |result_kind|,
121+
".result-" + |result_kind| + " > a:hover ." + |result_kind|,
122122
{"color": |hover_color|},
123123
)
124124
move-cursor-to: ".search-input"
125-
focus: ".result-" + |result_kind|
125+
focus: ".result-" + |result_kind| + " > a"
126126
assert-css: (
127-
".result-" + |result_kind| + ":focus",
127+
".result-" + |result_kind| + " > a:focus",
128128
{"color": |hover_entry_color|, "background-color": |hover_background_color|},
129129
)
130130
assert-css: (
131-
".result-" + |result_kind| + ":focus ." + |result_kind|,
131+
".result-" + |result_kind| + "> a:focus ." + |result_kind|,
132132
{"color": |hover_color|},
133133
)
134134
// color of the typename (struct, module, method, ...) before search results

tests/rustdoc-gui/search-result-impl-disambiguation.goml

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ press-key: 'Enter'
1111
// Waiting for the search results to appear...
1212
wait-for: "#search-tabs"
1313
// Check the disambiguated link.
14-
assert-count: ("a.result-method", 1)
15-
assert-attribute: ("a.result-method", {
14+
assert-count: ("li.result-method > a", 1)
15+
assert-attribute: ("li.result-method > a", {
1616
"href": "../test_docs/struct.ZyxwvutMethodDisambiguation.html#impl-ZyxwvutMethodDisambiguation/method.method_impl_disambiguation"
1717
})
18-
click: "a.result-method"
18+
click: "li.result-method > a"
1919
wait-for: "#impl-ZyxwvutMethodDisambiguation"
2020
assert-document-property: ({
2121
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation"
@@ -31,11 +31,11 @@ press-key: 'Enter'
3131
// Waiting for the search results to appear...
3232
wait-for: "#search-tabs"
3333
// Check the disambiguated link.
34-
assert-count: ("a.result-method", 1)
35-
assert-attribute: ("a.result-method", {
34+
assert-count: ("li.result-method > a", 1)
35+
assert-attribute: ("li.result-method > a", {
3636
"href": "../test_docs/struct.ZyxwvutMethodDisambiguation.html#impl-ZyxwvutTrait-for-ZyxwvutMethodDisambiguation/method.method_impl_disambiguation"
3737
})
38-
click: "a.result-method"
38+
click: "li.result-method > a"
3939
wait-for: "#impl-ZyxwvutMethodDisambiguation"
4040
assert-document-property: ({
4141
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1"

tests/rustdoc-gui/search-tab-change-title-fn-sig.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ assert-text: ("#search-tabs > button:nth-of-type(1)", "In Names", STARTS_WITH)
1111
assert: "input.search-input:focus"
1212
// Use left-right keys
1313
press-key: "ArrowDown"
14-
assert: "#results > .search-results.active > a:nth-of-type(1):focus"
14+
assert: "#results > .search-results.active > li:nth-of-type(1) > a:focus"
1515
press-key: "ArrowRight"
1616
wait-for-attribute: ("#search-tabs > button:nth-of-type(2)", {"class": "selected"})
1717
press-key: "ArrowRight"
@@ -33,7 +33,7 @@ assert-text: ("#search-tabs > button:nth-of-type(1)", "In Function Return Types"
3333
assert: "input.search-input:focus"
3434
// Use left-right keys
3535
press-key: "ArrowDown"
36-
assert: "#results > .search-results.active > a:nth-of-type(1):focus"
36+
assert: "#results > .search-results.active > li:nth-of-type(1) > a:focus"
3737
press-key: "ArrowRight"
3838
wait-for-attribute: ("#search-tabs > button:nth-of-type(1)", {"class": "selected"})
3939
press-key: "ArrowRight"

0 commit comments

Comments
 (0)