Skip to content

Commit 0d928b6

Browse files
Update rustdoc tests to adapt to changes to the sidebar
1 parent 5136b54 commit 0d928b6

17 files changed

+59
-59
lines changed

src/test/rustdoc-gui/hash-item-expansion.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ assert-attribute: ("#blanket-implementations-list > details:nth-child(2)", {"ope
55
// We first check that the impl block is open by default.
66
assert-attribute: ("#implementations + details", {"open": ""})
77
// To ensure that we will click on the currently hidden method.
8-
assert-text: (".sidebar-links > a", "must_use")
9-
click: ".sidebar-links > a"
8+
assert-text: (".sidebar-elems section .block li > a", "must_use")
9+
click: ".sidebar-elems section .block li > a"
1010
// We check that the impl block was opened as expected so that we can see the method.
1111
assert-attribute: ("#implementations + details", {"open": ""})

src/test/rustdoc-gui/sidebar-mobile.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"})
3333
// Check that clicking an element from the sidebar scrolls to the right place
3434
// so the target is not obscured by the topbar.
3535
click: ".sidebar-menu-toggle"
36-
click: ".sidebar-links a"
36+
click: ".sidebar-elems section .block li > a"
3737
assert-position: ("#method\.must_use", {"y": 45})
3838

3939
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.

src/test/rustdoc-gui/sidebar.goml

+17-17
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
1313
// We check that we have the crates list and that the "current" on is "test_docs".
1414
assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs")
1515
// And we're also supposed to have the list of items in the current module.
16-
assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Modules")
17-
assert-text: (".sidebar-elems .items > ul > li:nth-child(2)", "Macros")
18-
assert-text: (".sidebar-elems .items > ul > li:nth-child(3)", "Structs")
19-
assert-text: (".sidebar-elems .items > ul > li:nth-child(4)", "Enums")
20-
assert-text: (".sidebar-elems .items > ul > li:nth-child(5)", "Traits")
21-
assert-text: (".sidebar-elems .items > ul > li:nth-child(6)", "Functions")
22-
assert-text: (".sidebar-elems .items > ul > li:nth-child(7)", "Type Definitions")
23-
assert-text: (".sidebar-elems .items > ul > li:nth-child(8)", "Unions")
24-
assert-text: (".sidebar-elems .items > ul > li:nth-child(9)", "Keywords")
16+
assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Modules")
17+
assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Macros")
18+
assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Structs")
19+
assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Enums")
20+
assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Traits")
21+
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Functions")
22+
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Type Definitions")
23+
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Unions")
24+
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Keywords")
2525
assert-text: ("#structs + .item-table .item-left > a", "Foo")
2626
click: "#structs + .item-table .item-left > a"
2727

@@ -30,7 +30,7 @@ assert-count: (".sidebar .location", 2)
3030
// We check that there is no crate listed outside of the top level.
3131
assert-false: ".sidebar-elems > .crate"
3232

33-
click: ".sidebar-links a"
33+
click: ".sidebar-elems section .block li > a"
3434
assert-property-false: ("html", {"scrollTop": "0"})
3535

3636
click: ".sidebar h2.location a"
@@ -47,11 +47,11 @@ assert-text: (".sidebar > .location", "Crate lib2")
4747
// We check that we have the crates list and that the "current" on is now "lib2".
4848
assert-text: (".sidebar-elems .crate > ul > li > a.current", "lib2")
4949
// We now go to the "foobar" function page.
50-
assert-text: (".sidebar-elems > .items > ul > li:nth-child(1)", "Modules")
51-
assert-text: (".sidebar-elems > .items > ul > li:nth-child(2)", "Structs")
52-
assert-text: (".sidebar-elems > .items > ul > li:nth-child(3)", "Traits")
53-
assert-text: (".sidebar-elems > .items > ul > li:nth-child(4)", "Functions")
54-
assert-text: (".sidebar-elems > .items > ul > li:nth-child(5)", "Type Definitions")
50+
assert-text: (".sidebar-elems > section .block ul > li:nth-child(1)", "Modules")
51+
assert-text: (".sidebar-elems > section .block ul > li:nth-child(2)", "Structs")
52+
assert-text: (".sidebar-elems > section .block ul > li:nth-child(3)", "Traits")
53+
assert-text: (".sidebar-elems > section .block ul > li:nth-child(4)", "Functions")
54+
assert-text: (".sidebar-elems > section .block ul > li:nth-child(5)", "Type Definitions")
5555
assert-text: ("#functions + .item-table .item-left > a", "foobar")
5656
click: "#functions + .item-table .item-left > a"
5757

@@ -72,12 +72,12 @@ goto: ./sub_module/sub_sub_module/index.html
7272
assert-text: (".sidebar > .location", "Module sub_sub_module")
7373
// We check that we don't have the crate list.
7474
assert-false: ".sidebar-elems .crate"
75-
assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Functions")
75+
assert-text: (".sidebar-elems > section ul > li:nth-child(1)", "Functions")
7676
assert-text: ("#functions + .item-table .item-left > a", "foo")
7777

7878
// Links to trait implementations in the sidebar should not wrap even if they are long.
7979
goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html
80-
assert-property: (".sidebar-links a", {"offsetHeight": 29})
80+
assert-property: (".sidebar-elems section .block li > a", {"offsetHeight": 29})
8181

8282
// Test that clicking on of the "In <module>" headings in the sidebar links to the
8383
// appropriate anchor in index.html.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Checks that the elements in the sidebar are alphabetically sorted.
22
goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
3-
assert-text: (".sidebar-links a:nth-of-type(1)", "another")
4-
assert-text: (".sidebar-links a:nth-of-type(2)", "func1")
5-
assert-text: (".sidebar-links a:nth-of-type(3)", "func2")
6-
assert-text: (".sidebar-links a:nth-of-type(4)", "func3")
7-
assert-text: (".sidebar-links a:nth-of-type(5)", "hello")
8-
assert-text: (".sidebar-links a:nth-of-type(6)", "why_not")
3+
assert-text: (".sidebar-elems section .block li:nth-of-type(1) > a", "another")
4+
assert-text: (".sidebar-elems section .block li:nth-of-type(2) > a", "func1")
5+
assert-text: (".sidebar-elems section .block li:nth-of-type(3) > a", "func2")
6+
assert-text: (".sidebar-elems section .block li:nth-of-type(4) > a", "func3")
7+
assert-text: (".sidebar-elems section .block li:nth-of-type(5) > a", "hello")
8+
assert-text: (".sidebar-elems section .block li:nth-of-type(6) > a", "why_not")

src/test/rustdoc/associated-consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct Bar;
1010

1111
// @has 'foo/struct.Bar.html'
1212
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
13-
// @has - '//div[@class="sidebar-elems"]//div[@class="sidebar-links"]/a' 'FOO'
13+
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
1414
impl Trait for Bar {
1515
const FOO: u32 = 1;
1616

@@ -23,7 +23,7 @@ pub enum Foo {
2323

2424
// @has 'foo/enum.Foo.html'
2525
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
26-
// @has - '//div[@class="sidebar-elems"]//div[@class="sidebar-links"]/a' 'FOO'
26+
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
2727
impl Trait for Foo {
2828
const FOO: u32 = 1;
2929

src/test/rustdoc/deref-mut-methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl Foo {
99
}
1010

1111
// @has foo/struct.Bar.html
12-
// @has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo'
12+
// @has - '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.foo"]' 'foo'
1313
pub struct Bar {
1414
foo: Foo,
1515
}

src/test/rustdoc/deref-recursive-pathbuf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref<Target = Path>'
99
// @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)'
1010
// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>'
11-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.as_path"]' 'as_path'
11+
// @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.as_path"]' 'as_path'
1212
// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>'
13-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.exists"]' 'exists'
13+
// @has '-' '//*[@class="sidebar-elems"]//*[@class="block"]//a[@href="#method.exists"]' 'exists'
1414

1515
#![crate_name = "foo"]
1616

src/test/rustdoc/deref-recursive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>'
99
// @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)'
1010
// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>'
11-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.bar"]' 'bar'
11+
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.bar"]' 'bar'
1212
// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>'
13-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.baz"]' 'baz'
13+
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.baz"]' 'baz'
1414

1515
#![crate_name = "foo"]
1616

src/test/rustdoc/deref-typedef.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)'
88
// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)'
99
// @has '-' '//*[@class="sidebar-title"]/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>'
10-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_a"]' 'foo_a'
11-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_b"]' 'foo_b'
12-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_c"]' 'foo_c'
13-
// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_j"]' 'foo_j'
10+
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a'
11+
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b'
12+
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c'
13+
// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_j"]' 'foo_j'
1414

1515
pub struct FooA;
1616
pub type FooB = FooA;

src/test/rustdoc/double-quote-escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ pub trait Foo<T> {
88
pub struct Bar;
99

1010
// @has foo/struct.Bar.html
11-
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo<unsafe extern "C" fn()>'
11+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo<unsafe extern "C" fn()>'
1212
impl Foo<unsafe extern "C" fn()> for Bar {}

src/test/rustdoc/generic-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Bar;
77

88
// @has foo/struct.Foo.html '//*[@id="impl-ToString"]//h3[@class="code-header in-band"]' 'impl<T> ToString for T'
99
pub struct Foo;
10-
// @has foo/struct.Foo.html '//div[@class="sidebar-links"]/a[@href="#impl-ToString"]' 'ToString'
10+
// @has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString"]' 'ToString'
1111

1212
impl fmt::Display for Foo {
1313
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

src/test/rustdoc/method-list.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![crate_name = "foo"]
22

33
// @has foo/struct.Foo.html
4-
// @has - '//*[@class="sidebar-links"]/a' 'super_long_name'
5-
// @has - '//*[@class="sidebar-links"]/a' 'Disp'
4+
// @has - '//*[@class="sidebar-elems"]//section//a' 'super_long_name'
5+
// @has - '//*[@class="sidebar-elems"]//section//a' 'Disp'
66
pub struct Foo(usize);
77

88
impl Foo {

src/test/rustdoc/negative-impl-sidebar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub struct Foo;
55

66
// @has foo/struct.Foo.html
77
// @has - '//*[@class="sidebar-title"]/a[@href="#trait-implementations"]' 'Trait Implementations'
8-
// @has - '//*[@class="sidebar-links"]/a' '!Sync'
8+
// @has - '//*[@class="sidebar-elems"]//section//a' '!Sync'
99
impl !Sync for Foo {}

src/test/rustdoc/recursive-deref-sidebar.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ impl B { pub fn foo_b(&self) {} }
99
pub struct C {}
1010
impl C { pub fn foo_c(&self) {} }
1111

12-
// @has recursive_deref_sidebar/struct.A.html '//div[@class="sidebar-links"]' 'foo_b'
12+
// @has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_b'
1313
impl Deref for A {
1414
type Target = B;
1515
fn deref(&self) -> &B { todo!() }
1616
}
1717

18-
// @has recursive_deref_sidebar/struct.A.html '//div[@class="sidebar-links"]' 'foo_c'
18+
// @has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_c'
1919
impl Deref for B {
2020
type Target = C;
2121
fn deref(&self) -> &C { todo!() }

src/test/rustdoc/sidebar-items.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
// @has foo/trait.Foo.html
44
// @has - '//*[@class="sidebar-title"]/a[@href="#required-methods"]' 'Required Methods'
5-
// @has - '//*[@class="sidebar-links"]/a' 'bar'
5+
// @has - '//*[@class="sidebar-elems"]//section//a' 'bar'
66
// @has - '//*[@class="sidebar-title"]/a[@href="#provided-methods"]' 'Provided Methods'
7-
// @has - '//*[@class="sidebar-links"]/a' 'foo'
7+
// @has - '//*[@class="sidebar-elems"]//section//a' 'foo'
88
// @has - '//*[@class="sidebar-title"]/a[@href="#associated-const"]' 'Associated Constants'
9-
// @has - '//*[@class="sidebar-links"]/a' 'BAR'
9+
// @has - '//*[@class="sidebar-elems"]//section//a' 'BAR'
1010
// @has - '//*[@class="sidebar-title"]/a[@href="#associated-types"]' 'Associated Types'
11-
// @has - '//*[@class="sidebar-links"]/a' 'Output'
11+
// @has - '//*[@class="sidebar-elems"]//section//a' 'Output'
1212
pub trait Foo {
1313
const BAR: u32 = 0;
1414
type Output: ?Sized;
@@ -19,9 +19,9 @@ pub trait Foo {
1919

2020
// @has foo/struct.Bar.html
2121
// @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields'
22-
// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f"]' 'f'
23-
// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.u"]' 'u'
24-
// @!has - '//*[@class="sidebar-links"]/a' 'waza'
22+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f'
23+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.u"]' 'u'
24+
// @!has - '//*[@class="sidebar-elems"]//section//a' 'waza'
2525
pub struct Bar {
2626
pub f: u32,
2727
pub u: u32,
@@ -30,18 +30,18 @@ pub struct Bar {
3030

3131
// @has foo/enum.En.html
3232
// @has - '//*[@class="sidebar-title"]/a[@href="#variants"]' 'Variants'
33-
// @has - '//*[@class="sidebar-links"]/a' 'Foo'
34-
// @has - '//*[@class="sidebar-links"]/a' 'Bar'
33+
// @has - '//*[@class="sidebar-elems"]//section//a' 'Foo'
34+
// @has - '//*[@class="sidebar-elems"]//section//a' 'Bar'
3535
pub enum En {
3636
Foo,
3737
Bar,
3838
}
3939

4040
// @has foo/union.MyUnion.html
4141
// @has - '//*[@class="sidebar-title"]/a[@href="#fields"]' 'Fields'
42-
// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f1"]' 'f1'
43-
// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f2"]' 'f2'
44-
// @!has - '//*[@class="sidebar-links"]/a' 'waza'
42+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f1"]' 'f1'
43+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f2"]' 'f2'
44+
// @!has - '//*[@class="sidebar-elems"]//section//a' 'waza'
4545
pub union MyUnion {
4646
pub f1: u32,
4747
pub f2: f32,

src/test/rustdoc/sidebar-link-generation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![crate_name = "foo"]
22

3-
// @has foo/struct.SomeStruct.html '//*[@class="sidebar-links"]/a[@href="#method.some_fn-1"]' \
3+
// @has foo/struct.SomeStruct.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.some_fn-1"]' \
44
// "some_fn"
55
pub struct SomeStruct<T> { _inner: T }
66

src/test/rustdoc/sidebar-links-to-foreign-impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// @has foo/trait.Foo.html
66
// @has - '//*[@class="sidebar-title"]/a[@href="#foreign-impls"]' 'Implementations on Foreign Types'
77
// @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types'
8-
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo-for-u32"]' 'u32'
8+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32'
99
// @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header in-band"]' 'impl Foo for u32'
10-
// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo-for-%26%27a%20str"]' "&'a str"
10+
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-%26%27a%20str"]' "&'a str"
1111
// @has - '//*[@id="impl-Foo-for-%26%27a%20str"]//h3[@class="code-header in-band"]' "impl<'a> Foo for &'a str"
1212
pub trait Foo {}
1313

0 commit comments

Comments
 (0)