Skip to content

Commit a70c14a

Browse files
Add GUI test for sidebar items expand/collapse
1 parent df9fea2 commit a70c14a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Checks that the interactions with the source code pages are workined as expected.
1+
// Checks that the interactions with the source code pages are working as expected.
22
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
33
// Check that we can click on the line number.
44
click: ".line-numbers > span:nth-child(4)" // This is the span for line 4.
@@ -27,3 +27,26 @@ assert-position: ("//*[@id='1']", {"x": 104, "y": 103})
2727
// We click on the left of the "1" span but still in the "line-number" `<pre>`.
2828
click: (103, 103)
2929
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
30+
31+
// Checking the source code sidebar.
32+
33+
// First we "open" it.
34+
click: "#sidebar-toggle"
35+
assert: ".sidebar.expanded"
36+
37+
// We check that the first entry of the sidebar is collapsed (which, for whatever reason,
38+
// is number 2 and not 1...).
39+
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
40+
assert-text: ("#source-sidebar .name:nth-child(2)", "implementors")
41+
// We also check its children are hidden too.
42+
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
43+
// We now click on it.
44+
click: "#source-sidebar .name:nth-child(2)"
45+
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name expand"})
46+
// Checking that its children are displayed as well.
47+
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "block"})
48+
49+
// And now we collapse it again.
50+
click: "#source-sidebar .name:nth-child(2)"
51+
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
52+
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})

0 commit comments

Comments
 (0)