2021-12-14 04:48:49 -06:00
|
|
|
// The goal of this test is to ensure that the sidebar is working as expected in the source
|
|
|
|
// code pages.
|
2022-10-07 13:17:05 -05:00
|
|
|
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
2022-12-27 14:59:00 -06:00
|
|
|
show-text: true
|
|
|
|
|
|
|
|
// First, check the sidebar colors.
|
|
|
|
define-function: (
|
|
|
|
"check-colors",
|
|
|
|
(theme, color, background_color),
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
|
|
|
local-storage: {
|
2022-12-27 14:59:00 -06:00
|
|
|
"rustdoc-theme": |theme|,
|
|
|
|
"rustdoc-use-system-theme": "false",
|
2023-01-06 08:18:51 -06:00
|
|
|
}
|
|
|
|
reload:
|
2022-12-27 14:59:00 -06:00
|
|
|
// Checking results colors.
|
2023-01-06 08:18:51 -06:00
|
|
|
assert-css: (".source .sidebar", {
|
|
|
|
"color": |color|,
|
|
|
|
"background-color": |background_color|
|
|
|
|
}, ALL)
|
|
|
|
},
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
call-function: (
|
2023-01-06 08:18:51 -06:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "ayu",
|
|
|
|
"color": "rgb(197, 197, 197)",
|
|
|
|
"background_color": "rgb(20, 25, 31)",
|
|
|
|
}
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
call-function: (
|
2023-01-06 08:18:51 -06:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "dark",
|
|
|
|
"color": "rgb(221, 221, 221)",
|
|
|
|
"background_color": "rgb(80, 80, 80)",
|
|
|
|
}
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
call-function: (
|
2023-01-06 08:18:51 -06:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "light",
|
|
|
|
"color": "rgb(0, 0, 0)",
|
|
|
|
"background_color": "rgb(245, 245, 245)",
|
|
|
|
}
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// Next, desktop mode layout.
|
2021-12-14 04:48:49 -06:00
|
|
|
size: (1100, 800)
|
|
|
|
// 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 09:50:05 -05:00
|
|
|
// We wait for the sidebar to be expanded.
|
2022-06-20 14:41:11 -05: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 04:48:49 -06:00
|
|
|
// We collapse the sidebar.
|
|
|
|
click: (10, 10)
|
|
|
|
// We ensure that the class has been removed.
|
2022-06-20 14:41:11 -05:00
|
|
|
wait-for: "html:not(.expanded)"
|
2021-12-14 04:48:49 -06:00
|
|
|
assert: "nav.sidebar"
|
|
|
|
|
2022-07-17 07:12:03 -05:00
|
|
|
// Checking that only the path to the current file is "open".
|
2022-10-07 13:17:05 -05:00
|
|
|
goto: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html"
|
2022-07-17 07:12:03 -05: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-01-03 20:46:40 -06:00
|
|
|
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
|
2022-07-17 07:12:03 -05:00
|
|
|
|
2021-12-14 04:48:49 -06:00
|
|
|
// We now switch to mobile mode.
|
|
|
|
size: (600, 600)
|
2023-01-06 13:20:03 -06:00
|
|
|
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"})
|
2021-12-14 04:48:49 -06:00
|
|
|
// We collapse the sidebar.
|
|
|
|
click: (10, 10)
|
2023-01-06 13:20:03 -06:00
|
|
|
// We check that the sidebar has been moved off-screen.
|
|
|
|
assert-css: ("nav.sidebar", {"left": "-1000px"})
|
2021-12-14 04:48:49 -06:00
|
|
|
// We ensure that the class has been removed.
|
2022-06-20 14:41:11 -05:00
|
|
|
assert-false: ".source-sidebar-expanded"
|
2021-12-14 04:48:49 -06: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-06 18:48:24 -06:00
|
|
|
|
|
|
|
// Check that the topbar is not visible
|
2022-10-08 12:43:23 -05:00
|
|
|
assert-false: ".mobile-topbar"
|