fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// Ensures that the theme change is working as expected. 2go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" 3set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} 4reload: 5 6store-value: (background_light, "white") 7store-value: (background_dark, "#353535") 8store-value: (background_ayu, "#0f1419") 9 10click: "#settings-menu" 11wait-for: "#theme-ayu" 12click: "#theme-ayu" 13// should be the ayu theme so let's check the color. 14wait-for-css: ("body", { "background-color": |background_ayu| }) 15assert-local-storage: { "rustdoc-theme": "ayu" } 16click: "#theme-light" 17// should be the light theme so let's check the color. 18wait-for-css: ("body", { "background-color": |background_light| }) 19assert-local-storage: { "rustdoc-theme": "light" } 20click: "#theme-dark" 21// Should be the dark theme so let's check the color. 22wait-for-css: ("body", { "background-color": |background_dark| }) 23assert-local-storage: { "rustdoc-theme": "dark" } 24 25set-local-storage: { 26 "rustdoc-preferred-light-theme": "light", 27 "rustdoc-preferred-dark-theme": "light", 28} 29go-to: "file://" + |DOC_PATH| + "/settings.html" 30 31wait-for: "#settings" 32click: "#theme-light" 33wait-for-css: ("body", { "background-color": |background_light| }) 34assert-local-storage: { "rustdoc-theme": "light" } 35 36click: "#theme-dark" 37wait-for-css: ("body", { "background-color": |background_dark| }) 38assert-local-storage: { "rustdoc-theme": "dark" } 39 40click: "#theme-ayu" 41wait-for-css: ("body", { "background-color": |background_ayu| }) 42assert-local-storage: { "rustdoc-theme": "ayu" } 43 44assert-local-storage-false: { "rustdoc-use-system-theme": "true" } 45click: "#theme-system-preference" 46wait-for: "#preferred-light-theme.setting-line:not(.hidden)" 47assert-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. 49click: "#preferred-light-theme-dark" 50click: "#preferred-dark-theme-dark" 51wait-for-css: ("body", { "background-color": |background_dark| }) 52 53reload: 54// Ensure that the "preferred themes" are still displayed. 55wait-for: "#preferred-light-theme.setting-line:not(.hidden)" 56click: "#theme-light" 57wait-for-css: ("body", { "background-color": |background_light| }) 58assert-local-storage: { "rustdoc-theme": "light" } 59// Ensure it's now hidden again 60wait-for: "#preferred-light-theme.setting-line.hidden" 61// And ensure the theme was rightly set. 62wait-for-css: ("body", { "background-color": |background_light| }) 63assert-local-storage: { "rustdoc-theme": "light" } 64 65reload: 66wait-for: "#settings" 67assert: "#preferred-light-theme.setting-line.hidden" 68 69// Ensures that the custom theme feature is working as expected. 70go-to: "file://" + |DOC_PATH| + "/theme_css/index.html" 71set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} 72reload: 73 74store-value: (background_light, "white") 75store-value: (background_dark, "#353535") 76store-value: (background_ayu, "#0f1419") 77store-value: (background_custom_theme, "red") 78 79click: "#settings-menu" 80wait-for: "#theme-ayu" 81click: "#theme-ayu" 82// should be the ayu theme so let's check the color. 83wait-for-css: ("body", { "background-color": |background_ayu| }) 84assert-local-storage: { "rustdoc-theme": "ayu" } 85assert-text: (".custom-text", "custom text") 86click: "#theme-light" 87// should be the light theme so let's check the color. 88wait-for-css: ("body", { "background-color": |background_light| }) 89assert-local-storage: { "rustdoc-theme": "light" } 90assert-text: (".custom-text", "custom text") 91click: "#theme-dark" 92// Should be the dark theme so let's check the color. 93wait-for-css: ("body", { "background-color": |background_dark| }) 94assert-local-storage: { "rustdoc-theme": "dark" } 95assert-text: (".custom-text", "custom text") 96click: "#theme-custom-theme" 97// Should be the custom theme so let's check the color. 98wait-for-css: ("body", { "background-color": |background_custom_theme| }) 99assert-local-storage: { "rustdoc-theme": "custom-theme" } 100assert-text: (".custom-text", "custom text")