fork/rust

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

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

master
6.6 KiB167 linesraw
1// Checks multiple things on the sidebar display (width of its elements, colors, etc).
2go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
3assert-property: (".sidebar", {"clientWidth": "200"})
4show-text: true
5
6// First, check the sidebar colors.
7define-function: (
8    "check-colors",
9    (theme, color, background_color),
10    block {
11        set-local-storage: {
12            "rustdoc-theme": |theme|,
13            "rustdoc-use-system-theme": "false",
14        }
15        reload:
16        // Checking results colors.
17        assert-css: (".sidebar", {
18            "color": |color|,
19            "background-color": |background_color|
20        }, ALL)
21    },
22)
23
24call-function: (
25    "check-colors",
26    {
27        "theme": "ayu",
28        "color": "#c5c5c5",
29        "background_color": "#14191f",
30    }
31)
32call-function: (
33    "check-colors",
34    {
35        "theme": "dark",
36        "color": "#ddd",
37        "background_color": "#505050",
38    }
39)
40call-function: (
41    "check-colors",
42    {
43        "theme": "light",
44        "color": "black",
45        "background_color": "#f5f5f5",
46    }
47)
48
49set-local-storage: {"rustdoc-theme": "light"}
50// We reload the page so the local storage settings are being used.
51reload:
52
53assert-text: (".sidebar > .location", "Crate test_docs")
54// In modules, we only have one "location" element.
55assert-count: (".sidebar .location", 1)
56assert-count: (".sidebar h2", 1)
57assert-text: ("#all-types", "All Items")
58assert-css: ("#all-types", {"color": "#356da4"})
59// We check that we have the crates list and that the "current" on is "test_docs".
60assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs")
61// And we're also supposed to have the list of items in the current module.
62assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
63assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
64assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
65assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
66assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
67assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants")
68assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits")
69assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions")
70assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Aliases")
71assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions")
72assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords")
73assert-text: ("#structs + .item-table .item-name > a", "Foo")
74click: "#structs + .item-table .item-name > a"
75
76// PAGE: struct.Foo.html
77assert-count: (".sidebar .location", 1)
78assert-count: (".sidebar h2", 2)
79// We check that there is no crate listed outside of the top level.
80assert-false: ".sidebar-elems > .crate"
81
82click: ".sidebar-elems section .block li > a"
83assert-property-false: ("html", {"scrollTop": "0"})
84
85click: ".sidebar h2.location a"
86assert-property: ("html", {"scrollTop": "0"})
87
88// We now go back to the crate page to click on the "lib2" crate link.
89go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
90assert-property: (".sidebar", {"clientWidth": "200"})
91assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "#356da4"})
92click: ".sidebar-elems ul.crate > li:first-child > a"
93
94// PAGE: lib2/index.html
95go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
96assert-property: (".sidebar", {"clientWidth": "200"})
97assert-text: (".sidebar > .location", "Crate lib2")
98// We check that we have the crates list and that the "current" on is now "lib2".
99assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2")
100// We now go to the "foobar" function page.
101assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules")
102assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs")
103assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits")
104assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions")
105assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Aliases")
106assert-text: ("#functions + .item-table .item-name > a", "foobar")
107click: "#functions + .item-table .item-name > a"
108
109// PAGE: fn.foobar.html
110// In items containing no items (like functions or constants) and in modules, we have no
111// "location" elements. Only the parent module h2.
112assert-count: (".sidebar .location", 0)
113assert-count: (".sidebar h2", 1)
114assert-text: (".sidebar .sidebar-elems h2", "In lib2")
115// We check that we don't have the crate list.
116assert-false: ".sidebar-elems > .crate"
117
118go-to: "./module/index.html"
119assert-property: (".sidebar", {"clientWidth": "200"})
120assert-text: (".sidebar > .location", "Module module")
121// We check that we don't have the crate list.
122assert-false: ".sidebar-elems > .crate"
123
124go-to: "./sub_module/sub_sub_module/index.html"
125assert-property: (".sidebar", {"clientWidth": "200"})
126assert-text: (".sidebar > .location", "Module sub_sub_module")
127// We check that we don't have the crate list.
128assert-false: ".sidebar-elems .crate"
129assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions")
130assert-text: ("#functions + .item-table .item-name > a", "foo")
131
132// Links to trait implementations in the sidebar should not wrap even if they are long.
133go-to: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html"
134assert-property: (".sidebar", {"clientWidth": "200"})
135assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29})
136
137// Test that clicking on of the "In <module>" headings in the sidebar links to the
138// appropriate anchor in index.html.
139go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
140assert-property: (".sidebar", {"clientWidth": "200"})
141click: "//ul[@class='block mod']/preceding-sibling::h3/a"
142// PAGE: index.html
143assert-css: ("#modules", {"background-color": "#fdffd3"})
144
145// Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width.
146click: "#toggle-all-docs"
147assert-text: ("#toggle-all-docs", "[+]")
148assert-property: (".sidebar", {"clientWidth": "200"})
149click: "#toggle-all-docs"
150assert-text: ("#toggle-all-docs", "[−]")
151assert-property: (".sidebar", {"clientWidth": "200"})
152
153// Checks that all.html and index.html have their sidebar link in the same place.
154go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
155store-property: (".sidebar .location a", {
156    "clientWidth": index_sidebar_width,
157    "clientHeight": index_sidebar_height,
158    "offsetTop": index_sidebar_y,
159    "offsetLeft": index_sidebar_x,
160})
161go-to: "file://" + |DOC_PATH| + "/test_docs/all.html"
162assert-property: (".sidebar .location a", {
163    "clientWidth": |index_sidebar_width|,
164    "clientHeight": |index_sidebar_height|,
165    "offsetTop": |index_sidebar_y|,
166    "offsetLeft": |index_sidebar_x|,
167})