@@ -28,3 +28,48 @@ assert-text: ("#searchresults-header", "")
2828call-function: ("open-search", {})
2929write: "strikethrough"
3030wait-for-text: ("#searchresults-header", "2 search results for 'strikethrough':")
31+
32+ // Now we test search shortcuts and more page changes.
33+ go-to: |DOC_PATH| + "index.html"
34+
35+ // First we ensure that the search input is disabled and hidden.
36+ assert: "#searchbar:disabled"
37+ // This check is to ensure that the search bar is inside the search wrapper.
38+ assert: "#search-wrapper #searchbar"
39+ assert-css: ("#search-wrapper", {"display": "none"})
40+
41+ // Now we make the search input appear with the `S` shortcut.
42+ press-key: 'S'
43+ wait-for: "#searchbar:not(:disabled)"
44+ assert-css: ("#search-wrapper", {"display": "block"})
45+ // We ensure the search bar has the focus.
46+ assert: "#searchbar:focus"
47+
48+ // Now we press `Escape` to ensure that the search input disappears again.
49+ press-key: 'Escape'
50+ wait-for-css: ("#search-wrapper", {"display": "none"})
51+
52+ // Making it appear by clicking on the search button.
53+ click: "#search-toggle"
54+ wait-for-css: ("#search-wrapper", {"display": "block"})
55+ // We ensure the search bar has the focus.
56+ assert: "#searchbar:focus"
57+
58+ // We input "test".
59+ write: "test"
60+ // The results should now appear.
61+ wait-for-text: ("#searchresults-header", "search results for 'test':", ENDS_WITH)
62+ assert: "#searchresults"
63+ // Ensure that the URL was updated as well.
64+ assert-document-property: ({"URL": "?search=test"}, ENDS_WITH)
65+
66+ // Now we ensure that when we land on the page with a "search in progress", the search results are
67+ // loaded and that the search input has focus.
68+ go-to: |DOC_PATH| + "index.html?search=test"
69+ wait-for-text: ("#searchresults-header", "search results for 'test':", ENDS_WITH)
70+ assert: "#searchbar:focus"
71+ assert: "#searchresults"
72+
73+ // And now we press `Escape` to close everything.
74+ press-key: 'Escape'
75+ wait-for-css: ("#search-wrapper", {"display": "none"})
0 commit comments