Skip to content

Commit bc888ba

Browse files
Add sidebar GUI tests
1 parent dab01a0 commit bc888ba

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/test/rustdoc-gui/sidebar.goml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
goto: file://|DOC_PATH|/test_docs/index.html
2+
assert: (".sidebar > .location", "Crate test_docs")
3+
// In modules, we only have one "location" element.
4+
assert: (".sidebar .location", 1)
5+
assert: (".sidebar-elems > #all-types", "See all test_docs's items")
6+
// We check that we have the crates list and that the "current" on is "test_docs".
7+
assert: (".sidebar-elems > .crate > ul > li > a.current", "test_docs")
8+
// And we're also supposed to have the list of items in the current module.
9+
assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Modules")
10+
assert: (".sidebar-elems > .items > ul > li:nth-child(2)", "Structs")
11+
assert: (".sidebar-elems > .items > ul > li:nth-child(3)", "Enums")
12+
assert: (".sidebar-elems > .items > ul > li:nth-child(4)", "Traits")
13+
assert: (".sidebar-elems > .items > ul > li:nth-child(5)", "Functions")
14+
assert: (".sidebar-elems > .items > ul > li:nth-child(6)", "Keywords")
15+
assert: ("#structs + table td > a", "Foo")
16+
click: "#structs + table td > a"
17+
18+
// PAGE: struct.Foo.html
19+
assert: (".sidebar .location", 2)
20+
// We check that we have the crates list and that the "current" on is still "test_docs".
21+
assert: (".sidebar-elems > .crate > ul > li > a.current", "test_docs")
22+
// We now move to the other crate to check if its submodules have the correct sidebar elements too.
23+
click: ".sidebar-elems > .crate > ul > li:first-child > a"
24+
25+
// PAGE: lib2/index.html
26+
assert: (".sidebar > .location", "Crate lib2")
27+
// We check that we have the crates list and that the "current" on is now "lib2".
28+
assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
29+
// We now go to the "foobar" function page.
30+
assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Modules")
31+
assert: (".sidebar-elems > .items > ul > li:nth-child(2)", "Functions")
32+
assert: ("#functions + table td > a", "foobar")
33+
click: "#functions + table td > a"
34+
35+
// PAGE: fn.foobar.html
36+
// In items containing no items (like functions or constants) and in modules, we have one
37+
// "location" elements.
38+
assert: (".sidebar .location", 1)
39+
// We check that we still have the crates list and that the "current" on is still "lib2".
40+
assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
41+
goto: ./module/sub_module/sub_sub_module/index.html
42+
43+
assert: (".sidebar > .location", "Module sub_sub_module")
44+
assert: (".sidebar-elems > .crate > ul > li:nth-child(2) > a", "test_docs")
45+
assert: (".sidebar-elems > .crate > ul > li:nth-child(2) > a", "href", "../../../../test_docs/index.html")
46+
assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Functions")
47+
assert: ("#functions + table td > a", "foo")

src/test/rustdoc-gui/src/lib2.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub mod module {
2+
pub mod sub_module {
3+
pub mod sub_sub_module {
4+
pub fn foo() {}
5+
}
6+
pub fn bar() {}
7+
}
8+
pub fn whatever() {}
9+
}
10+
11+
pub fn foobar() {}

0 commit comments

Comments
 (0)