diff options
| author | Michael Howell <michael@notriddle.com> | 2023-12-17 23:06:31 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-12-17 23:06:31 -0700 |
| commit | 859bbc5deffbee7870433c541cdbeb4a4a23780f (patch) | |
| tree | 57e41fe2cc034bc00b157e60682937bdf850ca79 /tests | |
| parent | 43dcc9b786c922251c3fbe75a0142f50f07053ca (diff) | |
| download | rust-859bbc5deffbee7870433c541cdbeb4a4a23780f.tar.gz rust-859bbc5deffbee7870433c541cdbeb4a4a23780f.zip | |
rustdoc: clean up source sidebar hide button
This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rustdoc-gui/code-sidebar-toggle.goml | 4 | ||||
| -rw-r--r-- | tests/rustdoc-gui/cursor.goml | 2 | ||||
| -rw-r--r-- | tests/rustdoc-gui/globals.goml | 2 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-source-code-display.goml | 61 | ||||
| -rw-r--r-- | tests/rustdoc-gui/sidebar-source-code.goml | 2 | ||||
| -rw-r--r-- | tests/rustdoc-gui/source-code-page.goml | 2 |
6 files changed, 19 insertions, 54 deletions
diff --git a/tests/rustdoc-gui/code-sidebar-toggle.goml b/tests/rustdoc-gui/code-sidebar-toggle.goml index d1efa45dc1d..cdd6507947d 100644 --- a/tests/rustdoc-gui/code-sidebar-toggle.goml +++ b/tests/rustdoc-gui/code-sidebar-toggle.goml @@ -1,7 +1,7 @@ // This test checks that the source code pages sidebar toggle is working as expected. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" click: "a.src" -wait-for: "#src-sidebar-toggle" -click: "#src-sidebar-toggle" +wait-for: "#src-sidebar" +click: "#sidebar-button" expect-failure: true assert-css: ("#src-sidebar", { "left": "-300px" }) diff --git a/tests/rustdoc-gui/cursor.goml b/tests/rustdoc-gui/cursor.goml index f318b05ceda..27c955f5a13 100644 --- a/tests/rustdoc-gui/cursor.goml +++ b/tests/rustdoc-gui/cursor.goml @@ -21,4 +21,4 @@ assert-css: (".sidebar-menu-toggle", {"cursor": "pointer"}) // the sidebar toggle button on the source code pages go-to: "file://" + |DOC_PATH| + "/src/lib2/lib.rs.html" -assert-css: ("#src-sidebar-toggle > button", {"cursor": "pointer"}) +assert-css: ("#sidebar-button > a", {"cursor": "pointer"}) diff --git a/tests/rustdoc-gui/globals.goml b/tests/rustdoc-gui/globals.goml index 53f96ff086e..c01c8bb1019 100644 --- a/tests/rustdoc-gui/globals.goml +++ b/tests/rustdoc-gui/globals.goml @@ -18,7 +18,7 @@ assert-window-property: {"srcIndex": null} // source sidebar go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" -click: "#src-sidebar-toggle" +click: "#sidebar-button" wait-for: "#src-sidebar details" assert-window-property-false: {"srcIndex": null} assert-window-property: {"searchIndex": null} diff --git a/tests/rustdoc-gui/sidebar-source-code-display.goml b/tests/rustdoc-gui/sidebar-source-code-display.goml index cea4db1466b..44844b52219 100644 --- a/tests/rustdoc-gui/sidebar-source-code-display.goml +++ b/tests/rustdoc-gui/sidebar-source-code-display.goml @@ -2,18 +2,17 @@ javascript: false go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // Since the javascript is disabled, there shouldn't be a toggle. -assert-false: "#src-sidebar-toggle" wait-for-css: (".sidebar", {"display": "none"}) +assert-css: ("#sidebar-button", {"display": "none"}) // Let's retry with javascript enabled. javascript: true reload: -wait-for: "#src-sidebar-toggle" -assert-css: ("#src-sidebar-toggle", {"visibility": "visible"}) -assert-css: (".sidebar > *:not(#src-sidebar-toggle)", {"visibility": "hidden"}) +wait-for: "#src-sidebar" +assert-css: ("#src-sidebar", {"position": "absolute", "left": "-1000px"}) // Let's expand the sidebar now. -click: "#src-sidebar-toggle" -wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) +click: "#src-sidebar" +wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"}) // We now check that opening the sidebar and clicking a link will leave it open. // The behavior here on desktop is different than the behavior on mobile, @@ -38,29 +37,13 @@ define-function: ( block { set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"} reload: - wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) + wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"}) assert-css: ( "#src-sidebar details[open] > .files a.selected", {"color": |color_hover|, "background-color": |background|}, ) // Without hover or focus. - assert-css: ("#src-sidebar-toggle > button", {"background-color": |background_toggle|}) - // With focus. - focus: "#src-sidebar-toggle > button" - assert-css: ( - "#src-sidebar-toggle > button:focus", - {"background-color": |background_toggle_hover|}, - ) - focus: ".search-input" - // With hover. - move-cursor-to: "#src-sidebar-toggle > button" - assert-css: ( - "#src-sidebar-toggle > button:hover", - {"background-color": |background_toggle_hover|}, - ) - - // Without hover or focus. assert-css: ( "#src-sidebar details[open] > .files a:not(.selected)", {"color": |color|, "background-color": |background_toggle|}, @@ -125,8 +108,6 @@ call-function: ("check-colors", { "color_hover": "#000", "background": "#fff", "background_hover": "#e0e0e0", - "background_toggle": "rgba(0, 0, 0, 0)", - "background_toggle_hover": "#e0e0e0", }) call-function: ("check-colors", { "theme": "dark", @@ -134,8 +115,6 @@ call-function: ("check-colors", { "color_hover": "#ddd", "background": "#333", "background_hover": "#444", - "background_toggle": "rgba(0, 0, 0, 0)", - "background_toggle_hover": "#676767", }) call-function: ("check-colors", { "theme": "ayu", @@ -143,42 +122,28 @@ call-function: ("check-colors", { "color_hover": "#ffb44c", "background": "#14191f", "background_hover": "#14191f", - "background_toggle": "rgba(0, 0, 0, 0)", - "background_toggle_hover": "rgba(70, 70, 70, 0.33)", }) // Now checking on mobile devices. set-window-size: (500, 700) reload: // Waiting for the sidebar to be displayed... -wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) +wait-for-css: ("#src-sidebar", {"position": "sticky", "left": "0"}) // We now check it takes the full size of the display. assert-property: ("body", {"clientWidth": "500", "clientHeight": "700"}) assert-property: (".sidebar", {"clientWidth": "500", "clientHeight": "700"}) -// We now check the display of the toggle once the sidebar is expanded. -assert-property: ("#src-sidebar-toggle", {"clientWidth": "500", "clientHeight": "39"}) -assert-css: ( - "#src-sidebar-toggle", - { - "border-top-width": "0px", - "border-right-width": "0px", - "border-left-width": "0px", - "border-bottom-width": "1px", - }, -) - // We now check that the scroll position is kept when opening the sidebar. -click: "#src-sidebar-toggle" -wait-for-css: (".sidebar", {"left": "-1000px"}) +click: "#sidebar-button" +wait-for-css: (".sidebar", {"position": "absolute", "left": "-1000px"}) // We scroll to line 117 to change the scroll position. scroll-to: '//*[@id="117"]' assert-window-property: {"pageYOffset": "2516"} // Expanding the sidebar... -click: "#src-sidebar-toggle" +click: "#sidebar-button" wait-for-css: (".sidebar", {"left": "0px"}) -click: "#src-sidebar-toggle" +click: "#sidebar-button" wait-for-css: (".sidebar", {"left": "-1000px"}) // The "scrollTop" property should be the same. assert-window-property: {"pageYOffset": "2516"} @@ -189,7 +154,7 @@ assert-window-property: {"pageYOffset": "2516"} // you click one of them, you probably want to actually see the file's contents, and not just // make it the current selection. set-window-size: (500, 700) -click: "#src-sidebar-toggle" +click: "#sidebar-button" wait-for-css: ("#src-sidebar", {"visibility": "visible"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} click: ".sidebar a.selected" @@ -200,6 +165,6 @@ assert-local-storage: {"rustdoc-source-sidebar-show": "false"} set-window-size: (1000, 1000) wait-for-css: ("#src-sidebar", {"visibility": "hidden"}) assert-local-storage: {"rustdoc-source-sidebar-show": "false"} -click: "#src-sidebar-toggle" +click: "#sidebar-button" wait-for-css: ("#src-sidebar", {"visibility": "visible"}) assert-local-storage: {"rustdoc-source-sidebar-show": "true"} diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 9fc1409e86f..9e5438a4f00 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -48,7 +48,7 @@ call-function: ( // Next, desktop mode layout. set-window-size: (1100, 800) -wait-for: "#src-sidebar-toggle" +wait-for: "#sidebar-button" // 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. diff --git a/tests/rustdoc-gui/source-code-page.goml b/tests/rustdoc-gui/source-code-page.goml index ad57380ae25..1a4600ab0e4 100644 --- a/tests/rustdoc-gui/source-code-page.goml +++ b/tests/rustdoc-gui/source-code-page.goml @@ -97,7 +97,7 @@ assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) // Checking the source code sidebar. // First we "open" it. -click: "#src-sidebar-toggle" +click: "#sidebar-button" assert: ".src-sidebar-expanded" // We check that the first entry of the sidebar is collapsed |
