Add GUI test for settings menu

This commit is contained in:
Guillaume Gomez 2022-01-19 23:06:17 +01:00
parent 9625ed8be7
commit e7d7d75c81
4 changed files with 56 additions and 9 deletions

View File

@ -4,17 +4,20 @@ goto: file://|DOC_PATH|/test_docs/index.html
// First, we check that the search results are hidden when the Escape key is pressed.
write: (".search-input", "test")
wait-for: "#search h1" // The search element is empty before the first search
assert-attribute: ("#search", {"class": "content"})
// Check that the currently displayed element is search.
wait-for: "#alternative-display #search"
assert-attribute: ("#main-content", {"class": "content hidden"})
assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
press-key: "Escape"
assert-attribute: ("#search", {"class": "content hidden"})
// Checks that search is no longer in the displayed content.
wait-for: "#not-displayed #search"
assert-false: "#alternative-display #search"
assert-attribute: ("#main-content", {"class": "content"})
assert-document-property: ({"URL": "index.html"}, [ENDS_WITH])
// Check that focusing the search input brings back the search results
focus: ".search-input"
assert-attribute: ("#search", {"class": "content"})
wait-for: "#alternative-display #search"
assert-attribute: ("#main-content", {"class": "content hidden"})
assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
@ -24,8 +27,8 @@ click: "#help-button"
assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
assert-attribute: ("#help", {"class": ""})
press-key: "Escape"
wait-for: "#alternative-display #search"
assert-attribute: ("#help", {"class": "hidden"})
assert-attribute: ("#search", {"class": "content"})
assert-attribute: ("#main-content", {"class": "content hidden"})
assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
@ -37,5 +40,6 @@ assert-false: ".search-input:focus"
assert: "#results a:focus"
press-key: "Escape"
assert-attribute: ("#help", {"class": "hidden"})
assert-attribute: ("#search", {"class": "content hidden"})
wait-for: "#not-displayed #search"
assert-false: "#alternative-display #search"
assert-attribute: ("#main-content", {"class": "content"})

View File

@ -0,0 +1,38 @@
// This test ensures that the settings menu display is working as expected.
goto: file://|DOC_PATH|/test_docs/index.html
// First, we check that the settings page doesn't exist.
assert-false: "#settings"
// We now click on the settings button.
click: "#settings-menu"
wait-for: "#settings"
assert: "#main-content.hidden"
assert-css: ("#settings", {"display": "block"})
// Let's close it by clicking on the same button.
click: "#settings-menu"
assert-false: "#alternative-display #settings"
assert: "#not-displayed #settings"
assert: "#main-content:not(.hidden)"
// Let's open and then close it again with the "close settings" button.
click: "#settings-menu"
wait-for: "#alternative-display #settings"
assert: "#main-content.hidden"
click: "#back"
wait-for: "#not-displayed #settings"
assert: "#main-content:not(.hidden)"
// Let's check that pressing "ESCAPE" is closing it.
click: "#settings-menu"
wait-for: "#alternative-display #settings"
press-key: "Escape"
wait-for: "#not-displayed #settings"
assert: "#main-content:not(.hidden)"
// Let's click on it when the search results are displayed.
focus: ".search-input"
write: "test"
wait-for: "#alternative-display #search"
click: "#settings-menu"
wait-for: "#alternative-display #settings"
assert: "#not-displayed #search"
assert: "#main-content.hidden"

View File

@ -9,6 +9,7 @@ click: "#theme-choices > button:last-child"
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
goto: file://|DOC_PATH|/settings.html
wait-for: "#settings"
click: "#theme-light"
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
assert-local-storage: { "rustdoc-theme": "light" }

View File

@ -1,15 +1,19 @@
// Ensures that the theme is working when going back in history.
goto: file://|DOC_PATH|/test_docs/index.html
// Set the theme to dark.
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
local-storage: {
"rustdoc-theme": "dark",
"rustdoc-preferred-dark-theme": "dark",
"rustdoc-use-system-theme": "false",
}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ("body", { "background-color": "rgb(53, 53, 53)" })
assert-local-storage: { "rustdoc-theme": "dark" }
// Now we go to the settings page.
click: "#settings-menu"
wait-for: ".settings"
goto: file://|DOC_PATH|/settings.html
wait-for: "#settings"
// We change the theme to "light".
click: "#theme-light"
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
@ -18,7 +22,7 @@ assert-local-storage: { "rustdoc-theme": "light" }
// We go back in history.
history-go-back:
// Confirm that we're not on the settings page.
assert-false: ".settings"
assert-false: "#settings"
// Check that the current theme is still "light".
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
assert-local-storage: { "rustdoc-theme": "light" }