Move search-result-color.goml common parts into a function

This commit is contained in:
Guillaume Gomez 2024-04-06 14:53:30 +02:00
parent 7659ef47f0
commit 4967895e55

View File

@ -1,6 +1,37 @@
// The goal of this test is to ensure the color of the text is the one expected. // The goal of this test is to ensure the color of the text is the one expected.
include: "utils.goml" include: "utils.goml"
define-function: (
"check-search-color",
[theme, count_color, desc_color, path_color, bottom_border_color],
block {
call-function: ("switch-theme", {"theme": |theme|})
// Waiting for the search results to appear...
wait-for: "#search-tabs"
assert-css: (
"#search-tabs > button > .count",
{"color": |count_color|},
ALL,
)
assert-css: (
"//*[@class='desc'][text()='Just a normal struct.']",
{"color": |desc_color|},
)
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']",
{"color": |path_color|},
)
// Checking the color of the bottom border.
assert-css: (
".search-results > a",
{"border-bottom-color": |bottom_border_color|}
)
}
)
define-function: ( define-function: (
"check-result-color", "check-result-color",
[result_kind, color, hover_color], [result_kind, color, hover_color],
@ -44,29 +75,13 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
show-text: true show-text: true
// Ayu theme // Ayu theme
call-function: ("switch-theme", {"theme": "ayu"}) call-function: ("check-search-color", {
"theme": "ayu",
// Waiting for the search results to appear... "count_color": "#888",
wait-for: "#search-tabs" "desc_color": "#c5c5c5",
assert-css: ( "path_color": "#0096cf",
"#search-tabs > button > .count", "bottom_border_color": "#aaa3",
{"color": "#888"}, })
ALL,
)
assert-css: (
"//*[@class='desc'][text()='Just a normal struct.']",
{"color": "#c5c5c5"},
)
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']",
{"color": "#0096cf"},
)
// Checking the color of the bottom border.
assert-css: (
".search-results > a",
{"border-bottom-color": "#aaa3"}
)
store-value: (entry_color, "#0096cf") // color of the search entry store-value: (entry_color, "#0096cf") // color of the search entry
store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry store-value: (hover_entry_color, "#fff") // color of the hovered/focused search entry
@ -152,29 +167,13 @@ assert-css: (
) )
// Dark theme // Dark theme
call-function: ("switch-theme", {"theme": "dark"}) call-function: ("check-search-color", {
"theme": "dark",
// Waiting for the search results to appear... "count_color": "#888",
wait-for: "#search-tabs" "desc_color": "#ddd",
assert-css: ( "path_color": "#ddd",
"#search-tabs > button > .count", "bottom_border_color": "#aaa3",
{"color": "#888"}, })
ALL,
)
assert-css: (
"//*[@class='desc'][text()='Just a normal struct.']",
{"color": "#ddd"},
)
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']",
{"color": "#ddd"},
)
// Checking the color of the bottom border.
assert-css: (
".search-results > a",
{"border-bottom-color": "#aaa3"}
)
store-value: (entry_color, "#ddd") // color of the search entry store-value: (entry_color, "#ddd") // color of the search entry
store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry store-value: (hover_entry_color, "#ddd") // color of the hovered/focused search entry
@ -248,29 +247,13 @@ assert-css: (
) )
// Light theme // Light theme
call-function: ("switch-theme", {"theme": "light"}) call-function: ("check-search-color", {
"theme": "light",
// Waiting for the search results to appear... "count_color": "#888",
wait-for: "#search-tabs" "desc_color": "#000",
assert-css: ( "path_color": "#000",
"#search-tabs > button > .count", "bottom_border_color": "#aaa3",
{"color": "#888"}, })
ALL,
)
assert-css: (
"//*[@class='desc'][text()='Just a normal struct.']",
{"color": "#000"},
)
assert-css: (
"//*[@class='result-name']//*[text()='test_docs::']",
{"color": "#000"},
)
// Checking the color of the bottom border.
assert-css: (
".search-results > a",
{"border-bottom-color": "#aaa3"}
)
store-value: (entry_color, "#000") // color of the search entry store-value: (entry_color, "#000") // color of the search entry
store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry store-value: (hover_entry_color, "#000") // color of the hovered/focused search entry