|
| 1 | +// Checks that the interactions with the source code pages are working as expected. |
| 2 | +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" |
| 3 | +show-text: true |
| 4 | + |
| 5 | +define-function: ( |
| 6 | + "click-code-wrapping", |
| 7 | + [expected], |
| 8 | + block { |
| 9 | + click: "#wrap-source-code" |
| 10 | + wait-for-local-storage: {"rustdoc-wrap-source-code": |expected|} |
| 11 | + }, |
| 12 | +) |
| 13 | + |
| 14 | +store-size: (".rust code", {"width": width, "height": height}) |
| 15 | +click: "#settings-menu" |
| 16 | +wait-for: "#settings" |
| 17 | +call-function: ("click-code-wrapping", {"expected": "true"}) |
| 18 | +store-size: (".rust code", {"width": new_width, "height": new_height}) |
| 19 | +// The width should now be smaller than the window's and the height |
| 20 | +// should have increased. |
| 21 | +assert: |width| > |new_width| && |height| < |new_height| |
| 22 | + |
| 23 | +// Switching back to the original setting. |
| 24 | +call-function: ("click-code-wrapping", {"expected": "false"}) |
| 25 | +assert-size: (".rust code", {"width": |width|, "height": |height|}) |
| 26 | + |
| 27 | +// Now let's check in docs code examples. |
| 28 | +go-to: "file://" + |DOC_PATH| + "/test_docs/trait_bounds/index.html" |
| 29 | +click: "#settings-menu" |
| 30 | +wait-for: "#settings" |
| 31 | + |
| 32 | +store-size: (".example-wrap .rust code", {"width": rust_width, "height": rust_height}) |
| 33 | +store-size: (".example-wrap .language-text code", {"width": txt_width, "height": txt_height}) |
| 34 | +call-function: ("click-code-wrapping", {"expected": "true"}) |
| 35 | + |
| 36 | +store-size: (".example-wrap .rust code", {"width": new_rust_width, "height": new_rust_height}) |
| 37 | +store-size: (".example-wrap .language-text code", {"width": new_txt_width, "height": new_txt_height}) |
| 38 | + |
| 39 | +assert: |rust_width| > |new_rust_width| && |rust_height| < |new_rust_height| |
| 40 | +assert: |txt_width| > |new_txt_width| && |txt_height| < |new_txt_height| |
| 41 | + |
| 42 | +call-function: ("click-code-wrapping", {"expected": "false"}) |
| 43 | +assert-size: (".example-wrap .rust code", {"width": |rust_width|, "height": |rust_height|}) |
| 44 | +assert-size: (".example-wrap .language-text code", {"width": |txt_width|, "height": |txt_height|}) |
0 commit comments