diff --git a/tests/gui/books/search/README.md b/tests/gui/books/search/README.md new file mode 100644 index 00000000..d087e6cd --- /dev/null +++ b/tests/gui/books/search/README.md @@ -0,0 +1,3 @@ +# Search + +This GUI test book is used for testing basic search interaction. diff --git a/tests/gui/books/search/book.toml b/tests/gui/books/search/book.toml new file mode 100644 index 00000000..a7bdef3d --- /dev/null +++ b/tests/gui/books/search/book.toml @@ -0,0 +1,2 @@ +[book] +title = "search" diff --git a/tests/gui/books/search/src/SUMMARY.md b/tests/gui/books/search/src/SUMMARY.md new file mode 100644 index 00000000..6df575ed --- /dev/null +++ b/tests/gui/books/search/src/SUMMARY.md @@ -0,0 +1,4 @@ +# Summary + +- [Chapter 1](./chapter_1.md) +- [Chapter 2](./inner/chapter_2.md) diff --git a/tests/gui/books/search/src/chapter_1.md b/tests/gui/books/search/src/chapter_1.md new file mode 100644 index 00000000..709b8ded --- /dev/null +++ b/tests/gui/books/search/src/chapter_1.md @@ -0,0 +1,7 @@ +# Chapter 1 + +extraordinary refrigerator philosophical thunderstorm kaleidoscope + +## Repeat on same page + +kaleidoscope diff --git a/tests/gui/books/search/src/inner/chapter_2.md b/tests/gui/books/search/src/inner/chapter_2.md new file mode 100644 index 00000000..8c8964b7 --- /dev/null +++ b/tests/gui/books/search/src/inner/chapter_2.md @@ -0,0 +1,7 @@ +# Chapter 2 + +championship mediterranean sophisticated tuberculosis photographer + +## Repeat from other chapter + +extraordinary diff --git a/tests/gui/search.goml b/tests/gui/search.goml index c2bf4f93..02efdf24 100644 --- a/tests/gui/search.goml +++ b/tests/gui/search.goml @@ -1,7 +1,7 @@ // This tests basic search behavior. fail-on-js-error: true -go-to: |DOC_PATH| + "test_book/index.html" +go-to: |DOC_PATH| + "search/index.html" define-function: ( "open-search", @@ -15,23 +15,23 @@ define-function: ( call-function: ("open-search", {}) assert-text: ("#mdbook-searchresults-header", "") -write: "strikethrough" -wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'strikethrough':") +write: "extraordinary" +wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'extraordinary':") // Close the search display press-key: 'Escape' wait-for-css: ("#mdbook-search-wrapper", {"display": "none"}) // Reopening the search should show the last value call-function: ("open-search", {}) -assert-text: ("#mdbook-searchresults-header", "2 search results for 'strikethrough':") +assert-text: ("#mdbook-searchresults-header", "2 search results for 'extraordinary':") // Navigate to a sub-chapter -go-to: "./individual/strikethrough.html" +go-to: "./inner/chapter_2.html" assert-text: ("#mdbook-searchresults-header", "") call-function: ("open-search", {}) -write: "strikethrough" -wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'strikethrough':") +write: "kaleidoscope" +wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'kaleidoscope':") // Now we test search shortcuts and more page changes. -go-to: |DOC_PATH| + "test_book/index.html" +go-to: |DOC_PATH| + "search/index.html" // This check is to ensure that the search bar is inside the search wrapper. assert: "#mdbook-search-wrapper #mdbook-searchbar" @@ -56,18 +56,18 @@ wait-for-css: ("#mdbook-search-wrapper", {"display": "block"}) // We ensure the search bar has the focus. assert: "#mdbook-searchbar:focus" -// We input "test". -write: "test" +// We input "thunder". +write: "thunder" // The results should now appear. -wait-for-text: ("#mdbook-searchresults-header", "search results for 'test':", ENDS_WITH) +wait-for-text: ("#mdbook-searchresults-header", "1 search result for 'thunder':") assert: "#mdbook-searchresults" // Ensure that the URL was updated as well. -assert-document-property: ({"URL": "?search=test"}, ENDS_WITH) +assert-document-property: ({"URL": "?search=thunder"}, 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| + "test_book/index.html?search=test" -wait-for-text: ("#mdbook-searchresults-header", "search results for 'test':", ENDS_WITH) +go-to: |DOC_PATH| + "search/index.html?search=thunder" +wait-for-text: ("#mdbook-searchresults-header", "1 search result for 'thunder':") assert: "#mdbook-searchbar:focus" assert: "#mdbook-searchresults"