diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-05-30 18:20:28 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-07-18 14:16:29 +0200 |
| commit | ddaa90fc56bf4b047061a9639097083a61155b8c (patch) | |
| tree | 907d5496f5f765c8f7a485215977a29e9614785e | |
| parent | 9946a68275dc37ef1c7d1727a7876d65646bee44 (diff) | |
| download | rust-ddaa90fc56bf4b047061a9639097083a61155b8c.tar.gz rust-ddaa90fc56bf4b047061a9639097083a61155b8c.zip | |
Add rustdoc GUI test for new copy code feature
| -rw-r--r-- | tests/rustdoc-gui/copy-code.goml | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/rustdoc-gui/copy-code.goml b/tests/rustdoc-gui/copy-code.goml new file mode 100644 index 00000000000..726f9bba9b6 --- /dev/null +++ b/tests/rustdoc-gui/copy-code.goml @@ -0,0 +1,48 @@ +// Checks that the "copy code" button is not triggering JS error and its display +// isn't broken. +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" + +define-function: ( + "check-copy-button", + [], + block { + // First we ensure that there are no "copy code" currently existing. + assert-count: (".example-wrap .copy-button", 0) + move-cursor-to: ".example-wrap" + assert-count: (".example-wrap .copy-button", 1) + // We now ensure it's only displayed when the example is hovered. + assert-css: (".example-wrap .copy-button", { "visibility": "visible" }) + move-cursor-to: ".search-input" + assert-css: (".example-wrap .copy-button", { "visibility": "hidden" }) + }, +) + +call-function: ("check-copy-button", {}) +// Checking that the run button and the copy button have the same height. +compare-elements-size: ( + ".example-wrap:nth-of-type(1) .test-arrow", + ".example-wrap:nth-of-type(1) .copy-button", + ["height"], +) +// ... and the same y position. +compare-elements-position: ( + ".example-wrap:nth-of-type(1) .test-arrow", + ".example-wrap:nth-of-type(1) .copy-button", + ["y"], +) +store-size: (".example-wrap:nth-of-type(1) .copy-button", { + "height": copy_height, + "width": copy_width, +}) +assert: |copy_height| > 0 && |copy_width| > 0 + +// Checking same things for the copy button when there is no run button. +go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" +call-function: ("check-copy-button", {}) +// Ensure there is no run button. +assert-count: (".example-wrap .test-arrow", 0) +// Check it's the same size without a run button. +assert-size: (".example-wrap:nth-of-type(1) .copy-button", { + "height": |copy_height|, + "width": |copy_width|, +}) |
