]> git.proxmox.com Git - rustc.git/blob - tests/rustdoc-gui/sidebar.goml
New upstream version 1.69.0+dfsg1
[rustc.git] / tests / rustdoc-gui / sidebar.goml
1 // Checks multiple things on the sidebar display (width of its elements, colors, etc).
2 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
3 assert-property: (".sidebar", {"clientWidth": "200"})
4 show-text: true
5
6 // First, check the sidebar colors.
7 define-function: (
8 "check-colors",
9 (theme, color, background_color),
10 block {
11 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
24 call-function: (
25 "check-colors",
26 {
27 "theme": "ayu",
28 "color": "rgb(197, 197, 197)",
29 "background_color": "rgb(20, 25, 31)",
30 }
31 )
32 call-function: (
33 "check-colors",
34 {
35 "theme": "dark",
36 "color": "rgb(221, 221, 221)",
37 "background_color": "rgb(80, 80, 80)",
38 }
39 )
40 call-function: (
41 "check-colors",
42 {
43 "theme": "light",
44 "color": "rgb(0, 0, 0)",
45 "background_color": "rgb(245, 245, 245)",
46 }
47 )
48
49 local-storage: {"rustdoc-theme": "light"}
50 // We reload the page so the local storage settings are being used.
51 reload:
52
53 assert-text: (".sidebar > .location", "Crate test_docs")
54 // In modules, we only have one "location" element.
55 assert-count: (".sidebar .location", 1)
56 assert-count: (".sidebar h2", 1)
57 assert-text: ("#all-types", "All Items")
58 assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
59 // We check that we have the crates list and that the "current" on is "test_docs".
60 assert-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.
62 assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
63 assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
64 assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
65 assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
66 assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
67 assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants")
68 assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits")
69 assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions")
70 assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions")
71 assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions")
72 assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords")
73 assert-text: ("#structs + .item-table .item-name > a", "Foo")
74 click: "#structs + .item-table .item-name > a"
75
76 // PAGE: struct.Foo.html
77 assert-count: (".sidebar .location", 1)
78 assert-count: (".sidebar h2", 2)
79 // We check that there is no crate listed outside of the top level.
80 assert-false: ".sidebar-elems > .crate"
81
82 click: ".sidebar-elems section .block li > a"
83 assert-property-false: ("html", {"scrollTop": "0"})
84
85 click: ".sidebar h2.location a"
86 assert-property: ("html", {"scrollTop": "0"})
87
88 // We now go back to the crate page to click on the "lib2" crate link.
89 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
90 assert-property: (".sidebar", {"clientWidth": "200"})
91 assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "rgb(53, 109, 164)"})
92 click: ".sidebar-elems ul.crate > li:first-child > a"
93
94 // PAGE: lib2/index.html
95 goto: "file://" + |DOC_PATH| + "/lib2/index.html"
96 assert-property: (".sidebar", {"clientWidth": "200"})
97 assert-text: (".sidebar > .location", "Crate lib2")
98 // We check that we have the crates list and that the "current" on is now "lib2".
99 assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2")
100 // We now go to the "foobar" function page.
101 assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules")
102 assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs")
103 assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits")
104 assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions")
105 assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Definitions")
106 assert-text: ("#functions + .item-table .item-name > a", "foobar")
107 click: "#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.
112 assert-count: (".sidebar .location", 0)
113 assert-count: (".sidebar h2", 1)
114 assert-text: (".sidebar .sidebar-elems h2", "In lib2")
115 // We check that we don't have the crate list.
116 assert-false: ".sidebar-elems > .crate"
117
118 goto: "./module/index.html"
119 assert-property: (".sidebar", {"clientWidth": "200"})
120 assert-text: (".sidebar > .location", "Module module")
121 // We check that we don't have the crate list.
122 assert-false: ".sidebar-elems > .crate"
123
124 goto: "./sub_module/sub_sub_module/index.html"
125 assert-property: (".sidebar", {"clientWidth": "200"})
126 assert-text: (".sidebar > .location", "Module sub_sub_module")
127 // We check that we don't have the crate list.
128 assert-false: ".sidebar-elems .crate"
129 assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions")
130 assert-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.
133 goto: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html"
134 assert-property: (".sidebar", {"clientWidth": "200"})
135 assert-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.
139 goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
140 assert-property: (".sidebar", {"clientWidth": "200"})
141 click: "//ul[@class='block mod']/preceding-sibling::h3/a"
142 // PAGE: index.html
143 assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"})
144
145 // Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width.
146 click: "#toggle-all-docs"
147 assert-text: ("#toggle-all-docs", "[+]")
148 assert-property: (".sidebar", {"clientWidth": "200"})
149 click: "#toggle-all-docs"
150 assert-text: ("#toggle-all-docs", "[−]")
151 assert-property: (".sidebar", {"clientWidth": "200"})