Move more common code into a function in tests/rustdoc-gui/search-result-color.goml

This commit is contained in:
Guillaume Gomez 2024-04-06 15:24:09 +02:00
parent 4967895e55
commit f14e4db1f9

View File

@ -69,6 +69,32 @@ define-function: (
}, },
) )
define-function: (
"check-container-color",
[link_color, path_color, hover_background],
block {
// Checking the `<a>` container.
move-cursor-to: ".search-input"
focus: ".search-input" // To ensure the `<a>` container isn't focused or hovered.
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
{"color": |link_color|, "background-color": "transparent"},
ALL,
)
// Checking color and background on hover.
move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']",
{"color": |path_color|},
)
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
{"color": |path_color|, "background-color": |hover_background|},
)
}
)
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
// This is needed so that the text color is computed. // This is needed so that the text color is computed.
@ -146,24 +172,12 @@ call-function: (
}, },
) )
// Checking the `<a>` container. call-function: (
move-cursor-to: ".search-input" "check-container-color", {
focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. "link_color": "#0096cf",
assert-css: ( "path_color": "#fff",
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", "hover_background": "#3c3c3c",
{"color": "#0096cf", "background-color": "transparent"}, },
ALL,
)
// Checking color and background on hover.
move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']"
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']",
{"color": "#fff"},
)
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a",
{"color": "#fff", "background-color": "#3c3c3c"},
) )
// Dark theme // Dark theme
@ -238,12 +252,12 @@ call-function: (
}, },
) )
// Checking the `<a>` container. call-function: (
move-cursor-to: ".search-input" "check-container-color", {
focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. "link_color": "#ddd",
assert-css: ( "path_color": "#ddd",
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", "hover_background": "#616161",
{"color": "#ddd", "background-color": "transparent"}, },
) )
// Light theme // Light theme
@ -318,12 +332,12 @@ call-function: (
}, },
) )
// Checking the `<a>` container. call-function: (
move-cursor-to: ".search-input" "check-container-color", {
focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. "link_color": "#000",
assert-css: ( "path_color": "#000",
"//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", "hover_background": "#ccc",
{"color": "#000", "background-color": "transparent"}, },
) )
// Check the alias. // Check the alias.