Skip to content

Commit 8c0aa1e

Browse files
Add GUI test for docs.rs source code page
1 parent abe2edc commit 8c0aa1e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Diff for: gui-tests/source-viewer.goml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Checks that the docs.rs source code viewer page looks as expected.
2+
go-to: |DOC_PATH| + "/crate/sysinfo/latest/source/Cargo.toml"
3+
// We enforce a theme to ensure that the color checks will succeed.
4+
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
5+
reload:
6+
7+
// Bugs appears when window size is at maximum given width so we set it.
8+
set-window-size: (800, 800)
9+
10+
// First we ensure that the "documentation link button" is taking only one line.
11+
store-size: (".doc-link > span", {"height": icon_height})
12+
store-size: (".doc-link", {"height": button_height})
13+
assert-css: (".doc-link", {"padding-top": "10px", "padding-bottom": "10px"})
14+
// As confirmed just above, there is 20px of padding, so we subtract it from the check below.
15+
assert: |button_height| - 20 < |icon_height| * 2
16+
17+
// We check that hovering the side menu toggle will update the border color and also change the
18+
// mouse cursor.
19+
assert-css: (".toggle-source", {"border-color": "#4e4e4e", "cursor": "pointer"})
20+
assert-css: (".toggle-source > button", {"cursor": "pointer"})
21+
move-cursor-to: ".toggle-source > button"
22+
assert-css: (".toggle-source:hover", {"border-color": "#c0c0c0", "cursor": "pointer"})
23+
assert-css: (".toggle-source >button:hover", {"cursor": "pointer"})
24+
25+
store-size: ("#side-menu", {"width": side_menu_width})
26+
store-size: ("#source-code-container", {"width": source_width})
27+
28+
// Now we hide the side menu.
29+
click: ".toggle-source > button"
30+
wait-for: "#side-menu.collapsed"
31+
32+
store-size: ("#side-menu", {"width": side_menu_width2})
33+
store-size: ("#source-code-container", {"width": source_width2})
34+
35+
// The elements width should have changed (smaller side menu and bigger source).
36+
assert: |side_menu_width| > |side_menu_width2|
37+
assert: |source_width| < |source_width2|
38+
// The total width should not have changed.
39+
assert: |source_width2| + |side_menu_width2| == |source_width| + |side_menu_width|

0 commit comments

Comments
 (0)