Skip to content

Commit dacf9b8

Browse files
Extend GUI test for theme settings
1 parent 4074aae commit dacf9b8

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

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

+41-6
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,66 @@
22
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
33
local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
44
reload:
5+
6+
store-value: (background_light, "rgb(255, 255, 255)")
7+
store-value: (background_dark, "rgb(53, 53, 53)")
8+
store-value: (background_ayu, "rgb(15, 20, 25)")
9+
510
click: "#settings-menu"
611
wait-for: "#theme-ayu"
712
click: "#theme-ayu"
813
// should be the ayu theme so let's check the color.
9-
wait-for-css: ("body", { "background-color": "rgb(15, 20, 25)" })
14+
wait-for-css: ("body", { "background-color": |background_ayu| })
1015
assert-local-storage: { "rustdoc-theme": "ayu" }
1116
click: "#theme-light"
1217
// should be the light theme so let's check the color.
13-
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
18+
wait-for-css: ("body", { "background-color": |background_light| })
1419
assert-local-storage: { "rustdoc-theme": "light" }
1520
click: "#theme-dark"
1621
// Should be the dark theme so let's check the color.
17-
wait-for-css: ("body", { "background-color": "rgb(53, 53, 53)" })
22+
wait-for-css: ("body", { "background-color": |background_dark| })
1823
assert-local-storage: { "rustdoc-theme": "dark" }
1924

25+
local-storage: {
26+
"rustdoc-preferred-light-theme": "light",
27+
"rustdoc-preferred-dark-theme": "light",
28+
}
2029
goto: "file://" + |DOC_PATH| + "/settings.html"
30+
2131
wait-for: "#settings"
2232
click: "#theme-light"
23-
wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" })
33+
wait-for-css: ("body", { "background-color": |background_light| })
2434
assert-local-storage: { "rustdoc-theme": "light" }
2535

2636
click: "#theme-dark"
27-
wait-for-css: ("body", { "background-color": "rgb(53, 53, 53)" })
37+
wait-for-css: ("body", { "background-color": |background_dark| })
2838
assert-local-storage: { "rustdoc-theme": "dark" }
2939

3040
click: "#theme-ayu"
31-
wait-for-css: ("body", { "background-color": "rgb(15, 20, 25)" })
41+
wait-for-css: ("body", { "background-color": |background_ayu| })
3242
assert-local-storage: { "rustdoc-theme": "ayu" }
43+
44+
assert-local-storage-false: { "rustdoc-use-system-theme": "true" }
45+
click: "#theme-system-preference"
46+
wait-for: ".setting-line:not(.hidden) #preferred-light-theme"
47+
assert-local-storage: { "rustdoc-use-system-theme": "true" }
48+
// We click on both preferred light and dark themes to be sure that there is a change.
49+
click: "#preferred-light-theme-dark"
50+
click: "#preferred-dark-theme-dark"
51+
wait-for-css: ("body", { "background-color": |background_dark| })
52+
53+
reload:
54+
// Ensure that the "preferred themes" are still displayed.
55+
wait-for: ".setting-line:not(.hidden) #preferred-light-theme"
56+
click: "#theme-light"
57+
wait-for-css: ("body", { "background-color": |background_light| })
58+
assert-local-storage: { "rustdoc-theme": "light" }
59+
// Ensure it's now hidden again
60+
wait-for: ".setting-line.hidden #preferred-light-theme"
61+
// And ensure the theme was rightly set.
62+
wait-for-css: ("body", { "background-color": |background_light| })
63+
assert-local-storage: { "rustdoc-theme": "light" }
64+
65+
reload:
66+
wait-for: "#settings"
67+
assert: ".setting-line.hidden #preferred-light-theme"

0 commit comments

Comments
 (0)