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