2
2
include: "utils.goml"
3
3
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
4
4
show-text: true
5
- // We start with a wide screen.
6
- set-window-size: (1100, 600)
7
- // Checking they have the same y position.
8
- compare-elements-position: (
9
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
10
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
11
- ["y"],
12
- )
13
- // Checking they don't have the same x position.
14
- compare-elements-position-false: (
15
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
16
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
17
- ["x"],
18
- )
19
- // The `i` should be *after* the type.
20
- assert-position: (
21
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
22
- {"x": 677},
23
- )
24
- assert-position: (
25
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
26
- {"x": 955},
27
- )
28
- // The tooltip should be below the `i`
29
- // Also, clicking the tooltip should bring its text into the DOM
30
- assert-count: ("//*[@class='tooltip popover']", 0)
31
- click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
32
- assert-count: ("//*[@class='tooltip popover']", 1)
33
- compare-elements-position-near: (
34
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
35
- "//*[@class='tooltip popover']",
36
- {"y": 30}
5
+
6
+ define-function: (
7
+ "check-notable-tooltip-position",
8
+ [x, i_x],
9
+ block {
10
+ // Checking they have the same y position.
11
+ compare-elements-position: (
12
+ "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
13
+ "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
14
+ ["y"],
15
+ )
16
+ // Checking they don't have the same x position.
17
+ compare-elements-position-false: (
18
+ "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
19
+ "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
20
+ ["x"],
21
+ )
22
+ // The `i` should be *after* the type.
23
+ assert-position: (
24
+ "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
25
+ {"x": |x|},
26
+ )
27
+ assert-position: (
28
+ "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
29
+ {"x": |i_x|},
30
+ )
31
+ },
37
32
)
38
- compare-elements-position-false: (
39
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
40
- "//*[@class='tooltip popover']",
41
- ["x"]
33
+
34
+ define-function: (
35
+ "check-notable-tooltip-position-complete",
36
+ [x, i_x, popover_x],
37
+ block {
38
+ call-function: ("check-notable-tooltip-position", {"x": |x|, "i_x": |i_x|})
39
+ assert-count: ("//*[@class='tooltip popover']", 0)
40
+ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
41
+ assert-count: ("//*[@class='tooltip popover']", 1)
42
+ compare-elements-position-near: (
43
+ "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
44
+ "//*[@class='tooltip popover']",
45
+ {"y": 30}
46
+ )
47
+ compare-elements-position-false: (
48
+ "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
49
+ "//*[@class='tooltip popover']",
50
+ ["x"]
51
+ )
52
+ assert-position: (
53
+ "//*[@class='tooltip popover']",
54
+ {"x": |popover_x|}
55
+ )
56
+ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
57
+ move-cursor-to: "//h1"
58
+ assert-count: ("//*[@class='tooltip popover']", 0)
59
+ },
42
60
)
43
- click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
44
- move-cursor-to: "//h1"
45
- assert-count: ("//*[@class='tooltip popover']", 0)
61
+
62
+ // We start with a wide screen.
63
+ set-window-size: (1100, 600)
64
+ call-function: ("check-notable-tooltip-position-complete", {
65
+ "x": 677,
66
+ "i_x": 955,
67
+ "popover_x": 463,
68
+ })
46
69
47
70
// Now only the `i` should be on the next line.
48
71
set-window-size: (1055, 600)
@@ -54,71 +77,18 @@ compare-elements-position-false: (
54
77
55
78
// Now both the `i` and the struct name should be on the next line.
56
79
set-window-size: (980, 600)
57
- // Checking they have the same y position.
58
- compare-elements-position: (
59
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
60
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
61
- ["y"],
62
- )
63
- // Checking they don't have the same x position.
64
- compare-elements-position-false: (
65
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
66
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
67
- ["x"],
68
- )
69
- // The `i` should be *after* the type.
70
- assert-position: (
71
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
72
- {"x": 245},
73
- )
74
- assert-position: (
75
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
76
- {"x": 523},
77
- )
80
+ call-function: ("check-notable-tooltip-position", {
81
+ "x": 245,
82
+ "i_x": 523,
83
+ })
78
84
79
85
// Checking on mobile now.
80
86
set-window-size: (650, 600)
81
- // Checking they have the same y position.
82
- compare-elements-position: (
83
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
84
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
85
- ["y"],
86
- )
87
- // Checking they don't have the same x position.
88
- compare-elements-position-false: (
89
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
90
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
91
- ["x"],
92
- )
93
- // The `i` should be *after* the type.
94
- assert-position: (
95
- "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
96
- {"x": 15},
97
- )
98
- assert-position: (
99
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
100
- {"x": 293},
101
- )
102
- // The tooltip should STILL be below `i`
103
- click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
104
- assert-count: ("//*[@class='tooltip popover']", 1)
105
- compare-elements-position-near: (
106
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
107
- "//*[@class='tooltip popover']",
108
- {"y": 30}
109
- )
110
- compare-elements-position-false: (
111
- "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
112
- "//*[@class='tooltip popover']",
113
- ["x"]
114
- )
115
- assert-position: (
116
- "//*[@class='tooltip popover']",
117
- {"x": 0}
118
- )
119
- click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
120
- move-cursor-to: "//h1"
121
- assert-count: ("//*[@class='tooltip popover']", 0)
87
+ call-function: ("check-notable-tooltip-position-complete", {
88
+ "x": 15,
89
+ "i_x": 293,
90
+ "popover_x": 0,
91
+ })
122
92
123
93
// Now check the colors.
124
94
define-function: (
@@ -236,31 +206,31 @@ press-key: "Tab"
236
206
assert-count: ("//*[@class='tooltip popover']", 0)
237
207
assert: "#method\.create_an_iterator_from_read .tooltip:focus"
238
208
209
+ define-function: (
210
+ "setup-popup",
211
+ [],
212
+ block {
213
+ store-window-property: {"scrollY": scroll}
214
+ click: "#method\.create_an_iterator_from_read .fn"
215
+ // We ensure that the scroll position changed.
216
+ assert-window-property-false: {"scrollY": |scroll|}
217
+ // Store the new position.
218
+ store-window-property: {"scrollY": scroll}
219
+ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
220
+ wait-for: "//*[@class='tooltip popover']"
221
+ click: "#settings-menu a"
222
+ }
223
+ )
224
+
239
225
// Now we check that the focus isn't given back to the wrong item when opening
240
226
// another popover.
241
- store-window-property: {"scrollY": scroll}
242
- click: "#method\.create_an_iterator_from_read .fn"
243
- // We ensure that the scroll position changed.
244
- assert-window-property-false: {"scrollY": |scroll|}
245
- // Store the new position.
246
- store-window-property: {"scrollY": scroll}
247
- click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
248
- wait-for: "//*[@class='tooltip popover']"
249
- click: "#settings-menu a"
227
+ call-function: ("setup-popup", {})
250
228
click: ".search-input"
251
229
// We ensure we didn't come back to the previous focused item.
252
230
assert-window-property-false: {"scrollY": |scroll|}
253
231
254
232
// Same but with Escape handling.
255
- store-window-property: {"scrollY": scroll}
256
- click: "#method\.create_an_iterator_from_read .fn"
257
- // We ensure that the scroll position changed.
258
- assert-window-property-false: {"scrollY": |scroll|}
259
- // Store the new position.
260
- store-window-property: {"scrollY": scroll}
261
- click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
262
- wait-for: "//*[@class='tooltip popover']"
263
- click: "#settings-menu a"
233
+ call-function: ("setup-popup", {})
264
234
press-key: "Escape"
265
235
// We ensure we didn't come back to the previous focused item.
266
236
assert-window-property-false: {"scrollY": |scroll|}
0 commit comments