mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
rustdoc: use <wbr>
-tolerant function to check text contents
This commit is contained in:
parent
583bf1e5bf
commit
0d0e18e7f6
@ -4,11 +4,11 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/macro.a.html"
|
||||
wait-for: ".sidebar-elems .macro"
|
||||
// Check there is only one macro named "a" listed in the sidebar.
|
||||
assert-count: (
|
||||
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[text()='a']",
|
||||
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[normalize-space()='a']",
|
||||
1,
|
||||
)
|
||||
// Check there is only one macro named "b" listed in the sidebar.
|
||||
assert-count: (
|
||||
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[text()='b']",
|
||||
"//*[@class='sidebar-elems']//*[@class='block macro']//li/a[normalize-space()='b']",
|
||||
1,
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
// This test checks that the font weight is correctly applied.
|
||||
go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html"
|
||||
assert-css: ("//*[@class='rust item-decl']//a[text()='Alias']", {"font-weight": "400"})
|
||||
assert-css: ("//*[@class='rust item-decl']//a[normalize-space()='Alias']", {"font-weight": "400"})
|
||||
assert-css: (
|
||||
"//*[@class='structfield section-header']//a[text()='Alias']",
|
||||
"//*[@class='structfield section-header']//a[normalize-space()='Alias']",
|
||||
{"font-weight": "400"},
|
||||
)
|
||||
assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"})
|
||||
|
@ -12,11 +12,11 @@ assert-position: (".item-info .stab", {"x": 245})
|
||||
// test for <https://github.com/rust-lang/rust/issues/118615>.
|
||||
set-window-size: (850, 800)
|
||||
store-position: (
|
||||
"//*[@class='stab portability']//code[text()='Win32_System']",
|
||||
"//*[@class='stab portability']//code[normalize-space()='Win32_System']",
|
||||
{"x": first_line_x, "y": first_line_y},
|
||||
)
|
||||
store-position: (
|
||||
"//*[@class='stab portability']//code[text()='Win32_System_Diagnostics']",
|
||||
"//*[@class='stab portability']//code[normalize-space()='Win32_System_Diagnostics']",
|
||||
{"x": second_line_x, "y": second_line_y},
|
||||
)
|
||||
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
|
||||
|
@ -23,7 +23,7 @@ assert-css: (
|
||||
// table like view
|
||||
assert-css: (".desc.docblock-short", { "padding-left": "0px" })
|
||||
compare-elements-position-near: (
|
||||
"//*[@class='item-name']//a[text()='replaced_function']",
|
||||
"//*[@class='item-name']//a[normalize-space()='replaced_function']",
|
||||
".item-name .stab.deprecated",
|
||||
{"y": 2},
|
||||
)
|
||||
@ -35,8 +35,8 @@ compare-elements-position: (
|
||||
|
||||
// Ensure no wrap
|
||||
compare-elements-position: (
|
||||
"//*[@class='item-name']//a[text()='replaced_function']/..",
|
||||
"//*[@class='desc docblock-short'][text()='a thing with a label']",
|
||||
"//*[@class='item-name']//a[normalize-space()='replaced_function']/..",
|
||||
"//*[@class='desc docblock-short'][normalize-space()='a thing with a label']",
|
||||
["y"],
|
||||
)
|
||||
|
||||
@ -45,7 +45,7 @@ set-window-size: (600, 600)
|
||||
// staggered layout with 2em spacing
|
||||
assert-css: (".desc.docblock-short", { "padding-left": "32px" })
|
||||
compare-elements-position-near: (
|
||||
"//*[@class='item-name']//a[text()='replaced_function']",
|
||||
"//*[@class='item-name']//a[normalize-space()='replaced_function']",
|
||||
".item-name .stab.deprecated",
|
||||
{"y": 2},
|
||||
)
|
||||
@ -57,13 +57,13 @@ compare-elements-position: (
|
||||
|
||||
// Ensure wrap
|
||||
compare-elements-position-false: (
|
||||
"//*[@class='item-name']//a[text()='replaced_function']/..",
|
||||
"//*[@class='desc docblock-short'][text()='a thing with a label']",
|
||||
"//*[@class='item-name']//a[normalize-space()='replaced_function']/..",
|
||||
"//*[@class='desc docblock-short'][normalize-space()='a thing with a label']",
|
||||
["y"],
|
||||
)
|
||||
compare-elements-position-false: (
|
||||
".item-name .stab.deprecated",
|
||||
"//*[@class='desc docblock-short'][text()='a thing with a label']",
|
||||
"//*[@class='desc docblock-short'][normalize-space()='a thing with a label']",
|
||||
["y"],
|
||||
)
|
||||
|
||||
@ -73,7 +73,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/cfgs/index.html"
|
||||
// This part of the tags should not be on the same line as the beginning since the width
|
||||
// is too small for that.
|
||||
compare-elements-position-false: (
|
||||
"//*[@class='stab portability']/code[text()='appservice-api-c']",
|
||||
"//*[@class='stab portability']/code[text()='server']",
|
||||
"//*[@class='stab portability']/code[normalize-space()='appservice-api-c']",
|
||||
"//*[@class='stab portability']/code[normalize-space()='server']",
|
||||
["y"],
|
||||
)
|
||||
|
@ -9,19 +9,19 @@ define-function: (
|
||||
block {
|
||||
// Checking they have the same y position.
|
||||
compare-elements-position: (
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
||||
["y"],
|
||||
)
|
||||
// Checking they don't have the same x position.
|
||||
compare-elements-position-false: (
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
||||
["x"],
|
||||
)
|
||||
// The `i` should be *after* the type.
|
||||
assert-position: (
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
|
||||
{"x": |x|},
|
||||
)
|
||||
assert-position: (
|
||||
@ -70,7 +70,7 @@ call-function: ("check-notable-tooltip-position-complete", {
|
||||
// Now only the `i` should be on the next line.
|
||||
set-window-size: (1055, 600)
|
||||
compare-elements-position-false: (
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']",
|
||||
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
||||
["y", "x"],
|
||||
)
|
||||
|
@ -20,11 +20,11 @@ define-function: (
|
||||
ALL,
|
||||
)
|
||||
assert-css: (
|
||||
"//*[@class='desc'][text()='Just a normal struct.']",
|
||||
"//*[@class='desc'][normalize-space()='Just a normal struct.']",
|
||||
{"color": |desc_color|},
|
||||
)
|
||||
assert-css: (
|
||||
"//*[@class='result-name']//*[text()='test_docs::']",
|
||||
"//*[@class='result-name']//*[normalize-space()='test_docs::']",
|
||||
{"color": |path_color|},
|
||||
)
|
||||
|
||||
@ -85,19 +85,19 @@ define-function: (
|
||||
move-cursor-to: ".search-input"
|
||||
focus: ".search-input" // To ensure the `<a>` container isn't focused or hovered.
|
||||
assert-css: (
|
||||
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
|
||||
"//*[@class='result-name']//*[normalize-space()='test_docs::']/ancestor::a",
|
||||
{"color": |path_color|, "background-color": "transparent"},
|
||||
ALL,
|
||||
)
|
||||
|
||||
// Checking color and background on hover.
|
||||
move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
|
||||
move-cursor-to: "//*[@class='desc'][normalize-space()='Just a normal struct.']"
|
||||
assert-css: (
|
||||
"//*[@class='result-name']//*[text()='test_docs::']",
|
||||
"//*[@class='result-name']//*[normalize-space()='test_docs::']",
|
||||
{"color": |hover_path_color|},
|
||||
)
|
||||
assert-css: (
|
||||
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
|
||||
"//*[@class='result-name']//*[normalize-space()='test_docs::']/ancestor::a",
|
||||
{"color": |hover_path_color|, "background-color": |hover_background|},
|
||||
)
|
||||
}
|
||||
|
@ -2,4 +2,4 @@
|
||||
// displayed twice in the sidebar.
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/macro.repro.html"
|
||||
wait-for: ".sidebar-elems .block.macro a"
|
||||
assert-count: ("//*[@class='sidebar-elems']//*[@class='block macro']//a[text()='repro']", 1)
|
||||
assert-count: ("//*[@class='sidebar-elems']//*[@class='block macro']//a[normalize-space()='repro']", 1)
|
||||
|
@ -25,9 +25,12 @@ click: ".sidebar-menu-toggle"
|
||||
assert-css: (".sidebar", {"left": "0px"})
|
||||
|
||||
// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
|
||||
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
|
||||
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[normalize-space()='Foo']/parent::h2", {"display": "none"})
|
||||
// Make sure the global navigation is still here.
|
||||
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In crate test_docs']/parent::h2", {"display": "block"})
|
||||
assert-css: (
|
||||
"//nav[contains(@class, 'sidebar')]//h2/a[normalize-space()='In crate test_docs']/parent::h2",
|
||||
{"display": "block"}
|
||||
)
|
||||
|
||||
// Click elsewhere.
|
||||
click: "body"
|
||||
|
@ -66,12 +66,12 @@ click: "#sidebar-button"
|
||||
// We wait for the sidebar to be expanded.
|
||||
wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
|
||||
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
|
||||
assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
|
||||
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
|
||||
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='another_folder']"
|
||||
assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='sub_mod']"
|
||||
// Only "another_folder" should be "open" in "lib2".
|
||||
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
|
||||
assert: "//*[@class='dir-entry' and not(@open)]/*[normalize-space()='another_mod']"
|
||||
// All other trees should be collapsed.
|
||||
assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 11)
|
||||
assert-count: ("//*[@id='src-sidebar']/details[not(normalize-space()='lib2') and not(@open)]", 11)
|
||||
|
||||
// We now switch to mobile mode.
|
||||
set-window-size: (600, 600)
|
||||
|
@ -11,7 +11,7 @@ click: '//a[text() = "barbar" and @href="#5-7"]'
|
||||
assert-property: ("html", {"scrollTop": "123"})
|
||||
click: '//a[text() = "bar" and @href="#28-36"]'
|
||||
assert-property: ("html", {"scrollTop": "154"})
|
||||
click: '//a[text() = "sub_fn" and @href="#2-4"]'
|
||||
click: '//a[normalize-space() = "sub_fn" and @href="#2-4"]'
|
||||
assert-property: ("html", {"scrollTop": "51"})
|
||||
|
||||
// We now check that clicking on lines doesn't change the scroll
|
||||
|
Loading…
Reference in New Issue
Block a user