Skip to content

Commit 98bceb0

Browse files
Add GUI test for source code sidebar auto-expand
1 parent 3024d39 commit 98bceb0

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

src/test/rustdoc-gui/sidebar-source-code.goml

+17-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,27 @@ click: (10, 10)
1616
wait-for: "html:not(.expanded)"
1717
assert: "nav.sidebar"
1818

19+
// Checking that only the path to the current file is "open".
20+
goto: file://|DOC_PATH|/src/lib2/another_folder/sub_mod/mod.rs.html
21+
// First we expand the sidebar again.
22+
click: (10, 10)
23+
// We wait for the sidebar to be expanded.
24+
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
25+
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
26+
assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
27+
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
28+
// Only "another_folder" should be "open" in "lib2".
29+
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
30+
// All other trees should be collapsed.
31+
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 5)
32+
1933
// We now switch to mobile mode.
2034
size: (600, 600)
21-
// We check that the sidebar has the expected width (0).
22-
assert-css: ("nav.sidebar", {"width": "0px"})
23-
// We expand the sidebar.
24-
click: "#sidebar-toggle"
25-
assert-css: (".source-sidebar-expanded nav.sidebar", {"width": "600px"})
35+
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "600px"})
2636
// We collapse the sidebar.
2737
click: (10, 10)
38+
// We check that the sidebar has the expected width (0).
39+
assert-css: ("nav.sidebar", {"width": "0px"})
2840
// We ensure that the class has been removed.
2941
assert-false: ".source-sidebar-expanded"
3042
assert: "nav.sidebar"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn another_fn() {}
2+
3+
pub mod sub_mod;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn subsubsub() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn tadam() {}

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

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#![feature(doc_cfg)]
44

5+
pub mod another_folder;
6+
pub mod another_mod;
7+
58
pub mod module {
69
pub mod sub_module {
710
pub mod sub_sub_module {

0 commit comments

Comments
 (0)