1
+ // ignore-tidy-linelength
1
2
// Checks that the search results have the expected width.
2
3
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
3
4
set-window-size: (900, 1000)
@@ -7,15 +8,40 @@ press-key: 'Enter'
7
8
wait-for: "#crate-search"
8
9
// The width is returned by "getComputedStyle" which returns the exact number instead of the
9
10
// CSS rule which is "50%"...
10
- assert-size: (".search-results div.desc", {"width": 310})
11
+ assert-size: (".search-results div.desc", {"width": 248})
12
+ store-size: (".search-results .result-name .typename", {"width": width})
11
13
set-window-size: (600, 100)
12
14
// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
13
15
// when computed it's larger.
14
16
assert-size: (".search-results div.desc", {"width": 566})
15
17
16
18
// The result set is all on one line.
17
- assert-css: (".search-results .result-name > span:not(.typename)", {"display": "inline"})
18
- assert-css: (".search-results .result-name > span.typename", {"display": "inline-block"})
19
+ compare-elements-position-near: (
20
+ ".search-results .result-name .typename",
21
+ ".search-results .result-name .path",
22
+ {"y": 2},
23
+ )
24
+ compare-elements-position-near-false: (
25
+ ".search-results .result-name .typename",
26
+ ".search-results .result-name .path",
27
+ {"x": 5},
28
+ )
29
+ // The width of the "typename" isn't fixed anymore in this display mode.
30
+ store-size: (".search-results .result-name .typename", {"width": new_width})
31
+ assert: |new_width| < |width| - 10
32
+
33
+ // Check that if the search is too long on mobile, it'll go under the "typename".
34
+ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName"
35
+ wait-for: "#crate-search"
36
+ compare-elements-position-near: (
37
+ ".search-results .result-name .typename",
38
+ ".search-results .result-name .path",
39
+ {"y": 2, "x": 0},
40
+ )
41
+ store-size: (".search-results .result-name", {"width": width, "height": height})
42
+ store-size: (".search-results .result-name .path", {"width": sub_width, "height": sub_height})
43
+ assert: |width| < |sub_width| + 8 && |width| > |sub_width| - 8
44
+ assert: |height| < |sub_height| + 8 && |height| > |sub_height| - 8
19
45
20
46
// Check that the crate filter `<select>` is correctly handled when it goes to next line.
21
47
// To do so we need to update the length of one of its `<option>`.
0 commit comments