about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-05-05 21:56:40 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2022-05-06 13:52:21 +0200
commitfb2f97a37e8a3541368004daa5ddb38ec3048fe8 (patch)
tree70e649058b5359fbce2ea1e9fc50a9a0ba1d78a1
parent279dee5374dbaaf7c33ddb584bf29061a4971e05 (diff)
downloadrust-fb2f97a37e8a3541368004daa5ddb38ec3048fe8.tar.gz
rust-fb2f97a37e8a3541368004daa5ddb38ec3048fe8.zip
Add GUI test for search reexports
-rw-r--r--src/test/rustdoc-gui/search-reexport.goml29
-rw-r--r--src/test/rustdoc-gui/sidebar.goml19
-rw-r--r--src/test/rustdoc-gui/src/test_docs/lib.rs3
3 files changed, 42 insertions, 9 deletions
diff --git a/src/test/rustdoc-gui/search-reexport.goml b/src/test/rustdoc-gui/search-reexport.goml
new file mode 100644
index 00000000000..557781d4810
--- /dev/null
+++ b/src/test/rustdoc-gui/search-reexport.goml
@@ -0,0 +1,29 @@
+// Checks that the reexports are present in the search index, can have
+// doc aliases and are highligted when their ID is the hash of the page.
+goto: file://|DOC_PATH|/test_docs/index.html
+local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
+reload:
+// First we check that the reexport has the correct ID and no background color.
+assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;")
+assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"})
+write: (".search-input", "TheStdReexport")
+wait-for: "//a[@class='result-import']"
+assert-attribute: (
+    "//a[@class='result-import']",
+    {"href": "../test_docs/index.html#reexport.TheStdReexport"},
+)
+assert-text: ("//a[@class='result-import']", "test_docs::TheStdReexport")
+click: "//a[@class='result-import']"
+// We check that it has the background modified thanks to the focus.
+wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"})
+
+// We now check that the alias is working as well on the reexport.
+write: (".search-input", "AliasForTheStdReexport")
+wait-for: "//a[@class='result-import']"
+assert-text: (
+    "//a[@class='result-import']",
+    "AliasForTheStdReexport - see test_docs::TheStdReexport",
+)
+// Same thing again, we click on it to ensure the background is once again set as expected.
+click: "//a[@class='result-import']"
+wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"})
diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml
index 6b79b00d3f7..32fe3334f36 100644
--- a/src/test/rustdoc-gui/sidebar.goml
+++ b/src/test/rustdoc-gui/sidebar.goml
@@ -13,15 +13,16 @@ assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
 // We check that we have the crates list and that the "current" on is "test_docs".
 assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs")
 // And we're also supposed to have the list of items in the current module.
-assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Modules")
-assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Macros")
-assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Structs")
-assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Enums")
-assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Traits")
-assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Functions")
-assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Type Definitions")
-assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Unions")
-assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Keywords")
+assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
+assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
+assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
+assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
+assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
+assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits")
+assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions")
+assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions")
+assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions")
+assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords")
 assert-text: ("#structs + .item-table .item-left > a", "Foo")
 click: "#structs + .item-table .item-left > a"
 
diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs
index 348b1a65c78..b6fe9eb2565 100644
--- a/src/test/rustdoc-gui/src/test_docs/lib.rs
+++ b/src/test/rustdoc-gui/src/test_docs/lib.rs
@@ -274,3 +274,6 @@ impl EmptyTrait3 for HasEmptyTraits {}
 
 mod macros;
 pub use macros::*;
+
+#[doc(alias = "AliasForTheStdReexport")]
+pub use ::std as TheStdReexport;