]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/sidebar.goml
Auto merge of #2607 - RalfJung:rustup, r=RalfJung
[rust.git] / src / test / 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 local-storage: {"rustdoc-theme": "light"}
6 // We reload the page so the local storage settings are being used.
7 reload:
8
9 assert-text: (".sidebar > .location", "Crate test_docs")
10 // In modules, we only have one "location" element.
11 assert-count: (".sidebar .location", 1)
12 assert-count: (".sidebar h2", 1)
13 assert-text: ("#all-types", "All Items")
14 assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
15 // We check that we have the crates list and that the "current" on is "test_docs".
16 assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs")
17 // And we're also supposed to have the list of items in the current module.
18 assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports")
19 assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
20 assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
21 assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
22 assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
23 assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants")
24 assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits")
25 assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions")
26 assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions")
27 assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions")
28 assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords")
29 assert-text: ("#structs + .item-table .item-left > a", "Foo")
30 click: "#structs + .item-table .item-left > a"
31
32 // PAGE: struct.Foo.html
33 assert-count: (".sidebar .location", 1)
34 assert-count: (".sidebar h2", 2)
35 // We check that there is no crate listed outside of the top level.
36 assert-false: ".sidebar-elems > .crate"
37
38 click: ".sidebar-elems section .block li > a"
39 assert-property-false: ("html", {"scrollTop": "0"})
40
41 click: ".sidebar h2.location a"
42 assert-property: ("html", {"scrollTop": "0"})
43
44 // We now go back to the crate page to click on the "lib2" crate link.
45 goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
46 assert-property: (".sidebar", {"clientWidth": "200"})
47 assert-css: (".sidebar-elems ul.crate > li:first-child > a", {"color": "rgb(53, 109, 164)"})
48 click: ".sidebar-elems ul.crate > li:first-child > a"
49
50 // PAGE: lib2/index.html
51 goto: "file://" + |DOC_PATH| + "/lib2/index.html"
52 assert-property: (".sidebar", {"clientWidth": "200"})
53 assert-text: (".sidebar > .location", "Crate lib2")
54 // We check that we have the crates list and that the "current" on is now "lib2".
55 assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2")
56 // We now go to the "foobar" function page.
57 assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules")
58 assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs")
59 assert-text: (".sidebar-elems > section ul.block > li:nth-child(3)", "Traits")
60 assert-text: (".sidebar-elems > section ul.block > li:nth-child(4)", "Functions")
61 assert-text: (".sidebar-elems > section ul.block > li:nth-child(5)", "Type Definitions")
62 assert-text: ("#functions + .item-table .item-left > a", "foobar")
63 click: "#functions + .item-table .item-left > a"
64
65 // PAGE: fn.foobar.html
66 // In items containing no items (like functions or constants) and in modules, we have no
67 // "location" elements. Only the parent module h2.
68 assert-count: (".sidebar .location", 0)
69 assert-count: (".sidebar h2", 1)
70 assert-text: (".sidebar .sidebar-elems h2", "In lib2")
71 // We check that we don't have the crate list.
72 assert-false: ".sidebar-elems > .crate"
73
74 goto: "./module/index.html"
75 assert-property: (".sidebar", {"clientWidth": "200"})
76 assert-text: (".sidebar > .location", "Module module")
77 // We check that we don't have the crate list.
78 assert-false: ".sidebar-elems > .crate"
79
80 goto: "./sub_module/sub_sub_module/index.html"
81 assert-property: (".sidebar", {"clientWidth": "200"})
82 assert-text: (".sidebar > .location", "Module sub_sub_module")
83 // We check that we don't have the crate list.
84 assert-false: ".sidebar-elems .crate"
85 assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions")
86 assert-text: ("#functions + .item-table .item-left > a", "foo")
87
88 // Links to trait implementations in the sidebar should not wrap even if they are long.
89 goto: "file://" + |DOC_PATH| + "/lib2/struct.HasALongTraitWithParams.html"
90 assert-property: (".sidebar", {"clientWidth": "200"})
91 assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29})
92
93 // Test that clicking on of the "In <module>" headings in the sidebar links to the
94 // appropriate anchor in index.html.
95 goto: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
96 assert-property: (".sidebar", {"clientWidth": "200"})
97 click: "//ul[@class='block mod']/preceding-sibling::h3/a"
98 // PAGE: index.html
99 assert-css: ("#modules", {"background-color": "rgb(253, 255, 211)"})
100
101 // Finally, assert that the `[+]/[−]` toggle doesn't affect sidebar width.
102 click: "#toggle-all-docs"
103 assert-text: ("#toggle-all-docs", "[+]")
104 assert-property: (".sidebar", {"clientWidth": "200"})
105 click: "#toggle-all-docs"
106 assert-text: ("#toggle-all-docs", "[−]")
107 assert-property: (".sidebar", {"clientWidth": "200"})