Add GUI test for new "sans serif fonts" setting

This commit is contained in:
Guillaume Gomez 2024-12-03 15:55:05 +01:00
parent d93cbe5d69
commit 65fedebfc4
2 changed files with 35 additions and 4 deletions

View file

@ -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|})

View file

@ -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: "?"