diff --git a/crates/mdbook-html/front-end/css/variables.css b/crates/mdbook-html/front-end/css/variables.css index af5023bc3e..861a45adf7 100644 --- a/crates/mdbook-html/front-end/css/variables.css +++ b/crates/mdbook-html/front-end/css/variables.css @@ -301,6 +301,8 @@ --searchresults-li-bg: #dec2a2; --search-mark-bg: #e69f67; + --color-scheme: light; + /* Same as `--icons` */ --copy-button-filter: invert(51%) sepia(10%) saturate(393%) hue-rotate(198deg) brightness(86%) contrast(87%); /* Same as `--sidebar-active` */ diff --git a/tests/gui/books/basic/src/SUMMARY.md b/tests/gui/books/basic/src/SUMMARY.md index 7390c82896..fa67cf3e84 100644 --- a/tests/gui/books/basic/src/SUMMARY.md +++ b/tests/gui/books/basic/src/SUMMARY.md @@ -1,3 +1,4 @@ # Summary - [Chapter 1](./chapter_1.md) +- [Chapter 2](./chapter_2.md) diff --git a/tests/gui/books/basic/src/chapter_2.md b/tests/gui/books/basic/src/chapter_2.md new file mode 100644 index 0000000000..785a9e090a --- /dev/null +++ b/tests/gui/books/basic/src/chapter_2.md @@ -0,0 +1,10 @@ + + +# title + +Some content diff --git a/tests/gui/color-scheme.goml b/tests/gui/color-scheme.goml new file mode 100644 index 0000000000..dc7c8c7a8d --- /dev/null +++ b/tests/gui/color-scheme.goml @@ -0,0 +1,39 @@ +// This GUI test checks help popup. + +go-to: |DOC_PATH| + "basic/chapter_2.html" + +define-function: ( + "change-theme", + [theme], + block { + store-css: ("#mdbook-theme-list", {"display": theme_list_display}) + if: (|theme_list_display| != "block", block { + click: "#mdbook-theme-toggle" + wait-for-css: ("#mdbook-theme-list", {"display": "block"}) + }) + click: "#mdbook-theme-list #mdbook-theme-" + |theme| + wait-for: "#mdbook-theme-list #mdbook-theme-" + |theme| + ".theme-selected" + }, +) + +define-function: ( + "check-scheme-applied", + [theme, background_color], + block { + call-function: ("change-theme", {"theme": |theme|}) + assert-css: ("#mdbook-content main", {"background-color": |background_color|}) + store-value: (themes_checked, |themes_checked| + 1) + } +) + +store-value: (themes_checked, 1) // It's one to take into account the "auto" theme. + +call-function: ("check-scheme-applied", {"theme": "light", "background_color": "white"}) +call-function: ("check-scheme-applied", {"theme": "rust", "background_color": "white"}) +call-function: ("check-scheme-applied", {"theme": "coal", "background_color": "black"}) +call-function: ("check-scheme-applied", {"theme": "navy", "background_color": "black"}) +call-function: ("check-scheme-applied", {"theme": "ayu", "background_color": "black"}) + +// We confirm that the we checked all themes. If other themes are added later on, this test will +// fail. +assert-count: ("#mdbook-theme-list .theme", |themes_checked|) diff --git a/tests/gui/help.goml b/tests/gui/help.goml index d304e773cc..fbd28c92b0 100644 --- a/tests/gui/help.goml +++ b/tests/gui/help.goml @@ -12,5 +12,5 @@ wait-for-css: ("#mdbook-help-container", {"display": "flex"}) click: "#mdbook-help-popup" wait-for-css: ("#mdbook-help-container", {"display": "flex"}) // Click outside dismisses. -click: "*" +click: (0, 0) wait-for-css: ("#mdbook-help-container", {"display": "none"})