Skip to content

Commit df3187f

Browse files
committed
rustdoc: use <wbr>-tolerant function to check text contents
1 parent 5b043ee commit df3187f

12 files changed

+42
-39
lines changed

tests/rustdoc-gui/duplicate-macro-reexport.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/macro.a.html"
44
wait-for: ".sidebar-elems .macro"
55
// Check there is only one macro named "a" listed in the sidebar.
66
assert-count: (
7-
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[text()='a']",
7+
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[normalize-space()='a']",
88
1,
99
)
1010
// Check there is only one macro named "b" listed in the sidebar.
1111
assert-count: (
12-
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[text()='b']",
12+
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[normalize-space()='b']",
1313
1,
1414
)

tests/rustdoc-gui/font-weight.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This test checks that the font weight is correctly applied.
22
go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html"
3-
assert-css: ("//*[@class='rust item-decl']//a[text()='Alias']", {"font-weight": "400"})
3+
assert-css: ("//*[@class='rust item-decl']//a[normalize-space()='Alias']", {"font-weight": "400"})
44
assert-css: (
5-
"//*[@class='structfield section-header']//a[text()='Alias']",
5+
"//*[@class='structfield section-header']//a[normalize-space()='Alias']",
66
{"font-weight": "400"},
77
)
88
assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"})

tests/rustdoc-gui/help-page.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
6666
set-window-size: (1000, 1000) // Popover only appears when the screen width is >700px.
6767
assert-false: "#help"
6868
click: "#help-button > a"
69-
click: "//*[@id='help']//a[text()='the rustdoc book']"
69+
click: "//*[@id='help']//a[normalize-space()='the rustdoc book']"
7070
wait-for-document-property: ({"URL": "https://doc.rust-lang.org/"}, STARTS_WITH)

tests/rustdoc-gui/item-info.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ assert-position: (".item-info .stab", {"x": 245})
1212
// test for <https://github.com/rust-lang/rust/issues/118615>.
1313
set-window-size: (850, 800)
1414
store-position: (
15-
"//*[@class='stab portability']//code[text()='Win32_System']",
15+
"//*[@class='stab portability']//code[normalize-space()='Win32_System']",
1616
{"x": first_line_x, "y": first_line_y},
1717
)
1818
store-position: (
19-
"//*[@class='stab portability']//code[text()='Win32_System_Diagnostics']",
19+
"//*[@class='stab portability']//code[normalize-space()='Win32_System_Diagnostics']",
2020
{"x": second_line_x, "y": second_line_y},
2121
)
2222
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272

