116 lines
3.8 KiB
Plaintext
116 lines
3.8 KiB
Plaintext
// Check that the line number column has the correct layout.
|
|
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
|
|
|
set-window-size: (1000, 1000)
|
|
|
|
// Check that it's not zero.
|
|
assert-property-false: (
|
|
".more-scraped-examples .scraped-example .src-line-numbers",
|
|
{"clientWidth": "0"}
|
|
)
|
|
|
|
// Check that examples with very long lines have the same width as ones that don't.
|
|
store-property: (
|
|
".more-scraped-examples .scraped-example:nth-child(2) .src-line-numbers",
|
|
{"clientWidth": clientWidth},
|
|
)
|
|
|
|
assert-property: (
|
|
".more-scraped-examples .scraped-example:nth-child(3) .src-line-numbers",
|
|
{"clientWidth": |clientWidth|}
|
|
)
|
|
|
|
assert-property: (
|
|
".more-scraped-examples .scraped-example:nth-child(4) .src-line-numbers",
|
|
{"clientWidth": |clientWidth|}
|
|
)
|
|
|
|
assert-property: (
|
|
".more-scraped-examples .scraped-example:nth-child(5) .src-line-numbers",
|
|
{"clientWidth": |clientWidth|}
|
|
)
|
|
|
|
assert-property: (
|
|
".more-scraped-examples .scraped-example:nth-child(6) .src-line-numbers",
|
|
{"clientWidth": |clientWidth|}
|
|
)
|
|
|
|
// The "title" should be located at the right bottom corner of the code example.
|
|
store-position: (".scraped-example .example-wrap", {"x": x, "y": y})
|
|
store-size: (".scraped-example .example-wrap", {"width": width, "height": height})
|
|
store-size: (".scraped-example .scraped-example-title", {
|
|
"width": title_width,
|
|
"height": title_height,
|
|
})
|
|
assert-position: (".scraped-example .scraped-example-title", {
|
|
"x": |x| + |width| - |title_width| - 5,
|
|
"y": |y| + |height| - |title_height| - 8,
|
|
})
|
|
|
|
// Check that the expand button works and also that line number aligns with code.
|
|
move-cursor-to: ".scraped-example .rust"
|
|
click: ".scraped-example .button-holder .expand"
|
|
wait-for: ".scraped-example.expanded"
|
|
// They should have the same y position.
|
|
compare-elements-position: (
|
|
".scraped-example.expanded .src-line-numbers pre span",
|
|
".scraped-example.expanded .rust code",
|
|
["y"],
|
|
)
|
|
// And they should have the same height.
|
|
compare-elements-size: (
|
|
".scraped-example.expanded .src-line-numbers",
|
|
".scraped-example.expanded .rust",
|
|
["height"],
|
|
)
|
|
// Collapse code again.
|
|
click: ".scraped-example .button-holder .expand"
|
|
|
|
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
|
|
// correctly.
|
|
|
|
store-value: (offset_y, 4)
|
|
|
|
// First with desktop
|
|
assert-position: (".scraped-example", {"y": 226})
|
|
assert-position: (".scraped-example .prev", {"y": 226 + |offset_y|})
|
|
|
|
// Gradient background should be at the top of the code block.
|
|
assert-css: (".scraped-example .example-wrap::before", {"top": "0px"})
|
|
assert-css: (".scraped-example .example-wrap::after", {"bottom": "0px"})
|
|
|
|
// Then with mobile
|
|
set-window-size: (600, 600)
|
|
store-size: (".scraped-example .scraped-example-title", {"height": title_height})
|
|
assert-position: (".scraped-example", {"y": 284})
|
|
assert-position: (".scraped-example .prev", {"y": 284 + |offset_y| + |title_height|})
|
|
|
|
define-function: (
|
|
"check_title_and_code_position",
|
|
[],
|
|
block {
|
|
// Title should be above the code.
|
|
store-position: (".scraped-example .example-wrap .src-line-numbers", {"x": x, "y": y})
|
|
store-size: (".scraped-example .scraped-example-title", { "height": title_height })
|
|
|
|
assert-position: (".scraped-example .scraped-example-title", {
|
|
"x": |x|, // same X position.
|
|
"y": |y| - |title_height|,
|
|
})
|
|
|
|
// Line numbers should be right beside the code.
|
|
compare-elements-position: (
|
|
".scraped-example .example-wrap .src-line-numbers",
|
|
".scraped-example .example-wrap .rust",
|
|
["y"],
|
|
)
|
|
}
|
|
)
|
|
|
|
// Check that the title is now above the code.
|
|
call-function: ("check_title_and_code_position", {})
|
|
|
|
// Then with small mobile
|
|
set-window-size: (300, 300)
|
|
call-function: ("check_title_and_code_position", {})
|