Skip to content

Commit 5b5fd94

Browse files
Update GUI tests for code example buttons
1 parent 38c8bc5 commit 5b5fd94

File tree

3 files changed

+71
-56
lines changed

3 files changed

+71
-56
lines changed

tests/rustdoc-gui/code-example-buttons.goml

+69
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This test ensures that code blocks buttons are displayed on hover and when you click on them.
22
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
3+
include: "utils.goml"
34

45
// First we check we "hover".
56
move-cursor-to: ".example-wrap"
@@ -19,3 +20,71 @@ click: ".example-wrap"
1920
move-cursor-to: ".search-input"
2021
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0)
2122
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
23+
24+
define-function: (
25+
"check-buttons",
26+
[theme, background, filter, filter_hover],
27+
block {
28+
call-function: ("switch-theme", {"theme": |theme|})
29+
30+
assert-css: (".example-wrap .test-arrow", {"visibility": "hidden"})
31+
assert-css: (".example-wrap .copy-button", {"visibility": "hidden"})
32+
33+
move-cursor-to: ".example-wrap"
34+
assert-css: (".example-wrap .test-arrow", {
35+
"visibility": "visible",
36+
"background-color": |background|,
37+
"border-radius": "2px",
38+
})
39+
assert-css: (".example-wrap .test-arrow::before", {
40+
"filter": |filter|,
41+
})
42+
assert-css: (".example-wrap .copy-button", {
43+
"visibility": "visible",
44+
"background-color": |background|,
45+
"border-radius": "2px",
46+
})
47+
assert-css: (".example-wrap .copy-button::before", {
48+
"filter": |filter|,
49+
})
50+
51+
move-cursor-to: ".example-wrap .test-arrow"
52+
assert-css: (".example-wrap .test-arrow:hover", {
53+
"visibility": "visible",
54+
"background-color": |background|,
55+
"border-radius": "2px",
56+
})
57+
assert-css: (".example-wrap .test-arrow:hover::before", {
58+
"filter": |filter_hover|,
59+
})
60+
61+
move-cursor-to: ".example-wrap .copy-button"
62+
assert-css: (".example-wrap .copy-button:hover", {
63+
"visibility": "visible",
64+
"background-color": |background|,
65+
"border-radius": "2px",
66+
})
67+
assert-css: (".example-wrap .copy-button:hover::before", {
68+
"filter": |filter_hover|,
69+
})
70+
},
71+
)
72+
73+
call-function: ("check-buttons",{
74+
"theme": "ayu",
75+
"background": "#0f1419",
76+
"filter": "invert(0.7)",
77+
"filter_hover": "invert(1)",
78+
})
79+
call-function: ("check-buttons",{
80+
"theme": "dark",
81+
"background": "#353535",
82+
"filter": "invert(0.5)",
83+
"filter_hover": "invert(0.65)",
84+
})
85+
call-function: ("check-buttons",{
86+
"theme": "light",
87+
"background": "#fff",
88+
"filter": "invert(0.5)",
89+
"filter_hover": "invert(0.35)",
90+
})

tests/rustdoc-gui/copy-code.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ define-function: (
2424
)
2525

2626
call-function: ("check-copy-button", {})
27-
// Checking that the run button and the copy button have the same height.
27+
// Checking that the run button and the copy button have the same height and same width.
2828
compare-elements-size: (
2929
".example-wrap:nth-of-type(1) .test-arrow",
3030
".example-wrap:nth-of-type(1) .copy-button",
31-
["height"],
31+
["height", "width"],
3232
)
3333
// ... and the same y position.
3434
compare-elements-position: (

tests/rustdoc-gui/run-on-hover.goml

-54
This file was deleted.

0 commit comments

Comments
 (0)