2025-03-09 09:10:50 -07:00
|
|
|
// This tests basic search behavior.
|
|
|
|
|
|
2025-06-25 18:20:59 +02:00
|
|
|
fail-on-js-error: true
|
2025-03-09 09:10:50 -07:00
|
|
|
go-to: |DOC_PATH| + "index.html"
|
|
|
|
|
|
|
|
|
|
define-function: (
|
|
|
|
|
"open-search",
|
|
|
|
|
[],
|
|
|
|
|
block {
|
|
|
|
|
assert-css: ("#search-wrapper", {"display": "none"})
|
2025-05-26 10:58:53 -07:00
|
|
|
press-key: 's'
|
2025-03-09 09:10:50 -07:00
|
|
|
wait-for-css-false: ("#search-wrapper", {"display": "none"})
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
call-function: ("open-search", {})
|
|
|
|
|
assert-text: ("#searchresults-header", "")
|
|
|
|
|
write: "strikethrough"
|
|
|
|
|
wait-for-text: ("#searchresults-header", "2 search results for 'strikethrough':")
|
|
|
|
|
// Close the search display
|
|
|
|
|
press-key: 'Escape'
|
|
|
|
|
wait-for-css: ("#search-wrapper", {"display": "none"})
|
|
|
|
|
// Reopening the search should show the last value
|
|
|
|
|
call-function: ("open-search", {})
|
|
|
|
|
assert-text: ("#searchresults-header", "2 search results for 'strikethrough':")
|
|
|
|
|
// Navigate to a sub-chapter
|
|
|
|
|
go-to: "./individual/strikethrough.html"
|
|
|
|
|
assert-text: ("#searchresults-header", "")
|
|
|
|
|
call-function: ("open-search", {})
|
|
|
|
|
write: "strikethrough"
|
|
|
|
|
wait-for-text: ("#searchresults-header", "2 search results for 'strikethrough':")
|
2025-02-21 00:34:22 +01:00
|
|
|
|
|
|
|
|
// Now we test search shortcuts and more page changes.
|
|
|
|
|
go-to: |DOC_PATH| + "index.html"
|
|
|
|
|
|
|
|
|
|
// This check is to ensure that the search bar is inside the search wrapper.
|
|
|
|
|
assert: "#search-wrapper #searchbar"
|
|
|
|
|
assert-css: ("#search-wrapper", {"display": "none"})
|
|
|
|
|
|
2025-05-31 09:55:58 +02:00
|
|
|
// Now we make sure the search input appear with the `S` shortcut.
|
|
|
|
|
press-key: 's'
|
|
|
|
|
wait-for-css-false: ("#search-wrapper", {"display": "none"})
|
2025-02-21 00:34:22 +01:00
|
|
|
// We ensure the search bar has the focus.
|
|
|
|
|
assert: "#searchbar:focus"
|
2025-06-25 18:20:59 +02:00
|
|
|
// Pressing a key will therefore update the search input.
|
|
|
|
|
press-key: 't'
|
|
|
|
|
assert-text: ("#searchbar", "t")
|
2025-02-21 00:34:22 +01:00
|
|
|
|
|
|
|
|
// Now we press `Escape` to ensure that the search input disappears again.
|
|
|
|
|
press-key: 'Escape'
|
|
|
|
|
wait-for-css: ("#search-wrapper", {"display": "none"})
|
|
|
|
|
|
|
|
|
|
// Making it appear by clicking on the search button.
|
|
|
|
|
click: "#search-toggle"
|
|
|
|
|
wait-for-css: ("#search-wrapper", {"display": "block"})
|
|
|
|
|
// We ensure the search bar has the focus.
|
|
|
|
|
assert: "#searchbar:focus"
|
|
|
|
|
|
|
|
|
|
// We input "test".
|
|
|
|
|
write: "test"
|
|
|
|
|
// The results should now appear.
|
|
|
|
|
wait-for-text: ("#searchresults-header", "search results for 'test':", ENDS_WITH)
|
|
|
|
|
assert: "#searchresults"
|
|
|
|
|
// Ensure that the URL was updated as well.
|
|
|
|
|
assert-document-property: ({"URL": "?search=test"}, ENDS_WITH)
|
|
|
|
|
|
|
|
|
|
// Now we ensure that when we land on the page with a "search in progress", the search results are
|
|
|
|
|
// loaded and that the search input has focus.
|
|
|
|
|
go-to: |DOC_PATH| + "index.html?search=test"
|
|
|
|
|
wait-for-text: ("#searchresults-header", "search results for 'test':", ENDS_WITH)
|
|
|
|
|
assert: "#searchbar:focus"
|
|
|
|
|
assert: "#searchresults"
|
|
|
|
|
|
|
|
|
|
// And now we press `Escape` to close everything.
|
|
|
|
|
press-key: 'Escape'
|
|
|
|
|
wait-for-css: ("#search-wrapper", {"display": "none"})
|