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