rustdoc: fix rustdoc-gui tests for logo changes

This commit is contained in:
Michael Howell 2023-09-19 18:08:55 -07:00
parent c6e6ecb1af
commit 7c10c6f63d
6 changed files with 34 additions and 18 deletions

View file

@ -56,7 +56,7 @@ define-function: (
assert-css: ("#top-doc-prose-title", {"color": |title_color|})
assert-css: (".sidebar a", {"color": |sidebar_link_color|})
assert-css: (".sidebar .block a", {"color": |sidebar_link_color|})
assert-css: (".main-heading h1 a", {"color": |title_color|})
// We move the cursor over the "Implementations" title so the anchor is displayed.

View file

@ -1,18 +1,18 @@
// This test ensures that the correct style is applied to the rust logo in the sidebar.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
define-function: (
"check-logo",
(theme, filter),
block {
// Going to the doc page.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
// Changing theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
assert-css: (".rust-logo", {"filter": |filter|})
// Going to the source code page.
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html"
// Changing theme (since it's local files, the local storage works by folder).
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
@ -26,6 +26,15 @@ define-function: (
assert-false: ".rust-logo"
// Check there is no filter.
assert-css: (".sidebar .logo-container img", {"filter": "none"})
// Now we check that this page has no logo at all
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
assert-false: ".rust-logo"
assert-false: ".logo-container"
assert-false: ".sub-logo-container"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
assert-false: ".rust-logo"
assert-false: ".logo-container"
assert-false: ".sub-logo-container"
},
)

View file

@ -174,14 +174,14 @@ click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"left": "-1000px"})
// We scroll to line 117 to change the scroll position.
scroll-to: '//*[@id="117"]'
assert-window-property: {"pageYOffset": "2542"}
assert-window-property: {"pageYOffset": "2516"}
// Expanding the sidebar...
click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"left": "0px"})
click: "#src-sidebar-toggle"
wait-for-css: (".sidebar", {"left": "-1000px"})
// The "scrollTop" property should be the same.
assert-window-property: {"pageYOffset": "2542"}
assert-window-property: {"pageYOffset": "2516"}
// We now check that opening the sidebar and clicking a link will close it.
// The behavior here on mobile is different than the behavior on desktop,

View file

@ -8,13 +8,13 @@ set-window-size: (600, 800)
assert-property: ("html", {"scrollTop": "0"})
click: '//a[text() = "barbar" and @href="#5-7"]'
assert-property: ("html", {"scrollTop": "149"})
assert-property: ("html", {"scrollTop": "123"})
click: '//a[text() = "bar" and @href="#28-36"]'
assert-property: ("html", {"scrollTop": "180"})
assert-property: ("html", {"scrollTop": "154"})
click: '//a[text() = "sub_fn" and @href="#2-4"]'
assert-property: ("html", {"scrollTop": "77"})
assert-property: ("html", {"scrollTop": "51"})
// We now check that clicking on lines doesn't change the scroll
// Extra information: the "sub_fn" function header is on line 1.
click: '//*[@id="6"]'
assert-property: ("html", {"scrollTop": "77"})
assert-property: ("html", {"scrollTop": "51"})

View file

@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
// do anything (and certainly not add a `#NaN` to the URL!).
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// We use this assert-position to know where we will click.
assert-position: ("//*[@id='1']", {"x": 88, "y": 112})
assert-position: ("//*[@id='1']", {"x": 88, "y": 86})
// We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
click: (87, 103)
click: (87, 77)
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
// Checking the source code sidebar.
@ -163,16 +163,16 @@ assert-css: ("nav.sub", {"flex-direction": "row"})
// To check this, we maintain the invariant:
//
// offsetTop[nav.sub form] = offsetTop[#main-content] - offsetHeight[nav.sub form] - offsetTop[nav.sub form]
assert-property: ("nav.sub form", {"offsetTop": 28, "offsetHeight": 34})
assert-property: ("#main-content", {"offsetTop": 90})
// 28 = 90 - 34 - 28
assert-property: ("nav.sub form", {"offsetTop": 15, "offsetHeight": 34})
assert-property: ("#main-content", {"offsetTop": 64})
// 15 = 64 - 34 - 15
// Now do the same check on moderately-sized, tablet mobile.
set-window-size: (700, 700)
assert-css: ("nav.sub", {"flex-direction": "row"})
assert-property: ("nav.sub form", {"offsetTop": 21, "offsetHeight": 34})
assert-property: ("#main-content", {"offsetTop": 76})
// 21 = 76 - 34 - 21
assert-property: ("nav.sub form", {"offsetTop": 8, "offsetHeight": 34})
assert-property: ("#main-content", {"offsetTop": 50})
// 8 = 50 - 34 - 8
// Check the sidebar directory entries have a marker and spacing (tablet).
store-property: ("#src-sidebar > .title", {
@ -198,7 +198,12 @@ call-function: ("check-sidebar-dir-entry", {
"y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
})
// The logo is not present on this page.
assert-false: ".sub-logo-container > img"
// Check the staged-api page instead, which does.
// Now we check that the logo has a bottom margin so it's not stuck to the search input.
go-to: "file://" + |DOC_PATH| + "/src/staged_api/lib.rs.html"
assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"})
store-property: (".sub-logo-container", {"clientHeight": logo_height})
assert-position: (".search-form", {"y": |logo_height| + 8})

View file

@ -1,6 +1,8 @@
#![feature(staged_api)]
#![feature(rustdoc_internals)]
#![allow(internal_features)]
#![stable(feature = "some_feature", since = "1.3.5")]
#![doc(rust_logo)]
#[stable(feature = "some_feature", since = "1.3.5")]
pub struct Foo {}