Skip to content

Commit fb2f97a

Browse files
Add GUI test for search reexports
1 parent 279dee5 commit fb2f97a

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Checks that the reexports are present in the search index, can have
2+
// doc aliases and are highligted when their ID is the hash of the page.
3+
goto: file://|DOC_PATH|/test_docs/index.html
4+
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
5+
reload:
6+
// First we check that the reexport has the correct ID and no background color.
7+
assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;")
8+
assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"})
9+
write: (".search-input", "TheStdReexport")
10+
wait-for: "//a[@class='result-import']"
11+
assert-attribute: (
12+
"//a[@class='result-import']",
13+
{"href": "../test_docs/index.html#reexport.TheStdReexport"},
14+
)
15+
assert-text: ("//a[@class='result-import']", "test_docs::TheStdReexport")
16+
click: "//a[@class='result-import']"
17+
// We check that it has the background modified thanks to the focus.
18+
wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"})
19+
20+
// We now check that the alias is working as well on the reexport.
21+
write: (".search-input", "AliasForTheStdReexport")
22+
wait-for: "//a[@class='result-import']"
23+
assert-text: (
24+
"//a[@class='result-import']",
25+
"AliasForTheStdReexport - see test_docs::TheStdReexport",
26+
)
27+
// Same thing again, we click on it to ensure the background is once again set as expected.
28+
click: "//a[@class='result-import']"
29+
wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"})

src/test/rustdoc-gui/sidebar.goml

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
1313
// We check that we have the crates list and that the "current" on is "test_docs".
1414
assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs")
1515
// And we're also supposed to have the list of items in the current module.
16-
assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Modules")
17-
assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Macros")
18-
assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Structs")
19-
assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Enums")
20-
assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Traits")
21-
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Functions")
22-
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Type Definitions")
23-
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Unions")
24-
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Keywords")
16+
assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
17+
assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
18+
assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
19+
assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
20+
assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
21+
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits")
22+
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions")
23+
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions")
24+
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions")
25+
assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords")
2526
assert-text: ("#structs + .item-table .item-left > a", "Foo")
2627
click: "#structs + .item-table .item-left > a"
2728

src/test/rustdoc-gui/src/test_docs/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,6 @@ impl EmptyTrait3 for HasEmptyTraits {}
274274

275275
mod macros;
276276
pub use macros::*;
277+
278+
#[doc(alias = "AliasForTheStdReexport")]
279+
pub use ::std as TheStdReexport;

0 commit comments

Comments
 (0)