Skip to content

Commit e3cb0a8

Browse files
committed
rustdoc: add regression test for sidebar width jank
1 parent ee8e0bd commit e3cb0a8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/rustdoc-gui/sidebar.goml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Checks multiple things on the sidebar display (width of its elements, colors, etc).
22
goto: file://|DOC_PATH|/test_docs/index.html
3+
assert-property: (".sidebar", {"clientWidth": "200"})
34
show-text: true
45
local-storage: {"rustdoc-theme": "light"}
56
// We reload the page so the local storage settings are being used.
@@ -39,11 +40,13 @@ assert-property: ("html", {"scrollTop": "0"})
3940

4041
// We now go back to the crate page to click on the "lib2" crate link.
4142
goto: file://|DOC_PATH|/test_docs/index.html
43+
assert-property: (".sidebar", {"clientWidth": "200"})
4244
assert-css: (".sidebar-elems .crate > ul > li:first-child > a", {"color": "rgb(53, 109, 164)"})
4345
click: ".sidebar-elems .crate > ul > li:first-child > a"
4446

4547
// PAGE: lib2/index.html
4648
goto: file://|DOC_PATH|/lib2/index.html
49+
assert-property: (".sidebar", {"clientWidth": "200"})
4750
assert-text: (".sidebar > .location", "Crate lib2")
4851
// We check that we have the crates list and that the "current" on is now "lib2".
4952
assert-text: (".sidebar-elems .crate > ul > li > a.current", "lib2")
@@ -65,11 +68,13 @@ assert-text: (".sidebar .sidebar-elems .location", "In lib2")
6568
assert-false: ".sidebar-elems > .crate"
6669

6770
goto: ./module/index.html
71+
assert-property: (".sidebar", {"clientWidth": "200"})
6872
assert-text: (".sidebar > .location", "Module module")
6973
// We check that we don't have the crate list.
7074
assert-false: ".sidebar-elems > .crate"
7175

7276
goto: ./sub_module/sub_sub_module/index.html
77+
assert-property: (".sidebar", {"clientWidth": "200"})
7378
assert-text: (".sidebar > .location", "Module sub_sub_module")
7479
// We check that we don't have the crate list.
7580
assert-false: ".sidebar-elems .crate"
@@ -78,11 +83,21 @@ assert-text: ("#functions + .item-table .item-left > a", "foo")
7883

7984
// Links to trait implementations in the sidebar should not wrap even if they are long.
8085
goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html
86+
assert-property: (".sidebar", {"clientWidth": "200"})
8187
assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29})
8288

8389
// Test that clicking on of the "In <module>" headings in the sidebar links to the
8490
// appropriate anchor in index.html.
8591
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
92+
assert-property: (".sidebar", {"clientWidth": "200"})
8693
click: ".block.mod h3 a"
8794
// PAGE: index.html
8895
assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"})
96+
97+
// Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width.
98+
click: "#toggle-all-docs"
99+
assert-text: ("#toggle-all-docs", "[+]")
100+
assert-property: (".sidebar", {"clientWidth": "200"})
101+
click: "#toggle-all-docs"
102+
assert-text: ("#toggle-all-docs", "[−]")
103+
assert-property: (".sidebar", {"clientWidth": "200"})

0 commit comments

Comments
 (0)