Skip to content

Commit e7d7d75

Browse files
Add GUI test for settings menu
1 parent 9625ed8 commit e7d7d75

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

src/test/rustdoc-gui/escape-key.goml

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ goto: file://|DOC_PATH|/test_docs/index.html
44
// First, we check that the search results are hidden when the Escape key is pressed.
55
write: (".search-input", "test")
66
wait-for: "#search h1" // The search element is empty before the first search
7-
assert-attribute: ("#search", {"class": "content"})
7+
// Check that the currently displayed element is search.
8+
wait-for: "#alternative-display #search"
89
assert-attribute: ("#main-content", {"class": "content hidden"})
910
assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
1011
press-key: "Escape"
11-
assert-attribute: ("#search", {"class": "content hidden"})
12+
// Checks that search is no longer in the displayed content.
13+
wait-for: "#not-displayed #search"
14+
assert-false: "#alternative-display #search"
1215
assert-attribute: ("#main-content", {"class": "content"})
1316
assert-document-property: ({"URL": "index.html"}, [ENDS_WITH])
1417

1518
// Check that focusing the search input brings back the search results
1619
focus: ".search-input"
17-
assert-attribute: ("#search", {"class": "content"})
20+
wait-for: "#alternative-display #search"
1821
assert-attribute: ("#main-content", {"class": "content hidden"})
1922
assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
2023

@@ -24,8 +27,8 @@ click: "#help-button"
2427
assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
2528
assert-attribute: ("#help", {"class": ""})
2629
press-key: "Escape"
30+
wait-for: "#alternative-display #search"
2731
assert-attribute: ("#help", {"class": "hidden"})
28-
assert-attribute: ("#search", {"class": "content"})
2932
assert-attribute: ("#main-content", {"class": "content hidden"})
3033
assert-document-property: ({"URL": "index.html?search=test"}, [ENDS_WITH])
3134

@@ -37,5 +40,6 @@ assert-false: ".search-input:focus"
3740
assert: "#results a:focus"
3841
press-key: "Escape"
3942
assert-attribute: ("#help", {"class": "hidden"})
40-
assert-attribute: ("#search", {"class": "content hidden"})
43+
wait-for: "#not-displayed #search"
44+
assert-false: "#alternative-display #search"
4145
assert-attribute: ("#main-content", {"class": "content"})

src/test/rustdoc-gui/settings.goml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This test ensures that the settings menu display is working as expected.
2+
goto: file://|DOC_PATH|/test_docs/index.html
3+
// First, we check that the settings page doesn't exist.
4+
assert-false: "#settings"
5+
// We now click on the settings button.
6+
click: "#settings-menu"
7+
wait-for: "#settings"
8+
assert: "#main-content.hidden"
9+
assert-css: ("#settings", {"display": "block"})
10+
// Let's close it by clicking on the same button.
11+
click: "#settings-menu"
12+
assert-false: "#alternative-display #settings"
13+
assert: "#not-displayed #settings"
14+
assert: "#main-content:not(.hidden)"
15+
16+
// Let's open and then close it again with the "close settings" button.
17+
click: "#settings-menu"
18+
wait-for: "#alternative-display #settings"
19+
assert: "#main-content.hidden"
20+
click: "#back"
21+
wait-for: "#not-displayed #settings"
22+
assert: "#main-content:not(.hidden)"
23+
24+
// Let's check that pressing "ESCAPE" is closing it.
25+
click: "#settings-menu"
26+
wait-for: "#alternative-display #settings"
27+
press-key: "Escape"
28+
wait-for: "#not-displayed #settings"
29+
assert: "#main-content:not(.hidden)"
30+
31+
// Let's click on it when the search results are displayed.
32+
focus: ".search-input"
33+
write: "test"
34+
wait-for: "#alternative-display #search"
35+
click: "#settings-menu"
36+
wait-for: "#alternative-display #settings"
37+
assert: "#not-displayed #search"
38+
assert: "#main-content.hidden"

src/test/rustdoc-gui/theme-change.goml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ click: "#theme-choices > button:last-child"
99
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
1010

1111
goto: file://|DOC_PATH|/settings.html
12+
wait-for: "#settings"
1213
click: "#theme-light"
1314
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
1415
assert-local-storage: { "rustdoc-theme": "light" }
+8-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// Ensures that the theme is working when going back in history.
22
goto: file://|DOC_PATH|/test_docs/index.html
33
// Set the theme to dark.
4-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
4+
local-storage: {
5+
"rustdoc-theme": "dark",
6+
"rustdoc-preferred-dark-theme": "dark",
7+
"rustdoc-use-system-theme": "false",
8+
}
59
// We reload the page so the local storage settings are being used.
610
reload:
711
assert-css: ("body", { "background-color": "rgb(53, 53, 53)" })
812
assert-local-storage: { "rustdoc-theme": "dark" }
913

1014
// Now we go to the settings page.
11-
click: "#settings-menu"
12-
wait-for: ".settings"
15+
goto: file://|DOC_PATH|/settings.html
16+
wait-for: "#settings"
1317
// We change the theme to "light".
1418
click: "#theme-light"
1519
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
@@ -18,7 +22,7 @@ assert-local-storage: { "rustdoc-theme": "light" }
1822
// We go back in history.
1923
history-go-back:
2024
// Confirm that we're not on the settings page.
21-
assert-false: ".settings"
25+
assert-false: "#settings"
2226
// Check that the current theme is still "light".
2327
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
2428
assert-local-storage: { "rustdoc-theme": "light" }

0 commit comments

Comments
 (0)