about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-03 15:55:05 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-01-29 11:01:14 +0100
commit65fedebfc40653d88142171252f5e8b004afbfb9 (patch)
treeda42b61c936cdd71de712d5ba42b9da386fb96e7
parentd93cbe5d693b8f486b82d2b11a7cbb7e2c09c1e8 (diff)
downloadrust-65fedebfc40653d88142171252f5e8b004afbfb9.tar.gz
rust-65fedebfc40653d88142171252f5e8b004afbfb9.zip
Add GUI test for new "sans serif fonts" setting
-rw-r--r--tests/rustdoc-gui/font-serif-change.goml31
-rw-r--r--tests/rustdoc-gui/settings.goml8
2 files changed, 35 insertions, 4 deletions
diff --git a/tests/rustdoc-gui/font-serif-change.goml b/tests/rustdoc-gui/font-serif-change.goml
new file mode 100644
index 00000000000..b14d5ae96f9
--- /dev/null
+++ b/tests/rustdoc-gui/font-serif-change.goml
@@ -0,0 +1,31 @@
+// Ensures that the font serif change is working as expected.
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+
+// By default, it should be the serif fonts.
+store-value: (serif_font, '"Source Serif 4", NanumBarunGothic, serif')
+store-value: (serif_code_font, '"Source Code Pro", monospace')
+assert-css: ("body", {"font-family": |serif_font|})
+assert-css: ("p code", {"font-family": |serif_code_font|})
+
+// We now switch to the sans serif font
+click: "#settings-menu"
+wait-for: "#sans-serif-fonts"
+click: "#sans-serif-fonts"
+
+store-value: (font, '"Fira Sans", sans-serif')
+store-value: (code_font, '"Fira Mono", monospace')
+assert-css: ("body", {"font-family": |font|})
+assert-css: ("p code", {"font-family": |code_font|})
+
+// Reloading the page to ensure it is loaded correctly.
+reload:
+assert-css: ("body", {"font-family": |font|})
+assert-css: ("p code", {"font-family": |code_font|})
+
+// We switch back to the serif font
+click: "#settings-menu"
+wait-for: "#sans-serif-fonts"
+click: "#sans-serif-fonts"
+
+assert-css: ("body", {"font-family": |serif_font|})
+assert-css: ("p code", {"font-family": |serif_code_font|})
diff --git a/tests/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml
index 1d93c07f9ec..4ab5b83d7c4 100644
--- a/tests/rustdoc-gui/settings.goml
+++ b/tests/rustdoc-gui/settings.goml
@@ -257,15 +257,15 @@ assert-text: ("#preferred-light-theme .setting-radio-name", "Preferred light the
 // We now check that clicking on the toggles' text is like clicking on the checkbox.
 // To test it, we use the "Disable keyboard shortcuts".
 set-local-storage: {"rustdoc-disable-shortcuts": "false"}
-click: ".setting-line:last-child .setting-check span"
+click: "#disable-shortcuts"
 assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
 
 // We now check that focusing a toggle and pressing Space is like clicking on it.
 assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
-focus: ".setting-line:last-child .setting-check input"
+focus: "#disable-shortcuts"
 press-key: "Space"
 assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
-focus: ".setting-line:last-child .setting-check input"
+focus: "#disable-shortcuts"
 press-key: "Space"
 assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
 
@@ -276,7 +276,7 @@ assert-false: "#help-button .popover"
 wait-for-css: ("#settings-menu .popover", {"display": "block"})
 
 // Now turn keyboard shortcuts back on, and see if they work.
-click: ".setting-line:last-child .setting-check span"
+click: "#disable-shortcuts"
 assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
 press-key: "Escape"
 press-key: "?"