2022-12-20 11:32:35 -06:00
|
|
|
// Check that the line number column has the correct layout.
|
2023-04-11 12:11:34 -05:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
2022-12-20 11:32:35 -06:00
|
|
|
|
2024-09-01 08:00:51 -05:00
|
|
|
set-window-size: (1000, 1000)
|
|
|
|
|
2022-12-20 11:32:35 -06:00
|
|
|
// Check that it's not zero.
|
|
|
|
assert-property-false: (
|
2024-08-30 17:12:10 -05:00
|
|
|
".more-scraped-examples .scraped-example .src-line-numbers",
|
2022-12-20 11:32:35 -06:00
|
|
|
{"clientWidth": "0"}
|
|
|
|
)
|
|
|
|
|
|
|
|
// Check that examples with very long lines have the same width as ones that don't.
|
|
|
|
store-property: (
|
2024-08-30 17:12:10 -05:00
|
|
|
".more-scraped-examples .scraped-example:nth-child(2) .src-line-numbers",
|
2023-05-10 03:56:59 -05:00
|
|
|
{"clientWidth": clientWidth},
|
2022-12-20 11:32:35 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
assert-property: (
|
2024-08-30 17:12:10 -05:00
|
|
|
".more-scraped-examples .scraped-example:nth-child(3) .src-line-numbers",
|
2022-12-20 11:32:35 -06:00
|
|
|
{"clientWidth": |clientWidth|}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert-property: (
|
2024-08-30 17:12:10 -05:00
|
|
|
".more-scraped-examples .scraped-example:nth-child(4) .src-line-numbers",
|
2022-12-20 11:32:35 -06:00
|
|
|
{"clientWidth": |clientWidth|}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert-property: (
|
2024-08-30 17:12:10 -05:00
|
|
|
".more-scraped-examples .scraped-example:nth-child(5) .src-line-numbers",
|
2022-12-20 11:32:35 -06:00
|
|
|
{"clientWidth": |clientWidth|}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert-property: (
|
2024-08-30 17:12:10 -05:00
|
|
|
".more-scraped-examples .scraped-example:nth-child(6) .src-line-numbers",
|
2022-12-20 11:32:35 -06:00
|
|
|
{"clientWidth": |clientWidth|}
|
|
|
|
)
|
2022-12-30 09:27:56 -06:00
|
|
|
|
2024-09-01 08:00:51 -05:00
|
|
|
// The "title" should be located at the right bottom corner of the code example.
|
2024-09-02 08:59:00 -05:00
|
|
|
store-position: (".scraped-example .example-wrap", {"x": x, "y": y})
|
2024-09-20 08:34:45 -05:00
|
|
|
assert-size: (".scraped-example .example-wrap", {"height": 130})
|
2024-09-02 08:59:00 -05:00
|
|
|
store-size: (".scraped-example .example-wrap", {"width": width, "height": height})
|
|
|
|
store-size: (".scraped-example .scraped-example-title", {
|
2024-09-01 08:00:51 -05:00
|
|
|
"width": title_width,
|
|
|
|
"height": title_height,
|
|
|
|
})
|
2024-09-02 08:59:00 -05:00
|
|
|
assert-position: (".scraped-example .scraped-example-title", {
|
2024-09-01 08:00:51 -05:00
|
|
|
"x": |x| + |width| - |title_width| - 5,
|
|
|
|
"y": |y| + |height| - |title_height| - 8,
|
|
|
|
})
|
|
|
|
|
2024-09-20 08:34:45 -05:00
|
|
|
store-size: (".more-scraped-examples .scraped-example .example-wrap", {"height": more_height})
|
|
|
|
assert: |more_height| > |height|
|
|
|
|
assert-size: (".more-scraped-examples .scraped-example .example-wrap", {
|
|
|
|
"height": 250,
|
|
|
|
"width": |width|,
|
|
|
|
})
|
|
|
|
|
2024-09-02 17:42:13 -05:00
|
|
|
// 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"
|
|
|
|
|
2022-12-30 09:27:56 -06:00
|
|
|
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
|
|
|
|
// correctly.
|
|
|
|
|
|
|
|
store-value: (offset_y, 4)
|
|
|
|
|
|
|
|
// First with desktop
|
2024-10-23 18:15:23 -05:00
|
|
|
assert-position: (".scraped-example", {"y": 256})
|
|
|
|
assert-position: (".scraped-example .prev", {"y": 256 + |offset_y|})
|
2022-12-30 09:27:56 -06:00
|
|
|
|
2024-09-01 16:59:46 -05:00
|
|
|
// Gradient background should be at the top of the code block.
|
2024-09-02 08:59:00 -05:00
|
|
|
assert-css: (".scraped-example .example-wrap::before", {"top": "0px"})
|
|
|
|
assert-css: (".scraped-example .example-wrap::after", {"bottom": "0px"})
|
2024-09-01 16:59:46 -05:00
|
|
|
|
2022-12-30 09:27:56 -06:00
|
|
|
// Then with mobile
|
2023-04-11 12:11:34 -05:00
|
|
|
set-window-size: (600, 600)
|
2024-09-02 08:59:00 -05:00
|
|
|
store-size: (".scraped-example .scraped-example-title", {"height": title_height})
|
2024-10-23 18:15:23 -05:00
|
|
|
assert-position: (".scraped-example", {"y": 291})
|
|
|
|
assert-position: (".scraped-example .prev", {"y": 291 + |offset_y| + |title_height|})
|
2024-09-01 16:59:46 -05:00
|
|
|
|
2024-09-01 08:00:51 -05:00
|
|
|
define-function: (
|
|
|
|
"check_title_and_code_position",
|
|
|
|
[],
|
|
|
|
block {
|
|
|
|
// Title should be above the code.
|
2024-09-02 08:59:00 -05:00
|
|
|
store-position: (".scraped-example .example-wrap .src-line-numbers", {"x": x, "y": y})
|
|
|
|
store-size: (".scraped-example .scraped-example-title", { "height": title_height })
|
2024-09-01 08:00:51 -05:00
|
|
|
|
2024-09-02 08:59:00 -05:00
|
|
|
assert-position: (".scraped-example .scraped-example-title", {
|
2024-09-01 08:00:51 -05:00
|
|
|
"x": |x|, // same X position.
|
|
|
|
"y": |y| - |title_height|,
|
|
|
|
})
|
|
|
|
|
|
|
|
// Line numbers should be right beside the code.
|
|
|
|
compare-elements-position: (
|
2024-09-02 08:59:00 -05:00
|
|
|
".scraped-example .example-wrap .src-line-numbers",
|
|
|
|
".scraped-example .example-wrap .rust",
|
2024-09-01 08:00:51 -05:00
|
|
|
["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", {})
|