Skip to content

Reduce wait-for instructions for rustdoc GUI tests #95172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.3
0.8.4
4 changes: 2 additions & 2 deletions src/test/rustdoc-gui/default-settings.goml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
// check.
goto: file://|DOC_PATH|/settings/index.html
// Wait a bit to be sure the default theme is applied.
wait-for: 1000
assert-css: ("body", {"background-color": "rgb(15, 20, 25)"})
// If the theme isn't applied, the command will time out.
wait-for-css: ("body", {"background-color": "rgb(15, 20, 25)"})
6 changes: 2 additions & 4 deletions src/test/rustdoc-gui/search-filter.goml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ assert-property: ("#crate-search", {"value": "lib2"})
// Now we check that leaving the search results and putting them back keeps the
// crate filtering.
press-key: "Escape"
wait-for: 100
assert-css: ("#main-content", {"display": "block"})
wait-for-css: ("#main-content", {"display": "block"})
focus: ".search-input"
wait-for: 100
assert-css: ("#main-content", {"display": "none"})
wait-for-css: ("#main-content", {"display": "none"})
// We check that there is no more "test_docs" appearing.
assert-false: "#results .externcrate"
assert-property: ("#crate-search", {"value": "lib2"})
Expand Down
3 changes: 1 addition & 2 deletions src/test/rustdoc-gui/search-result-go-to-first.goml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ assert-css: ("#main-content", {"display": "none"})
// Now we can check that the feature is working as expected!
goto: file://|DOC_PATH|/test_docs/index.html?search=struct%3AFoo&go_to_first=true
// Waiting for the page to load...
wait-for: 500
assert-text: (".fqn .in-band", "Struct test_docs::Foo")
wait-for-text: (".fqn .in-band", "Struct test_docs::Foo")
6 changes: 2 additions & 4 deletions src/test/rustdoc-gui/sidebar-source-code-display.goml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
assert-false: "#sidebar-toggle"
// For some reason, we need to wait a bit here because it seems like the transition on opacity
// is being applied whereas it can't be reproduced in a browser...
wait-for: 500
assert-css: (".sidebar > *", {"visibility": "hidden", "opacity": 0})
wait-for-css: (".sidebar > *", {"visibility": "hidden", "opacity": 0})

// Let's retry with javascript enabled.
javascript: true
Expand All @@ -17,6 +16,5 @@ assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden", "opac
// Let's expand the sidebar now.
click: "#sidebar-toggle"
// Because of the transition CSS, better wait a second before checking.
wait-for: 1000
assert-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "visible", "opacity": 1})
9 changes: 3 additions & 6 deletions src/test/rustdoc-gui/sidebar-source-code.goml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ size: (1100, 800)
assert-css: ("nav.sidebar", {"width": "50px"})
// We now click on the button to expand the sidebar.
click: (10, 10)
// We wait for the sidebar to be expanded (there is a 0.5s animation).
wait-for: 600
assert-css: ("nav.sidebar.expanded", {"width": "300px"})
// We wait for the sidebar to be expanded.
wait-for-css: ("nav.sidebar.expanded", {"width": "300px"})
assert-css: ("nav.sidebar.expanded a", {"font-size": "14px"})
// We collapse the sidebar.
click: (10, 10)
// We wait for the sidebar to be collapsed (there is a 0.5s animation).
wait-for: 600
// We ensure that the class has been removed.
assert-false: "nav.sidebar.expanded"
wait-for: "nav.sidebar:not(.expanded)"
assert: "nav.sidebar"

// We now switch to mobile mode.
Expand Down
15 changes: 5 additions & 10 deletions src/test/rustdoc-gui/theme-change.goml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
goto: file://|DOC_PATH|/test_docs/index.html
click: "#theme-picker"
click: "#theme-choices > button:first-child"
wait-for: 500
// should be the ayu theme so let's check the color
assert-css: ("body", { "background-color": "rgb(15, 20, 25)" })
wait-for-css: ("body", { "background-color": "rgb(15, 20, 25)" })
click: "#theme-choices > button:last-child"
wait-for: 500
// should be the light theme so let's check the color
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })

goto: file://|DOC_PATH|/settings.html
click: "#theme-light"
wait-for: 500
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
assert-local-storage: { "rustdoc-theme": "light" }

click: "#theme-dark"
wait-for: 500
assert-css: ("body", { "background-color": "rgb(53, 53, 53)" })
wait-for-css: ("body", { "background-color": "rgb(53, 53, 53)" })
assert-local-storage: { "rustdoc-theme": "dark" }

click: "#theme-ayu"
wait-for: 500
assert-css: ("body", { "background-color": "rgb(15, 20, 25)" })
wait-for-css: ("body", { "background-color": "rgb(15, 20, 25)" })
assert-local-storage: { "rustdoc-theme": "ayu" }
3 changes: 1 addition & 2 deletions src/test/rustdoc-gui/theme-in-history.goml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ click: "#settings-menu"
wait-for: ".settings"
// We change the theme to "light".
click: "#theme-light"
wait-for: 250
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
assert-local-storage: { "rustdoc-theme": "light" }

// We go back in history.
Expand Down
9 changes: 3 additions & 6 deletions src/test/rustdoc-gui/toggle-docs.goml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ wait-for: 50
assert-attribute-false: ("#main-content > details.top-doc", {"open": ""})
assert-text: ("#toggle-all-docs", "[+]")
click: "#toggle-all-docs"
wait-for: 50
// Not collapsed anymore so the "open" attribute should be back.
assert-attribute: ("#main-content > details.top-doc", {"open": ""})
wait-for-attribute: ("#main-content > details.top-doc", {"open": ""})
assert-text: ("#toggle-all-docs", "[−]")

// Check that it works on non-module pages as well.
Expand All @@ -27,8 +26,7 @@ assert-attribute-false: (

// We collapse them all.
click: "#toggle-all-docs"
wait-for: 50
assert-text: ("#toggle-all-docs", "[+]")
wait-for-text: ("#toggle-all-docs", "[+]")
// We check that all <details> are collapsed (except for the impl block ones).
assert-attribute-false: ("details.rustdoc-toggle:not(.implementors-toggle)", {"open": ""}, ALL)
assert-attribute: ("#implementations-list > details.implementors-toggle", {"open": ""})
Expand All @@ -40,6 +38,5 @@ assert-attribute-false: (
)
// We open them all again.
click: "#toggle-all-docs"
wait-for: 50
assert-text: ("#toggle-all-docs", "[−]")
wait-for-text: ("#toggle-all-docs", "[−]")
assert-attribute: ("details.rustdoc-toggle", {"open": ""}, ALL)