Skip to content

Commit 66bc97c

Browse files
Make theme switching closer to reality
1 parent cf65764 commit 66bc97c

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

tests/rustdoc-gui/docblock-code-block-line-number.goml

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
include: "utils.goml"
33
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
44

5-
// Otherwise, we can't check text color
6-
show-text: true
7-
85
// We check that without this setting, there is no line number displayed.
96
assert-false: "pre.example-line-numbers"
107

8+
// We set the setting to show the line numbers on code examples.
9+
set-local-storage: {"rustdoc-line-numbers": "true"}
10+
reload:
11+
// We wait for the line numbers to be added into the DOM by the JS...
12+
wait-for: "pre.example-line-numbers"
13+
14+
// Otherwise, we can't check text color
15+
show-text: true
16+
1117
// Let's now check some CSS properties...
1218
define-function: (
1319
"check-colors",
1420
[theme, color],
1521
block {
16-
// We now set the setting to show the line numbers on code examples.
17-
set-local-storage: {"rustdoc-line-numbers": "true"}
1822
// Page will be reloaded in "switch-theme".
1923
call-function: ("switch-theme", {"theme": |theme|})
20-
// We wait for the line numbers to be added into the DOM by the JS...
21-
wait-for: "pre.example-line-numbers"
2224
// If the test didn't fail, it means that it was found!
2325
assert-css: (
2426
"pre.example-line-numbers",

tests/rustdoc-gui/scrape-examples-toggle.goml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ define-function: (
99
[theme, toggle_line_color, toggle_line_hover_color],
1010
block {
1111
call-function: ("switch-theme", {"theme": |theme|})
12+
reload:
1213

1314
// Clicking "More examples..." will open additional examples
1415
assert-attribute-false: (".more-examples-toggle", {"open": ""})
@@ -21,6 +22,8 @@ define-function: (
2122
".toggle-line:hover .toggle-line-inner",
2223
{"background-color": |toggle_line_hover_color|},
2324
)
25+
// We put the toggle in the original state.
26+
click: ".more-examples-toggle"
2427
// Moving cursor away from the toggle line to prevent disrupting next test.
2528
move-cursor-to: ".search-input"
2629
},

tests/rustdoc-gui/search-result-color.goml

+6-9
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,21 @@ call-function: ("check-search-color", {
210210

211211
// Check the alias.
212212
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
213-
// If the text isn't displayed, the browser doesn't compute color style correctly...
214-
show-text: true
213+
214+
write-into: (".search-input", "thisisanalias")
215+
// To be SURE that the search will be run.
216+
press-key: 'Enter'
217+
// Waiting for the search results to appear...
218+
wait-for: "#search-tabs"
215219

216220
define-function: (
217221
"check-alias",
218222
[theme, alias, grey],
219223
block {
220224
call-function: ("switch-theme", {"theme": |theme|})
221-
write-into: (".search-input", "thisisanalias")
222-
// To be SURE that the search will be run.
223-
press-key: 'Enter'
224-
// Waiting for the search results to appear...
225-
wait-for: "#search-tabs"
226225
// Checking that the colors for the alias element are the ones expected.
227226
assert-css: (".result-name .path .alias", {"color": |alias|})
228227
assert-css: (".result-name .path .alias > .grey", {"color": |grey|})
229-
// Leave the search results to prevent reloading with an already filled search input.
230-
press-key: "Escape"
231228
},
232229
)
233230

tests/rustdoc-gui/settings.goml

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ wait-for: "#alternative-display #search"
3636
assert: "#main-content.hidden"
3737

3838
// Now let's check the content of the settings menu.
39-
call-function: ("switch-theme", {"theme": "dark"})
39+
// If we are on the settings page, the menu doesn't work the same so we set
40+
// the theme manually.
41+
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
42+
// We reload the page so the local storage settings are being used.
43+
reload:
44+
4045
click: "#settings-menu"
4146
wait-for: "#settings"
4247

tests/rustdoc-gui/utils.goml

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ define-function: (
44
[theme],
55
block {
66
// Set the theme.
7-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
8-
// We reload the page so the local storage settings are being used.
9-
reload:
7+
// Open the settings menu.
8+
click: "#settings-menu"
9+
// Wait for the popover to appear...
10+
wait-for: "#settings"
11+
// Change the setting.
12+
click: "#theme-"+ |theme|
13+
// Close the popover.
14+
click: "#settings-menu"
15+
// Ensure that the local storage was correctly updated.
16+
assert-local-storage: {"rustdoc-theme": |theme|}
1017
},
1118
)

0 commit comments

Comments
 (0)