about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-05-21 15:05:56 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2022-05-30 16:38:53 +0200
commitb8db8cc10f5d3a28d75f89680f2734e24cd1490c (patch)
tree0930daa238f44b0cb79eb14a0dba4f7844257647
parent07596fefc114335c5f4c8cc3ed5b7361b17cf91b (diff)
downloadrust-b8db8cc10f5d3a28d75f89680f2734e24cd1490c.tar.gz
rust-b8db8cc10f5d3a28d75f89680f2734e24cd1490c.zip
Add GUI test for `<details>`/`<summary>` display
-rw-r--r--src/test/rustdoc-gui/docblock-details.goml23
-rw-r--r--src/test/rustdoc-gui/src/test_docs/lib.rs12
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/rustdoc-gui/docblock-details.goml b/src/test/rustdoc-gui/docblock-details.goml
new file mode 100644
index 00000000000..2edbf1e4e2d
--- /dev/null
+++ b/src/test/rustdoc-gui/docblock-details.goml
@@ -0,0 +1,23 @@
+// This ensures that the `<details>`/`<summary>` elements are displayed as expected.
+goto: file://|DOC_PATH|/test_docs/details/struct.Details.html
+show-text: true
+local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
+reload:
+
+// We first check that the headers in the `.top-doc` doc block still have their
+// bottom border.
+assert-text: (".top-doc .docblock > h3", "Hello")
+assert-css: (
+    ".top-doc .docblock > h3",
+    {"border-bottom": "1px solid rgb(221, 221, 221)"},
+)
+// We now check that the `<summary>` doesn't have a bottom border and has the correct display.
+assert-css: (
+    ".top-doc .docblock summary h4",
+    {"border-bottom": "0px none rgb(221, 221, 221)"},
+)
+// This allows to ensure that summary is on one line only!
+assert-property: (".top-doc .docblock summary h4", {"offsetHeight": "33"})
+assert-css: (".top-doc .docblock summary h4", {"margin-top": "15px", "margin-bottom": "5px"})
+// So `33 + 15 + 5` == `53`
+assert-property: (".top-doc .docblock summary", {"offsetHeight": "53"})
diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs
index b6fe9eb2565..aa2f78289be 100644
--- a/src/test/rustdoc-gui/src/test_docs/lib.rs
+++ b/src/test/rustdoc-gui/src/test_docs/lib.rs
@@ -277,3 +277,15 @@ pub use macros::*;
 
 #[doc(alias = "AliasForTheStdReexport")]
 pub use ::std as TheStdReexport;
+
+pub mod details {
+    /// We check the appearance of the `<details>`/`<summary>` in here.
+    ///
+    /// ## Hello
+    ///
+    /// <details>
+    /// <summary><h4>I'm a summary</h4></summary>
+    /// <div>I'm the content of the details!</div>
+    /// </details>
+    pub struct Details;
+}