2022-01-21 19:41:47 +00:00
|
|
|
// Ensures that the theme change is working as expected.
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
|
|
|
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
|
2022-05-11 21:11:31 +00:00
|
|
|
reload:
|
2022-11-13 20:37:42 +00:00
|
|
|
|
2023-06-07 15:42:04 +00:00
|
|
|
store-value: (background_light, "white")
|
|
|
|
store-value: (background_dark, "#353535")
|
|
|
|
store-value: (background_ayu, "#0f1419")
|
2022-11-13 20:37:42 +00:00
|
|
|
|
2022-05-11 21:11:31 +00:00
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#theme-ayu"
|
|
|
|
click: "#theme-ayu"
|
|
|
|
// should be the ayu theme so let's check the color.
|
2022-11-13 20:37:42 +00:00
|
|
|
wait-for-css: ("body", { "background-color": |background_ayu| })
|
2022-05-11 21:11:31 +00:00
|
|
|
assert-local-storage: { "rustdoc-theme": "ayu" }
|
|
|
|
click: "#theme-light"
|
|
|
|
// should be the light theme so let's check the color.
|
2022-11-13 20:37:42 +00:00
|
|
|
wait-for-css: ("body", { "background-color": |background_light| })
|
2022-05-11 21:11:31 +00:00
|
|
|
assert-local-storage: { "rustdoc-theme": "light" }
|
|
|
|
click: "#theme-dark"
|
|
|
|
// Should be the dark theme so let's check the color.
|
2022-11-13 20:37:42 +00:00
|
|
|
wait-for-css: ("body", { "background-color": |background_dark| })
|
2022-05-11 21:11:31 +00:00
|
|
|
assert-local-storage: { "rustdoc-theme": "dark" }
|
2022-01-29 09:44:27 +00:00
|
|
|
|
2023-04-11 17:11:34 +00:00
|
|
|
set-local-storage: {
|
2022-11-13 20:37:42 +00:00
|
|
|
"rustdoc-preferred-light-theme": "light",
|
|
|
|
"rustdoc-preferred-dark-theme": "light",
|
|
|
|
}
|
2023-04-11 17:11:34 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/settings.html"
|
2022-11-13 20:37:42 +00:00
|
|
|
|
2022-01-19 22:06:17 +00:00
|
|
|
wait-for: "#settings"
|
2022-01-29 09:44:27 +00:00
|
|
|
click: "#theme-light"
|
2022-11-13 20:37:42 +00:00
|
|
|
wait-for-css: ("body", { "background-color": |background_light| })
|
2022-01-29 09:44:27 +00:00
|
|
|
assert-local-storage: { "rustdoc-theme": "light" }
|
|
|
|
|
|
|
|
click: "#theme-dark"
|
2022-11-13 20:37:42 +00:00
|
|
|
wait-for-css: ("body", { "background-color": |background_dark| })
|
2022-01-29 09:44:27 +00:00
|
|
|
assert-local-storage: { "rustdoc-theme": "dark" }
|
|
|
|
|
|
|
|
click: "#theme-ayu"
|
2022-11-13 20:37:42 +00:00
|
|
|
wait-for-css: ("body", { "background-color": |background_ayu| })
|
2022-01-29 09:44:27 +00:00
|
|
|
assert-local-storage: { "rustdoc-theme": "ayu" }
|
2022-11-13 20:37:42 +00:00
|
|
|
|
|
|
|
assert-local-storage-false: { "rustdoc-use-system-theme": "true" }
|
|
|
|
click: "#theme-system-preference"
|
2023-01-23 17:44:01 +00:00
|
|
|
wait-for: "#preferred-light-theme.setting-line:not(.hidden)"
|
2022-11-13 20:37:42 +00:00
|
|
|
assert-local-storage: { "rustdoc-use-system-theme": "true" }
|
|
|
|
// We click on both preferred light and dark themes to be sure that there is a change.
|
|
|
|
click: "#preferred-light-theme-dark"
|
|
|
|
click: "#preferred-dark-theme-dark"
|
|
|
|
wait-for-css: ("body", { "background-color": |background_dark| })
|
|
|
|
|
|
|
|
reload:
|
|
|
|
// Ensure that the "preferred themes" are still displayed.
|
2023-01-23 17:44:01 +00:00
|
|
|
wait-for: "#preferred-light-theme.setting-line:not(.hidden)"
|
2022-11-13 20:37:42 +00:00
|
|
|
click: "#theme-light"
|
|
|
|
wait-for-css: ("body", { "background-color": |background_light| })
|
|
|
|
assert-local-storage: { "rustdoc-theme": "light" }
|
|
|
|
// Ensure it's now hidden again
|
2023-01-23 17:44:01 +00:00
|
|
|
wait-for: "#preferred-light-theme.setting-line.hidden"
|
2022-11-13 20:37:42 +00:00
|
|
|
// And ensure the theme was rightly set.
|
|
|
|
wait-for-css: ("body", { "background-color": |background_light| })
|
|
|
|
assert-local-storage: { "rustdoc-theme": "light" }
|
|
|
|
|
|
|
|
reload:
|
|
|
|
wait-for: "#settings"
|
2023-01-23 17:44:01 +00:00
|
|
|
assert: "#preferred-light-theme.setting-line.hidden"
|
2023-09-14 20:24:23 +00:00
|
|
|
|
|
|
|
// Ensures that the custom theme feature is working as expected.
|
|
|
|
go-to: "file://" + |DOC_PATH| + "/theme_css/index.html"
|
|
|
|
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
|
|
|
|
reload:
|
|
|
|
|
|
|
|
store-value: (background_light, "white")
|
|
|
|
store-value: (background_dark, "#353535")
|
|
|
|
store-value: (background_ayu, "#0f1419")
|
|
|
|
store-value: (background_custom_theme, "red")
|
|
|
|
|
|
|
|
click: "#settings-menu"
|
|
|
|
wait-for: "#theme-ayu"
|
|
|
|
click: "#theme-ayu"
|
|
|
|
// should be the ayu theme so let's check the color.
|
|
|
|
wait-for-css: ("body", { "background-color": |background_ayu| })
|
|
|
|
assert-local-storage: { "rustdoc-theme": "ayu" }
|
|
|
|
assert-text: (".custom-text", "custom text")
|
|
|
|
click: "#theme-light"
|
|
|
|
// should be the light theme so let's check the color.
|
|
|
|
wait-for-css: ("body", { "background-color": |background_light| })
|
|
|
|
assert-local-storage: { "rustdoc-theme": "light" }
|
|
|
|
assert-text: (".custom-text", "custom text")
|
|
|
|
click: "#theme-dark"
|
|
|
|
// Should be the dark theme so let's check the color.
|
|
|
|
wait-for-css: ("body", { "background-color": |background_dark| })
|
|
|
|
assert-local-storage: { "rustdoc-theme": "dark" }
|
|
|
|
assert-text: (".custom-text", "custom text")
|
|
|
|
click: "#theme-custom-theme"
|
|
|
|
// Should be the custom theme so let's check the color.
|
|
|
|
wait-for-css: ("body", { "background-color": |background_custom_theme| })
|
|
|
|
assert-local-storage: { "rustdoc-theme": "custom-theme" }
|
|
|
|
assert-text: (".custom-text", "custom text")
|