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