Skip to content

Commit b44c1df

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

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 > button", {"border-color": "#4e4e4e", "cursor": "pointer"})
20+
move-cursor-to: ".toggle-source > button"
21+
assert-css: (".toggle-source > button:hover", {"border-color": "#c0c0c0", "cursor": "pointer"})
22+
23+
store-size: ("#side-menu", {"width": side_menu_width})
24+
store-size: ("#source-code-container", {"width": source_width})
25+
26+
// Now we hide the side menu.
27+
click: ".toggle-source > button"
28+
wait-for: "#side-menu.collapsed"
29+
30+
store-size: ("#side-menu", {"width": side_menu_width2})
31+
store-size: ("#source-code-container", {"width": source_width2})
32+
33+
// The elements width should have changed (smaller side menu and bigger source).
34+
assert: |side_menu_width| > |side_menu_width2|
35+
assert: |source_width| < |source_width2|
36+
// The total width should not have changed.
37+
assert: |source_width2| + |side_menu_width2| == |source_width| + |side_menu_width|

0 commit comments

Comments
 (0)