2021-12-14 10:48:49 +00:00
|
|
|
// The goal of this test is to ensure that the sidebar is working as expected in the source
|
|
|
|
// code pages.
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
2022-12-27 20:59:00 +00:00
|
|
|
show-text: true
|
|
|
|
|
|
|
|
// First, check the sidebar colors.
|
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(theme, color, background_color),
|
2023-01-06 14:18:51 +00:00
|
|
|
block {
|
2023-04-11 17:11:34 +00:00
|
|
|
set-local-storage: {
|
2022-12-27 20:59:00 +00:00
|
|
|
"rustdoc-theme": |theme|,
|
|
|
|
"rustdoc-use-system-theme": "false",
|
2023-01-06 14:18:51 +00:00
|
|
|
}
|
|
|
|
reload:
|
2022-12-27 20:59:00 +00:00
|
|
|
// Checking results colors.
|
2023-01-06 14:18:51 +00:00
|
|
|
assert-css: (".source .sidebar", {
|
|
|
|
"color": |color|,
|
|
|
|
"background-color": |background_color|
|
|
|
|
}, ALL)
|
|
|
|
},
|
2022-12-27 20:59:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
2023-01-06 14:18:51 +00:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "ayu",
|
|
|
|
"color": "rgb(197, 197, 197)",
|
|
|
|
"background_color": "rgb(20, 25, 31)",
|
|
|
|
}
|
2022-12-27 20:59:00 +00:00
|
|
|
)
|
|
|
|
call-function: (
|
2023-01-06 14:18:51 +00:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "dark",
|
|
|
|
"color": "rgb(221, 221, 221)",
|
|
|
|
"background_color": "rgb(80, 80, 80)",
|
|
|
|
}
|
2022-12-27 20:59:00 +00:00
|
|
|
)
|
|
|
|
call-function: (
|
2023-01-06 14:18:51 +00:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "light",
|
|
|
|
"color": "rgb(0, 0, 0)",
|
|
|
|
"background_color": "rgb(245, 245, 245)",
|
|
|
|
}
|
2022-12-27 20:59:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Next, desktop mode layout.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (1100, 800)
|
2021-12-14 10:48:49 +00:00
|
|
|
// We check that the sidebar isn't expanded and has the expected width.
|
|
|
|
assert-css: ("nav.sidebar", {"width": "50px"})
|
|
|
|
// We now click on the button to expand the sidebar.
|
|
|
|
click: (10, 10)
|
2022-03-21 14:50:05 +00:00
|
|
|
// We wait for the sidebar to be expanded.
|
2022-06-20 19:41:11 +00:00
|
|
|
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
|
|
|
|
assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
|
2021-12-14 10:48:49 +00:00
|
|
|
// We collapse the sidebar.
|
|
|
|
click: (10, 10)
|
|
|
|
// We ensure that the class has been removed.
|
2022-06-20 19:41:11 +00:00
|
|
|
wait-for: "html:not(.expanded)"
|
2021-12-14 10:48:49 +00:00
|
|
|
assert: "nav.sidebar"
|
|
|
|
|
2022-07-17 12:12:03 +00:00
|
|
|
// Checking that only the path to the current file is "open".
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html"
|
2022-07-17 12:12:03 +00:00
|
|
|
// First we expand the sidebar again.
|
|
|
|
click: (10, 10)
|
|
|
|
// We wait for the sidebar to be expanded.
|
|
|
|
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"})
|
|
|
|
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
|
|
|
|
assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
|
|
|
|
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
|
|
|
|
// Only "another_folder" should be "open" in "lib2".
|
|
|
|
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
|
|
|
|
// All other trees should be collapsed.
|
2023-04-12 13:17:33 +00:00
|
|
|
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
|
2022-07-17 12:12:03 +00:00
|
|
|
|
2021-12-14 10:48:49 +00:00
|
|
|
// We now switch to mobile mode.
|
2023-04-11 17:11:34 +00:00
|
|
|
set-window-size: (600, 600)
|
2023-01-06 19:20:03 +00:00
|
|
|
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"})
|
2021-12-14 10:48:49 +00:00
|
|
|
// We collapse the sidebar.
|
|
|
|
click: (10, 10)
|
2023-01-06 19:20:03 +00:00
|
|
|
// We check that the sidebar has been moved off-screen.
|
|
|
|
assert-css: ("nav.sidebar", {"left": "-1000px"})
|
2021-12-14 10:48:49 +00:00
|
|
|
// We ensure that the class has been removed.
|
2022-06-20 19:41:11 +00:00
|
|
|
assert-false: ".source-sidebar-expanded"
|
2021-12-14 10:48:49 +00:00
|
|
|
assert: "nav.sidebar"
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
|
|
|
|
// Check that the topbar is not visible
|
2022-10-08 17:43:23 +00:00
|
|
|
assert-false: ".mobile-topbar"
|