forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode-example-buttons.goml
119 lines (107 loc) · 4.33 KB
/
code-example-buttons.goml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// This test ensures that code blocks buttons are displayed on hover and when you click on them.
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
include: "utils.goml"
// First we check we "hover".
move-cursor-to: ".example-wrap"
assert-css: (".example-wrap .copy-button", { "visibility": "visible" })
move-cursor-to: ".search-input"
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
// Now we check the click.
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0)
click: ".example-wrap"
move-cursor-to: ".search-input"
// It should have a new class and be visible.
wait-for-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 1)
wait-for-css: (".example-wrap:not(:hover) .button-holder.keep-visible", { "visibility": "visible" })
// Clicking again will remove the class.
click: ".example-wrap"
move-cursor-to: ".search-input"
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0)
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
// Clicking on the "copy code" button shouldn't make the buttons stick.
click: ".example-wrap .copy-button"
move-cursor-to: ".search-input"
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0)
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
// Since we clicked on the copy button, the clipboard content should have been updated.
assert-clipboard: 'println!("nothing fancy");\nprintln!("but with two lines!");'
define-function: (
"check-buttons",
[theme, background, filter, filter_hover],
block {
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".example-wrap .test-arrow", {"visibility": "hidden"})
assert-css: (".example-wrap .copy-button", {"visibility": "hidden"})
move-cursor-to: ".example-wrap"
assert-css: (".example-wrap .test-arrow", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .test-arrow::before", {
"filter": |filter|,
})
assert-css: (".example-wrap .copy-button", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .copy-button::before", {
"filter": |filter|,
})
move-cursor-to: ".example-wrap .test-arrow"
assert-css: (".example-wrap .test-arrow:hover", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .test-arrow:hover::before", {
"filter": |filter_hover|,
})
move-cursor-to: ".example-wrap .copy-button"
assert-css: (".example-wrap .copy-button:hover", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .copy-button:hover::before", {
"filter": |filter_hover|,
})
},
)
call-function: ("check-buttons",{
"theme": "ayu",
"background": "#0f1419",
"filter": "invert(0.7)",
"filter_hover": "invert(1)",
})
call-function: ("check-buttons",{
"theme": "dark",
"background": "#353535",
"filter": "invert(0.5)",
"filter_hover": "invert(0.65)",
})
call-function: ("check-buttons",{
"theme": "light",
"background": "#fff",
"filter": "invert(0.5)",
"filter_hover": "invert(0.35)",
})
define-function: (
"check-buttons-position",
[pre_selector],
block {
move-cursor-to: |pre_selector| + " .rust:not(.item-decl)"
store-position: (|pre_selector| + " .rust:not(.item-decl)", {"x": x, "y": y})
assert-position: (|pre_selector| + " .rust:not(.item-decl) + .button-holder", {
"y": |y| + 4,
})
}
)
call-function: ("check-buttons-position", {"pre_selector": ".example-wrap"})
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
// We should work as well for scraped examples.
call-function: ("check-buttons-position", {"pre_selector": ".scraped-example .example-wrap"})
// And also when the scraped example "title" goes above.
set-window-size: (600, 600)
call-function: ("check-buttons-position", {"pre_selector": ".scraped-example .example-wrap"})