2022-01-21 19:41:47 +00:00
|
|
|
|
// Checks multiple things on the sidebar display (width of its elements, colors, etc).
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
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
|
|
|
|
show-text: true
|
2022-12-27 20:59:00 +00:00
|
|
|
|
|
|
|
|
|
// 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: (".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
|
|
|
|
)
|
|
|
|
|
|
2023-04-11 17:11:34 +00:00
|
|
|
|
set-local-storage: {"rustdoc-theme": "light"}
|
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
|
|
|
|
// We reload the page so the local storage settings are being used.
|
|
|
|
|
reload:
|
|
|
|
|
|
2021-06-19 10:56:55 +00:00
|
|
|
|
assert-text: (".sidebar > .location", "Crate test_docs")
|
2021-05-02 16:59:31 +00:00
|
|
|
|
// In modules, we only have one "location" element.
|
2021-06-19 10:56:55 +00:00
|
|
|
|
assert-count: (".sidebar .location", 1)
|
2022-10-18 18:14:01 +00:00
|
|
|
|
assert-count: (".sidebar h2", 1)
|
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
|
|
|
|
assert-text: ("#all-types", "All Items")
|
2022-01-23 19:26:07 +00:00
|
|
|
|
assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
|
2021-05-02 16:59:31 +00:00
|
|
|
|
// We check that we have the crates list and that the "current" on is "test_docs".
|
2022-10-10 18:37:19 +00:00
|
|
|
|
assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs")
|
2021-05-02 16:59:31 +00:00
|
|
|
|
// And we're also supposed to have the list of items in the current module.
|
2022-05-05 19:56:40 +00:00
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
|
2022-10-19 15:15:11 +00:00
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions")
|
2023-08-21 23:20:00 +00:00
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Aliases")
|
2022-10-19 15:15:11 +00:00
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions")
|
|
|
|
|
assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords")
|
2023-02-08 02:00:18 +00:00
|
|
|
|
assert-text: ("#structs + .item-table .item-name > a", "Foo")
|
|
|
|
|
click: "#structs + .item-table .item-name > a"
|
2021-05-02 16:59:31 +00:00
|
|
|
|
|
|
|
|
|
// PAGE: struct.Foo.html
|
2022-10-18 18:14:01 +00:00
|
|
|
|
assert-count: (".sidebar .location", 1)
|
|
|
|
|
assert-count: (".sidebar h2", 2)
|
2021-05-31 09:51:22 +00:00
|
|
|
|
// We check that there is no crate listed outside of the top level.
|
|
|
|
|
assert-false: ".sidebar-elems > .crate"
|
2022-01-11 22:39:51 +00:00
|
|
|
|
|
2022-02-08 16:05:00 +00:00
|
|
|
|
click: ".sidebar-elems section .block li > a"
|
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
|
|
|
|
assert-property-false: ("html", {"scrollTop": "0"})
|
2022-01-11 22:39:51 +00:00
|
|
|
|
|
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
|
|
|
|
click: ".sidebar h2.location a"
|
2022-01-11 22:39:51 +00:00
|
|
|
|
assert-property: ("html", {"scrollTop": "0"})
|
|
|
|
|
|
2021-05-31 10:11:05 +00:00
|
|
|
|
// We now go back to the crate page to click on the "lib2" crate link.
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2022-10-10 18:37:19 +00:00
|
|
|
|
assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "rgb(53, 109, 164)"})
|
|
|
|
|
click: ".sidebar-elems ul.crate > li:first-child > a"
|
2021-05-02 16:59:31 +00:00
|
|
|
|
|
|
|
|
|
// PAGE: lib2/index.html
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2021-06-19 10:56:55 +00:00
|
|
|
|
assert-text: (".sidebar > .location", "Crate lib2")
|
2021-05-02 16:59:31 +00:00
|
|
|
|
// We check that we have the crates list and that the "current" on is now "lib2".
|
2022-10-10 18:37:19 +00:00
|
|
|
|
assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2")
|
2021-05-02 16:59:31 +00:00
|
|
|
|
// We now go to the "foobar" function page.
|
2022-10-10 18:37:19 +00:00
|
|
|
|
assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules")
|
|
|
|
|
assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs")
|
|
|
|
|
assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits")
|
|
|
|
|
assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions")
|
2023-08-21 23:20:00 +00:00
|
|
|
|
assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Aliases")
|
2023-02-08 02:00:18 +00:00
|
|
|
|
assert-text: ("#functions + .item-table .item-name > a", "foobar")
|
|
|
|
|
click: "#functions + .item-table .item-name > a"
|
2021-05-02 16:59:31 +00:00
|
|
|
|
|
|
|
|
|
// PAGE: fn.foobar.html
|
2022-10-18 18:14:01 +00:00
|
|
|
|
// In items containing no items (like functions or constants) and in modules, we have no
|
|
|
|
|
// "location" elements. Only the parent module h2.
|
|
|
|
|
assert-count: (".sidebar .location", 0)
|
|
|
|
|
assert-count: (".sidebar h2", 1)
|
|
|
|
|
assert-text: (".sidebar .sidebar-elems h2", "In lib2")
|
2021-05-31 10:11:05 +00:00
|
|
|
|
// We check that we don't have the crate list.
|
|
|
|
|
assert-false: ".sidebar-elems > .crate"
|
|
|
|
|
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "./module/index.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2021-06-19 10:56:55 +00:00
|
|
|
|
assert-text: (".sidebar > .location", "Module module")
|
2021-05-31 09:51:22 +00:00
|
|
|
|
// We check that we don't have the crate list.
|
|
|
|
|
assert-false: ".sidebar-elems > .crate"
|
2021-05-02 16:59:31 +00:00
|
|
|
|
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "./sub_module/sub_sub_module/index.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2021-06-19 10:56:55 +00:00
|
|
|
|
assert-text: (".sidebar > .location", "Module sub_sub_module")
|
2021-05-31 09:51:22 +00:00
|
|
|
|
// We check that we don't have the crate list.
|
2021-11-04 15:27:02 +00:00
|
|
|
|
assert-false: ".sidebar-elems .crate"
|
2022-02-08 16:05:00 +00:00
|
|
|
|
assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions")
|
2023-02-08 02:00:18 +00:00
|
|
|
|
assert-text: ("#functions + .item-table .item-name > a", "foo")
|
2022-01-25 04:19:09 +00:00
|
|
|
|
|
|
|
|
|
// Links to trait implementations in the sidebar should not wrap even if they are long.
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2022-02-08 16:05:00 +00:00
|
|
|
|
assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29})
|
2022-02-04 06:50:32 +00:00
|
|
|
|
|
|
|
|
|
// Test that clicking on of the "In <module>" headings in the sidebar links to the
|
|
|
|
|
// appropriate anchor in index.html.
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
2022-09-22 17:42:15 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2022-10-10 18:37:19 +00:00
|
|
|
|
click: "//ul[@class='block mod']/preceding-sibling::h3/a"
|
2022-02-04 06:50:32 +00:00
|
|
|
|
// PAGE: index.html
|
|
|
|
|
assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"})
|
2022-09-22 17:42:15 +00:00
|
|
|
|
|
|
|
|
|
// Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width.
|
|
|
|
|
click: "#toggle-all-docs"
|
|
|
|
|
assert-text: ("#toggle-all-docs", "[+]")
|
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
|
|
|
|
click: "#toggle-all-docs"
|
|
|
|
|
assert-text: ("#toggle-all-docs", "[−]")
|
2023-01-08 20:29:57 +00:00
|
|
|
|
assert-property: (".sidebar", {"clientWidth": "200"})
|
2023-03-03 01:21:26 +00:00
|
|
|
|
|
|
|
|
|
// Checks that all.html and index.html have their sidebar link in the same place.
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
2023-05-10 08:56:59 +00:00
|
|
|
|
store-property: (".sidebar .location a", {
|
|
|
|
|
"clientWidth": index_sidebar_width,
|
|
|
|
|
"clientHeight": index_sidebar_height,
|
|
|
|
|
"offsetTop": index_sidebar_y,
|
|
|
|
|
"offsetLeft": index_sidebar_x,
|
|
|
|
|
})
|
2023-04-11 17:11:34 +00:00
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/all.html"
|
2023-03-03 01:21:26 +00:00
|
|
|
|
assert-property: (".sidebar .location a", {
|
|
|
|
|
"clientWidth": |index_sidebar_width|,
|
|
|
|
|
"clientHeight": |index_sidebar_height|,
|
2023-05-10 08:56:59 +00:00
|
|
|
|
"offsetTop": |index_sidebar_y|,
|
|
|
|
|
"offsetLeft": |index_sidebar_x|,
|
2023-03-03 01:21:26 +00:00
|
|
|
|
})
|