Skip to content

Commit f7d8558

Browse files
Add rustdoc-gui test to ensure sidebars share the same image
1 parent 934e86b commit f7d8558

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/rustdoc-gui/sidebar.goml

+36
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,42 @@ assert-position-false: (".sidebar-crate > h2 > a", {"x": -3})
199199
drag-and-drop: ((205, 100), (108, 100))
200200
assert-position: (".sidebar-crate > h2 > a", {"x": -3})
201201

202+
// Check that the mobile sidebar and the source sidebar use the same icon.
203+
store-css: (".mobile-topbar .sidebar-menu-toggle::before", {"content": image_url})
204+
// Then we go to a source page.
205+
click: ".main-heading .src"
206+
assert-css: ("#sidebar-button a::before", {"content": |image_url|})
207+
// Check that hover events work as expected.
208+
store-css: ("#sidebar-button a", {"background-color": sidebar_background})
209+
move-cursor-to: "#sidebar-button a"
210+
store-css: ("#sidebar-button a:hover", {"background-color": sidebar_background_hover})
211+
assert: |sidebar_background| != |sidebar_background_hover|
212+
click: "#sidebar-button a"
213+
wait-for: "html.src-sidebar-expanded"
214+
assert-css: ("#sidebar-button a:hover", {"background-color": |sidebar_background_hover|})
215+
move-cursor-to: "#settings-menu"
216+
assert-css: ("#sidebar-button a:not(:hover)", {"background-color": |sidebar_background|})
217+
// Closing sidebar.
218+
click: "#sidebar-button a"
219+
wait-for: "html:not(.src-sidebar-expanded)"
220+
// Now we check the same when the sidebar button is moved alongside the search.
221+
set-window-size: (500, 500)
222+
store-css: ("#sidebar-button a:hover", {"background-color": not_sidebar_background_hover})
223+
move-cursor-to: "#settings-menu"
224+
store-css: ("#sidebar-button a:not(:hover)", {"background-color": not_sidebar_background})
225+
// The sidebar background is supposed to be the same as the main background.
226+
assert-css: ("body", {"background-color": |not_sidebar_background|})
227+
assert: |not_sidebar_background| != |not_sidebar_background_hover| && |not_sidebar_background| != |sidebar_background|
228+
// The hover background is supposed to be the same as the sidebar background.
229+
assert: |not_sidebar_background_hover| == |sidebar_background|
230+
click: "#sidebar-button a"
231+
wait-for: "html.src-sidebar-expanded"
232+
// And now the background colors are supposed to be the same as the sidebar since the sidebar has
233+
// been open.
234+
assert-css: ("#sidebar-button a:hover", {"background-color": |sidebar_background_hover|})
235+
move-cursor-to: "h2"
236+
assert-css: ("#sidebar-button a:not(:hover)", {"background-color": |sidebar_background|})
237+
202238
// Configuration option to show TOC in sidebar.
203239
set-local-storage: {"rustdoc-hide-toc": "true"}
204240
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"

0 commit comments

Comments
 (0)