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.
|
2024-04-05 14:38:55 -05:00
|
|
|
include: "utils.goml"
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "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",
|
2024-04-01 14:11:22 -05:00
|
|
|
[theme, color, background_color],
|
2023-01-06 08:18:51 -06:00
|
|
|
block {
|
2024-04-05 14:38:55 -05:00
|
|
|
call-function: ("switch-theme", {"theme": |theme|})
|
2022-12-27 14:59:00 -06:00
|
|
|
// Checking results colors.
|
2023-07-14 18:38:01 -05:00
|
|
|
assert-css: (".src .sidebar", {
|
2023-01-06 08:18:51 -06:00
|
|
|
"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",
|
2023-07-08 07:55:50 -05:00
|
|
|
"color": "#c5c5c5",
|
|
|
|
"background_color": "#14191f",
|
2023-01-06 08:18:51 -06:00
|
|
|
}
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
call-function: (
|
2023-01-06 08:18:51 -06:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "dark",
|
2023-07-08 07:55:50 -05:00
|
|
|
"color": "#ddd",
|
|
|
|
"background_color": "#505050",
|
2023-01-06 08:18:51 -06:00
|
|
|
}
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
call-function: (
|
2023-01-06 08:18:51 -06:00
|
|
|
"check-colors",
|
|
|
|
{
|
|
|
|
"theme": "light",
|
2023-07-08 07:55:50 -05:00
|
|
|
"color": "black",
|
|
|
|
"background_color": "#F5F5F5",
|
2023-01-06 08:18:51 -06:00
|
|
|
}
|
2022-12-27 14:59:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// Next, desktop mode layout.
|
2023-04-11 12:11:34 -05:00
|
|
|
set-window-size: (1100, 800)
|
2023-12-18 00:06:31 -06:00
|
|
|
wait-for: "#sidebar-button"
|
2021-12-14 04:48:49 -06: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.
|
2023-12-18 13:11:14 -06:00
|
|
|
click: "#sidebar-button"
|
2022-03-21 09:50:05 -05:00
|
|
|
// We wait for the sidebar to be expanded.
|
2023-07-14 18:38:01 -05:00
|
|
|
wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
|
|
|
|
assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
|
2021-12-14 04:48:49 -06:00
|
|
|
// We collapse the sidebar.
|
2023-12-18 13:11:14 -06:00
|
|
|
click: "#sidebar-button"
|
2021-12-14 04:48:49 -06:00
|
|
|
// We ensure that the class has been removed.
|
2023-09-07 20:45:24 -05:00
|
|
|
wait-for: "html:not(.src-sidebar-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".
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "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.
|
2023-12-18 13:11:14 -06:00
|
|
|
click: "#sidebar-button"
|
2022-07-17 07:12:03 -05:00
|
|
|
// We wait for the sidebar to be expanded.
|
2023-07-14 18:38:01 -05:00
|
|
|
wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
|
2022-07-17 07:12:03 -05:00
|
|
|
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
|
2024-07-06 19:12:53 -05:00
|
|
|
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='another_folder']"
|
|
|
|
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='sub_mod']"
|
2022-07-17 07:12:03 -05:00
|
|
|
// Only "another_folder" should be "open" in "lib2".
|
2024-07-06 19:12:53 -05:00
|
|
|
assert: "//*[@class='dir-entry' and not(@open)]/*[normalize-space()='another_mod']"
|
2022-07-17 07:12:03 -05:00
|
|
|
// All other trees should be collapsed.
|
2024-07-06 19:12:53 -05:00
|
|
|
assert-count: ("//*[@id='src-sidebar']/details[not(normalize-space()='lib2') and not(@open)]", 11)
|
2022-07-17 07:12:03 -05:00
|
|
|
|
2021-12-14 04:48:49 -06:00
|
|
|
// We now switch to mobile mode.
|
2023-04-11 12:11:34 -05:00
|
|
|
set-window-size: (600, 600)
|
2023-07-14 18:38:01 -05:00
|
|
|
wait-for-css: (".src-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.
|
2023-07-14 18:38:01 -05:00
|
|
|
assert-false: ".src-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"
|