Skip to content

Commit dbad189

Browse files
committed
Add a gui test book for search
This isolates the search test with its own test book.
1 parent 4a06e06 commit dbad189

File tree

6 files changed

+37
-14
lines changed

6 files changed

+37
-14
lines changed

tests/gui/books/search/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Search
2+
3+
This GUI test book is used for testing basic search interaction.

tests/gui/books/search/book.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[book]
2+
title = "search"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Summary
2+
3+
- [Chapter 1](./chapter_1.md)
4+
- [Chapter 2](./inner/chapter_2.md)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Chapter 1
2+
3+
extraordinary refrigerator philosophical thunderstorm kaleidoscope
4+
5+
## Repeat on same page
6+
7+
kaleidoscope
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Chapter 2
2+
3+
championship mediterranean sophisticated tuberculosis photographer
4+
5+
## Repeat from other chapter
6+
7+
extraordinary

tests/gui/search.goml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This tests basic search behavior.
22

33
fail-on-js-error: true
4-
go-to: |DOC_PATH| + "test_book/index.html"
4+
go-to: |DOC_PATH| + "search/index.html"
55

66
define-function: (
77
"open-search",
@@ -15,23 +15,23 @@ define-function: (
1515

1616
call-function: ("open-search", {})
1717
assert-text: ("#mdbook-searchresults-header", "")
18-
write: "strikethrough"
19-
wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'strikethrough':")
18+
write: "extraordinary"
19+
wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'extraordinary':")
2020
// Close the search display
2121
press-key: 'Escape'
2222
wait-for-css: ("#mdbook-search-wrapper", {"display": "none"})
2323
// Reopening the search should show the last value
2424
call-function: ("open-search", {})
25-
assert-text: ("#mdbook-searchresults-header", "2 search results for 'strikethrough':")
25+
assert-text: ("#mdbook-searchresults-header", "2 search results for 'extraordinary':")
2626
// Navigate to a sub-chapter
27-
go-to: "./individual/strikethrough.html"
27+
go-to: "./inner/chapter_2.html"
2828
assert-text: ("#mdbook-searchresults-header", "")
2929
call-function: ("open-search", {})
30-
write: "strikethrough"
31-
wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'strikethrough':")
30+
write: "kaleidoscope"
31+
wait-for-text: ("#mdbook-searchresults-header", "2 search results for 'kaleidoscope':")
3232

3333
// Now we test search shortcuts and more page changes.
34-
go-to: |DOC_PATH| + "test_book/index.html"
34+
go-to: |DOC_PATH| + "search/index.html"
3535

3636
// This check is to ensure that the search bar is inside the search wrapper.
3737
assert: "#mdbook-search-wrapper #mdbook-searchbar"
@@ -56,18 +56,18 @@ wait-for-css: ("#mdbook-search-wrapper", {"display": "block"})
5656
// We ensure the search bar has the focus.
5757
assert: "#mdbook-searchbar:focus"
5858

59-
// We input "test".
60-
write: "test"
59+
// We input "thunder".
60+
write: "thunder"
6161
// The results should now appear.
62-
wait-for-text: ("#mdbook-searchresults-header", "search results for 'test':", ENDS_WITH)
62+
wait-for-text: ("#mdbook-searchresults-header", "1 search result for 'thunder':")
6363
assert: "#mdbook-searchresults"
6464
// Ensure that the URL was updated as well.
65-
assert-document-property: ({"URL": "?search=test"}, ENDS_WITH)
65+
assert-document-property: ({"URL": "?search=thunder"}, ENDS_WITH)
6666

6767
// Now we ensure that when we land on the page with a "search in progress", the search results are
6868
// loaded and that the search input has focus.
69-
go-to: |DOC_PATH| + "test_book/index.html?search=test"
70-
wait-for-text: ("#mdbook-searchresults-header", "search results for 'test':", ENDS_WITH)
69+
go-to: |DOC_PATH| + "search/index.html?search=thunder"
70+
wait-for-text: ("#mdbook-searchresults-header", "1 search result for 'thunder':")
7171
assert: "#mdbook-searchbar:focus"
7272
assert: "#mdbook-searchresults"
7373

0 commit comments

Comments
 (0)