fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
4.3 KiB106 linesraw
1// ignore-tidy-linelength
2// Checks that the search results have the expected width.
3go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
4set-window-size: (900, 1000)
5write: (".search-input", "test")
6// To be SURE that the search will be run.
7press-key: 'Enter'
8wait-for: "#crate-search"
9// The width is returned by "getComputedStyle" which returns the exact number instead of the
10// CSS rule which is "50%"...
11assert-size: (".search-results div.desc", {"width": 248})
12store-size: (".search-results .result-name .typename", {"width": width})
13set-window-size: (600, 100)
14// As counter-intuitive as it may seem, in this width, the width is "100%", which is why
15// when computed it's larger.
16assert-size: (".search-results div.desc", {"width": 566})
17
18// The result set is all on one line.
19compare-elements-position-near: (
20    ".search-results .result-name .typename",
21    ".search-results .result-name .path",
22    {"y": 2},
23)
24compare-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.
30store-size: (".search-results .result-name .typename", {"width": new_width})
31assert: |new_width| < |width| - 10
32
33// Check that if the search is too long on mobile, it'll go under the "typename".
34go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName"
35wait-for: "#crate-search"
36compare-elements-position-near: (
37    ".search-results .result-name .typename",
38    ".search-results .result-name .path",
39    {"y": 2, "x": 0},
40)
41compare-elements-size-near: (
42    ".search-results .result-name",
43    ".search-results .result-name .path",
44    {"width": 8, "height": 8},
45)
46
47// Check that the crate filter `<select>` is correctly handled when it goes to next line.
48// To do so we need to update the length of one of its `<option>`.
49set-window-size: (900, 900)
50
51// First we check the current width, height and position.
52assert-css: ("#crate-search", {"width": "223px"})
53assert-css: (".search-results-title", {"height": "50px", "width": "640px"})
54assert-css: ("#search", {"width": "640px"})
55
56// Then we update the text of one of the `<option>`.
57set-text: (
58    "#crate-search option",
59    "sdjfaksdjfaksjdbfkadsbfkjsadbfkdsbkfbsadkjfbkdsabfkadsfkjdsafa",
60)
61
62// Then we compare again to confirm the height didn't change.
63assert-size: ("#crate-search", {"width": 527})
64assert-size: (".search-results-title", {"height": 50, "width": 640})
65// And we check that the `<select>` isn't bigger than its container (".search-results-title").
66assert-css: ("#search", {"width": "640px"})
67
68// Now checking that the crate filter is working as expected too.
69show-text: true
70define-function: (
71    "check-filter",
72    (theme, border, filter, hover_border, hover_filter),
73    block {
74        set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
75        reload:
76        wait-for: "#crate-search"
77        assert-css: ("#crate-search", {"border": "1px solid " + |border|})
78        assert-css: ("#crate-search-div::after", {"filter": |filter|})
79        move-cursor-to: "#crate-search"
80        assert-css: ("#crate-search", {"border": "1px solid " + |hover_border|})
81        assert-css: ("#crate-search-div::after", {"filter": |hover_filter|})
82        move-cursor-to: ".search-input"
83    },
84)
85
86call-function: ("check-filter", {
87    "theme": "ayu",
88    "border": "#5c6773",
89    "filter": "invert(0.41) sepia(0.12) saturate(4.87) hue-rotate(171deg) brightness(0.94) contrast(0.94)",
90    "hover_border": "#e0e0e0",
91    "hover_filter": "invert(0.98) sepia(0.12) saturate(0.81) hue-rotate(343deg) brightness(1.13) contrast(0.76)",
92})
93call-function: ("check-filter", {
94    "theme": "dark",
95    "border": "#e0e0e0",
96    "filter": "invert(0.94) sepia(0) saturate(7.21) hue-rotate(255deg) brightness(0.9) contrast(0.9)",
97    "hover_border": "#2196f3",
98    "hover_filter": "invert(0.69) sepia(0.6) saturate(66.13) hue-rotate(184deg) brightness(1) contrast(0.91)",
99})
100call-function: ("check-filter", {
101    "theme": "light",
102    "border": "#e0e0e0",
103    "filter": "invert(1) sepia(0) saturate(42.23) hue-rotate(289deg) brightness(1.14) contrast(0.76)",
104    "hover_border": "#717171",
105    "hover_filter": "invert(0.44) sepia(0.18) saturate(0.23) hue-rotate(317deg) brightness(0.96) contrast(0.93)",
106})