Skip to content

Commit

Permalink
Update GUI tests for code example buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 30, 2024
1 parent 38c8bc5 commit 5b5fd94
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 56 deletions.
69 changes: 69 additions & 0 deletions tests/rustdoc-gui/code-example-buttons.goml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This test ensures that code blocks buttons are displayed on hover and when you click on them.
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
include: "utils.goml"

// First we check we "hover".
move-cursor-to: ".example-wrap"
Expand All @@ -19,3 +20,71 @@ click: ".example-wrap"
move-cursor-to: ".search-input"
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0)
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })

define-function: (
"check-buttons",
[theme, background, filter, filter_hover],
block {
call-function: ("switch-theme", {"theme": |theme|})

assert-css: (".example-wrap .test-arrow", {"visibility": "hidden"})
assert-css: (".example-wrap .copy-button", {"visibility": "hidden"})

move-cursor-to: ".example-wrap"
assert-css: (".example-wrap .test-arrow", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .test-arrow::before", {
"filter": |filter|,
})
assert-css: (".example-wrap .copy-button", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .copy-button::before", {
"filter": |filter|,
})

move-cursor-to: ".example-wrap .test-arrow"
assert-css: (".example-wrap .test-arrow:hover", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .test-arrow:hover::before", {
"filter": |filter_hover|,
})

move-cursor-to: ".example-wrap .copy-button"
assert-css: (".example-wrap .copy-button:hover", {
"visibility": "visible",
"background-color": |background|,
"border-radius": "2px",
})
assert-css: (".example-wrap .copy-button:hover::before", {
"filter": |filter_hover|,
})
},
)

call-function: ("check-buttons",{
"theme": "ayu",
"background": "#0f1419",
"filter": "invert(0.7)",
"filter_hover": "invert(1)",
})
call-function: ("check-buttons",{
"theme": "dark",
"background": "#353535",
"filter": "invert(0.5)",
"filter_hover": "invert(0.65)",
})
call-function: ("check-buttons",{
"theme": "light",
"background": "#fff",
"filter": "invert(0.5)",
"filter_hover": "invert(0.35)",
})
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/copy-code.goml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ define-function: (
)

call-function: ("check-copy-button", {})
// Checking that the run button and the copy button have the same height.
// Checking that the run button and the copy button have the same height and same width.
compare-elements-size: (
".example-wrap:nth-of-type(1) .test-arrow",
".example-wrap:nth-of-type(1) .copy-button",
["height"],
["height", "width"],
)
// ... and the same y position.
compare-elements-position: (
Expand Down
54 changes: 0 additions & 54 deletions tests/rustdoc-gui/run-on-hover.goml

This file was deleted.

0 comments on commit 5b5fd94

Please sign in to comment.