Skip to content

Commit 65fedeb

Browse files
Add GUI test for new "sans serif fonts" setting
1 parent d93cbe5 commit 65fedeb

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

Diff for: tests/rustdoc-gui/font-serif-change.goml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Ensures that the font serif change is working as expected.
2+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
3+
4+
// By default, it should be the serif fonts.
5+
store-value: (serif_font, '"Source Serif 4", NanumBarunGothic, serif')
6+
store-value: (serif_code_font, '"Source Code Pro", monospace')
7+
assert-css: ("body", {"font-family": |serif_font|})
8+
assert-css: ("p code", {"font-family": |serif_code_font|})
9+
10+
// We now switch to the sans serif font
11+
click: "#settings-menu"
12+
wait-for: "#sans-serif-fonts"
13+
click: "#sans-serif-fonts"
14+
15+
store-value: (font, '"Fira Sans", sans-serif')
16+
store-value: (code_font, '"Fira Mono", monospace')
17+
assert-css: ("body", {"font-family": |font|})
18+
assert-css: ("p code", {"font-family": |code_font|})
19+
20+
// Reloading the page to ensure it is loaded correctly.
21+
reload:
22+
assert-css: ("body", {"font-family": |font|})
23+
assert-css: ("p code", {"font-family": |code_font|})
24+
25+
// We switch back to the serif font
26+
click: "#settings-menu"
27+
wait-for: "#sans-serif-fonts"
28+
click: "#sans-serif-fonts"
29+
30+
assert-css: ("body", {"font-family": |serif_font|})
31+
assert-css: ("p code", {"font-family": |serif_code_font|})

Diff for: tests/rustdoc-gui/settings.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ assert-text: ("#preferred-light-theme .setting-radio-name", "Preferred light the
257257
// We now check that clicking on the toggles' text is like clicking on the checkbox.
258258
// To test it, we use the "Disable keyboard shortcuts".
259259
set-local-storage: {"rustdoc-disable-shortcuts": "false"}
260-
click: ".setting-line:last-child .setting-check span"
260+
click: "#disable-shortcuts"
261261
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
262262

263263
// We now check that focusing a toggle and pressing Space is like clicking on it.
264264
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
265-
focus: ".setting-line:last-child .setting-check input"
265+
focus: "#disable-shortcuts"
266266
press-key: "Space"
267267
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
268-
focus: ".setting-line:last-child .setting-check input"
268+
focus: "#disable-shortcuts"
269269
press-key: "Space"
270270
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
271271

@@ -276,7 +276,7 @@ assert-false: "#help-button .popover"
276276
wait-for-css: ("#settings-menu .popover", {"display": "block"})
277277

278278
// Now turn keyboard shortcuts back on, and see if they work.
279-
click: ".setting-line:last-child .setting-check span"
279+
click: "#disable-shortcuts"
280280
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
281281
press-key: "Escape"
282282
press-key: "?"

0 commit comments

Comments
 (0)