1+ // ignore-tidy-linelength
12// Checks that the search results have the expected width.
23go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
34set-window-size: (900, 1000)
@@ -7,15 +8,40 @@ press-key: 'Enter'
78wait-for: "#crate-search"
89// The width is returned by "getComputedStyle" which returns the exact number instead of the
910// 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})
1113set-window-size: (600, 100)
1214// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
1315// when computed it's larger.
1416assert-size: (".search-results div.desc", {"width": 566})
1517
1618// 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
1945
2046// Check that the crate filter `<select>` is correctly handled when it goes to next line.
2147// To do so we need to update the length of one of its `<option>`.
0 commit comments