tests/rustdoc-gui/label-next-to-symbol.goml

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ assert-css: (
2323
// table like view
2424
assert-css: (".desc.docblock-short", { "padding-left": "0px" })
2525
compare-elements-position-near: (
26-
"//*[@class='item-name']//a[text()='replaced_function']",
26+
"//*[@class='item-name']//a[normalize-space()='replaced_function']",
2727
".item-name .stab.deprecated",
2828
{"y": 2},
2929
)
@@ -35,8 +35,8 @@ compare-elements-position: (
3535

3636
// Ensure no wrap
3737
compare-elements-position: (
38-
"//*[@class='item-name']//a[text()='replaced_function']/..",
39-
"//*[@class='desc docblock-short'][text()='a thing with a label']",
38+
"//*[@class='item-name']//a[normalize-space()='replaced_function']/..",
39+
"//*[@class='desc docblock-short'][normalize-space()='a thing with a label']",
4040
["y"],
4141
)
4242

@@ -45,7 +45,7 @@ set-window-size: (600, 600)
4545
// staggered layout with 2em spacing
4646
assert-css: (".desc.docblock-short", { "padding-left": "32px" })
4747
compare-elements-position-near: (
48-
"//*[@class='item-name']//a[text()='replaced_function']",
48+
"//*[@class='item-name']//a[normalize-space()='replaced_function']",
4949
".item-name .stab.deprecated",
5050
{"y": 2},
5151
)
@@ -57,13 +57,13 @@ compare-elements-position: (
5757

5858
// Ensure wrap
5959
compare-elements-position-false: (
60-
"//*[@class='item-name']//a[text()='replaced_function']/..",
61-
"//*[@class='desc docblock-short'][text()='a thing with a label']",
60+
"//*[@class='item-name']//a[normalize-space()='replaced_function']/..",
61+
"//*[@class='desc docblock-short'][normalize-space()='a thing with a label']",
6262
["y"],
6363
)
6464
compare-elements-position-false: (
6565
".item-name .stab.deprecated",
66-
"//*[@class='desc docblock-short'][text()='a thing with a label']",
66+
"//*[@class='desc docblock-short'][normalize-space()='a thing with a label']",
6767
["y"],
6868
)
6969

@@ -73,7 +73,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/cfgs/index.html"
7373
// This part of the tags should not be on the same line as the beginning since the width
7474
// is too small for that.
7575
compare-elements-position-false: (
76-
"//*[@class='stab portability']/code[text()='appservice-api-c']",
77-
"//*[@class='stab portability']/code[text()='server']",
76+
"//*[@class='stab portability']/code[normalize-space()='appservice-api-c']",
77+
"//*[@class='stab portability']/code[normalize-space()='server']",
7878
["y"],
7979
)

tests/rustdoc-gui/notable-trait.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ define-function: (
99
block {
1010
// Checking they have the same y position.
1111
compare-elements-position: (
12-
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
12+
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
1313
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
1414
["y"],
1515
)
1616
// Checking they don't have the same x position.
1717
compare-elements-position-false: (
18-
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
18+
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
1919
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
2020
["x"],
2121
)
2222
// The `i` should be *after* the type.
2323
assert-position: (
24-
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
24+
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
2525
{"x": |x|},
2626
)
2727
assert-position: (
@@ -70,7 +70,7 @@ call-function: ("check-notable-tooltip-position-complete", {
7070
// Now only the `i` should be on the next line.
7171
set-window-size: (1055, 600)
7272
compare-elements-position-false: (
73-
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
73+
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
7474
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
7575
["y", "x"],
7676
)

tests/rustdoc-gui/search-result-color.goml

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ define-function: (
2020
ALL,
2121
)
2222
assert-css: (
23-
"//*[@class='desc'][text()='Just a normal struct.']",
23+
"//*[@class='desc'][normalize-space()='Just a normal struct.']",
2424
{"color": |desc_color|},
2525
)
2626
assert-css: (
27-
"//*[@class='result-name']//*[text()='test_docs::']",
27+
"//*[@class='result-name']//*[normalize-space()='test_docs::']",
2828
{"color": |path_color|},
2929
)
3030

@@ -85,19 +85,19 @@ define-function: (
8585
move-cursor-to: ".search-input"
8686
focus: ".search-input" // To ensure the `<a>` container isn't focused or hovered.
8787
assert-css: (
88-
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
88+
"//*[@class='result-name']//*[normalize-space()='test_docs::']/ancestor::a",
8989
{"color": |path_color|, "background-color": "transparent"},
9090
ALL,
9191
)
9292

9393
// Checking color and background on hover.
94-
move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
94+
move-cursor-to: "//*[@class='desc'][normalize-space()='Just a normal struct.']"
9595
assert-css: (
96-
"//*[@class='result-name']//*[text()='test_docs::']",
96+
"//*[@class='result-name']//*[normalize-space()='test_docs::']",
9797
{"color": |hover_path_color|},
9898
)
9999
assert-css: (
100-
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
100+
"//*[@class='result-name']//*[normalize-space()='test_docs::']/ancestor::a",
101101
{"color": |hover_path_color|, "background-color": |hover_background|},
102102
)
103103
}

tests/rustdoc-gui/sidebar-macro-reexport.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// displayed twice in the sidebar.
33
go-to: "file://" + |DOC_PATH| + "/test_docs/macro.repro.html"
44
wait-for: ".sidebar-elems .block.macro a"
5-
assert-count: ("//*[@class='sidebar-elems']//*[@class='block macro']//a[text()='repro']", 1)
5+
assert-count: ("//*[@class='sidebar-elems']//*[@class='block macro']//a[normalize-space()='repro']", 1)

tests/rustdoc-gui/sidebar-mobile.goml

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ click: ".sidebar-menu-toggle"
2525
assert-css: (".sidebar", {"left": "0px"})
2626

2727
// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
28-
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
28+
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[normalize-space()='Foo']/parent::h2", {"display": "none"})
2929
// Make sure the global navigation is still here.
30-
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In crate test_docs']/parent::h2", {"display": "block"})
30+
assert-css: (
31+
"//nav[contains(@class, 'sidebar')]//h2/a[normalize-space()='In crate test_docs']/parent::h2",
32+
{"display": "block"}
33+
)
3134

3235
// Click elsewhere.
3336
click: "body"

tests/rustdoc-gui/sidebar-source-code.goml

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ go-to: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html"
6565
click: "#sidebar-button"
6666
// We wait for the sidebar to be expanded.
6767
wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
68-
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
69-
assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
70-
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
68+
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='lib2']"
69+
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='another_folder']"
70+
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='sub_mod']"
7171
// Only "another_folder" should be "open" in "lib2".
72-
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
72+
assert: "//*[@class='dir-entry' and not(@open)]/*[normalize-space()='another_mod']"
7373
// All other trees should be collapsed.
74-
assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 11)
74+
assert-count: ("//*[@id='src-sidebar']/details[not(normalize-space()='lib2') and not(@open)]", 11)
7575

7676
// We now switch to mobile mode.
7777
set-window-size: (600, 600)

tests/rustdoc-gui/source-anchor-scroll.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ set-window-size: (600, 800)
77
// We check that the scroll is at the top first.
88
assert-property: ("html", {"scrollTop": "0"})
99

10-
click: '//a[text() = "barbar" and @href="#5-7"]'
10+
click: '//a[normalize-space() = "barbar" and @href="#5-7"]'
1111
assert-property: ("html", {"scrollTop": "123"})
12-
click: '//a[text() = "bar" and @href="#28-36"]'
12+
click: '//a[normalize-space() = "bar" and @href="#28-36"]'
1313
assert-property: ("html", {"scrollTop": "154"})
14-
click: '//a[text() = "sub_fn" and @href="#2-4"]'
14+
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
1515
assert-property: ("html", {"scrollTop": "51"})
1616

1717
// We now check that clicking on lines doesn't change the scroll

tests/rustdoc-gui/type-declation-overflow.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ go-to: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html"
6666

6767
click: ".item-decl .type-contents-toggle"
6868
assert-property: ("pre.item-decl", {"scrollLeft": 0})
69-
scroll-to: "//*[@class='rust item-decl']//details/a[text()='String']"
69+
scroll-to: "//*[@class='rust item-decl']//details/a[normalize-space()='String']"
7070
assert-property-false: ("pre.item-decl", {"scrollLeft": 0})
7171

7272
// Then on an item without "hidden methods".
7373
go-to: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.TraitWithLongItemsName.html"
7474
assert-property: ("pre.item-decl", {"scrollLeft": 0})
75-
scroll-to: "//*[@class='rust item-decl']//code/a[text()='String']"
75+
scroll-to: "//*[@class='rust item-decl']//code/a[normalize-space()='String']"
7676
assert-property-false: ("pre.item-decl", {"scrollLeft": 0})

0 commit comments

Comments
 (0)