Skip to content

Commit 249e54f

Browse files
committed
Factor search process out to a function
1 parent 1cb4274 commit 249e54f

13 files changed

+48
-162
lines changed

tests/rustdoc-gui/cursor.goml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test ensures that several clickable items actually have the pointer cursor.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html"
34

45
// the `[+]/[-]` button
@@ -8,13 +9,7 @@ assert-css: ("#toggle-all-docs", {"cursor": "pointer"})
89
assert-css: ("#copy-path", {"cursor": "pointer"})
910

1011
// the search tabs
11-
click: "#search-button"
12-
wait-for: ".search-input"
13-
write-into: (".search-input", "Foo")
14-
// To be SURE that the search will be run.
15-
press-key: 'Enter'
16-
// Waiting for the search results to appear...
17-
wait-for: "#search-tabs"
12+
call-function: ("perform-search", {"query": "Foo"})
1813
assert-css: ("#search-tabs > button", {"cursor": "pointer"})
1914

2015
// mobile sidebar toggle button

tests/rustdoc-gui/escape-key.goml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
// This test ensures that the "Escape" shortcut is handled correctly based on the
22
// current content displayed.
3+
include: "utils.goml"
34
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
45
// First, we check that the search results are hidden when the Escape key is pressed.
5-
click: "#search-button"
6-
wait-for: "#search .search-switcher" // The search element is empty before the first search
7-
write-into: (".search-input", "test")
8-
press-key: "Enter"
6+
call-function: ("perform-search", {"query": "test"})
97
// Check that the currently displayed element is search.
10-
wait-for: "#alternative-display #search"
118
assert-attribute: ("#main-content", {"class": "content hidden"})
129
assert-document-property: ({"URL": "index.html?search=test"}, ENDS_WITH)
1310
press-key: "Escape"

tests/rustdoc-gui/globals.goml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Make sure search stores its data in `window`
22
// It needs to use a global to avoid racing on search-index.js and search.js
33
// https://github.com/rust-lang/rust/pull/118961
4+
include: "utils.goml"
45

56
// URL query
67
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds"
@@ -9,10 +10,7 @@ assert-window-property-false: {"searchIndex": null}
910

1011
// Form input
1112
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
12-
click: "#search-button"
13-
write-into: (".search-input", "Foo")
14-
press-key: 'Enter'
15-
wait-for: "#search-tabs"
13+
call-function: ("perform-search", {"query": "Foo"})
1614
assert-window-property-false: {"searchIndex": null}
1715

1816
// source sidebar

tests/rustdoc-gui/search-corrections.goml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
// ignore-tidy-linelength
2+
include: "utils.goml"
23

34
// Checks that the search tab result tell the user about corrections
45
// First, try a search-by-name
56
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
6-
click: "#search-button"
7-
wait-for: ".search-input"
8-
// Intentionally wrong spelling of "NotableStructWithLongName"
9-
write-into: (".search-input", "NotableStructWithLongNamr")
10-
// To be SURE that the search will be run.
11-
press-key: 'Enter'
12-
// Waiting for the search results to appear...
13-
wait-for: "#search-tabs"
14-
wait-for-false: "#search-tabs .count.loading"
7+
call-function: ("perform-search", {"query": "NotableStructWithLongNamr"})
158

169
// Corrections aren't shown on the "In Names" tab.
1710
assert: "#search-tabs button.selected:first-child"
@@ -35,15 +28,7 @@ assert-text: (
3528

3629
// Now, explicit return values
3730
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
38-
click: "#search-button"
39-
wait-for: ".search-input"
40-
// Intentionally wrong spelling of "NotableStructWithLongName"
41-
write-into: (".search-input", "-> NotableStructWithLongNamr")
42-
// To be SURE that the search will be run.
43-
press-key: 'Enter'
44-
// Waiting for the search results to appear...
45-
wait-for: "#search-tabs"
46-
wait-for-false: "#search-tabs .count.loading"
31+
call-function: ("perform-search", {"query": "-> NotableStructWithLongNamr"})
4732

4833
assert-text: (
4934
".search-results.active .search-corrections",
@@ -52,15 +37,7 @@ assert-text: (
5237

5338
// Now, generic correction
5439
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
55-
click: "#search-button"
56-
wait-for: ".search-input"
57-
// Intentionally wrong spelling of "NotableStructWithLongName"
58-
write-into: (".search-input", "NotableStructWithLongNamr, NotableStructWithLongNamr")
59-
// To be SURE that the search will be run.
60-
press-key: 'Enter'
61-
// Waiting for the search results to appear...
62-
wait-for: "#search-tabs"
63-
wait-for-false: "#search-tabs .count.loading"
40+
call-function: ("perform-search", {"query": "NotableStructWithLongNamr, NotableStructWithLongNamr"})
6441

6542
assert-text: (
6643
".search-failed.active .search-corrections",
@@ -69,31 +46,15 @@ assert-text: (
6946

7047
// Now, generic correction plus error
7148
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
72-
click: "#search-button"
73-
wait-for: ".search-input"
74-
// Intentionally wrong spelling of "NotableStructWithLongName"
75-
write-into: (".search-input", "Foo<NotableStructWithLongNamr>,y")
76-
// To be SURE that the search will be run.
77-
press-key: 'Enter'
78-
// Waiting for the search results to appear...
79-
wait-for: "#search-tabs"
80-
wait-for-false: "#search-tabs .count.loading"
49+
call-function: ("perform-search", {"query": "Foo<NotableStructWithLongNamr>,y"})
8150

8251
assert-text: (
8352
".search-failed.active .search-corrections",
8453
"Type \"NotableStructWithLongNamr\" not found and used as generic parameter. Consider searching for \"NotableStructWithLongName\" instead."
8554
)
8655

8756
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
88-
click: "#search-button"
89-
wait-for: ".search-input"
90-
// Intentionally wrong spelling of "NotableStructWithLongName"
91-
write-into: (".search-input", "generic:NotableStructWithLongNamr<x>,y")
92-
// To be SURE that the search will be run.
93-
press-key: 'Enter'
94-
// Waiting for the search results to appear...
95-
wait-for: "#search-tabs"
96-
wait-for-false: "#search-tabs .count.loading"
57+
call-function: ("perform-search", {"query": "generic:NotableStructWithLongNamr<x>,y"})
9758

9859
assert-css: (".error", {
9960
"display": "block"

tests/rustdoc-gui/search-filter.goml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22
include: "utils.goml"
33
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
44
show-text: true
5-
click: "#search-button"
6-
wait-for: ".search-input"
7-
write-into: (".search-input", "test")
8-
// To be SURE that the search will be run.
9-
press-key: 'Enter'
10-
// Waiting for the search results to appear...
11-
wait-for: "#search-tabs"
12-
wait-for-false: "#search-tabs .count.loading"
5+
call-function: ("perform-search", {"query": "test"})
136
assert-text: ("#results .externcrate", "test_docs")
147

158
wait-for: "#crate-search"

tests/rustdoc-gui/search-keyboard.goml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// Checks that the search tab results work correctly with function signature syntax
22
// First, try a search-by-name
3+
include: "utils.goml"
34
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
4-
click: "#search-button"
5-
wait-for: ".search-input"
6-
write-into: (".search-input", "Foo")
7-
// To be SURE that the search will be run.
8-
press-key: 'Enter'
9-
// Waiting for the search results to appear...
10-
wait-for: "#search-tabs"
11-
wait-for-false: "#search-tabs .count.loading"
5+
call-function: ("perform-search", {"query": "Foo"})
126

137
// Now use the keyboard commands to switch to the third result.
148
press-key: "ArrowDown"

tests/rustdoc-gui/search-reexport.goml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ call-function: ("switch-theme", {"theme": "dark"})
66
// First we check that the reexport has the correct ID and no background color.
77
assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;")
88
assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"})
9-
click: "#search-button"
10-
wait-for: ".search-input"
11-
write-into: (".search-input", "TheStdReexport")
12-
// To be SURE that the search will be run.
13-
press-key: 'Enter'
14-
wait-for: "//a[@class='result-import']"
9+
call-function: ("perform-search", {"query": "TheStdReexport"})
10+
assert: "//a[@class='result-import']"
1511
assert-attribute: (
1612
"//a[@class='result-import']",
1713
{"href": "../test_docs/index.html#reexport.TheStdReexport"},
@@ -23,11 +19,8 @@ wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "#494a
2319

2420
// We now check that the alias is working as well on the reexport.
2521
// To be SURE that the search will be run.
26-
press-key: 'Enter'
27-
click: "#search-button"
28-
wait-for: ".search-input"
29-
write-into: (".search-input", "AliasForTheStdReexport")
30-
wait-for: "//a[@class='result-import']"
22+
call-function: ("perform-search", {"query": "AliasForTheStdReexport"})
23+
assert: "//a[@class='result-import']"
3124
assert-text: (
3225
"a.result-import .result-name",
3326
"re-export AliasForTheStdReexport - see test_docs::TheStdReexport",

tests/rustdoc-gui/search-result-color.goml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,7 @@ call-function: ("check-search-color", {
213213
// Check the alias.
214214
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
215215

216-
click: "#search-button"
217-
wait-for: ".search-input"
218-
write-into: (".search-input", "thisisanalias")
219-
// To be SURE that the search will be run.
220-
press-key: 'Enter'
221-
// Waiting for the search results to appear...
222-
wait-for: "#search-tabs"
223-
wait-for-false: "#search-tabs .count.loading"
216+
call-function: ("perform-search", {"query": "thisisanalias"})
224217

225218
define-function: (
226219
"check-alias",

tests/rustdoc-gui/search-result-impl-disambiguation.goml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
// ignore-tidy-linelength
2+
include: "utils.goml"
23

34
// Checks that, if a type has two methods with the same name, they both get
45
// linked correctly.
56
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
67

78
// This should link to the inherent impl
8-
click: "#search-button"
9-
wait-for: ".search-input"
10-
write-into: (".search-input", "ZyxwvutMethodDisambiguation -> bool")
11-
// To be SURE that the search will be run.
12-
press-key: 'Enter'
13-
// Waiting for the search results to appear...
14-
wait-for: "#search-tabs"
15-
wait-for-false: "#search-tabs .count.loading"
9+
call-function: ("perform-search", {"query": "ZyxwvutMethodDisambiguation -> bool"})
1610
// Check the disambiguated link.
1711
assert-count: ("a.result-method", 1)
1812
assert-attribute: ("a.result-method", {
@@ -28,14 +22,7 @@ assert: "section:target"
2822
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
2923

3024
// This should link to the trait impl
31-
click: "#search-button"
32-
wait-for: ".search-input"
33-
write-into: (".search-input", "ZyxwvutMethodDisambiguation, usize -> usize")
34-
// To be SURE that the search will be run.
35-
press-key: 'Enter'
36-
// Waiting for the search results to appear...
37-
wait-for: "#search-tabs"
38-
wait-for-false: "#search-tabs .count.loading"
25+
call-function: ("perform-search", {"query": "ZyxwvutMethodDisambiguation, usize -> usize"})
3926
// Check the disambiguated link.
4027
assert-count: ("a.result-method", 1)
4128
assert-attribute: ("a.result-method", {
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
// Checks that the "keyword" results have the expected text alongside them.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
3-
click: "#search-button"
4-
write-into: (".search-input", "for")
5-
// To be SURE that the search will be run.
6-
press-key: 'Enter'
7-
// Waiting for the search results to appear...
8-
wait-for: "#search-tabs"
9-
wait-for-false: "#search-tabs .count.loading"
4+
call-function: ("perform-search", {"query": "for"})
105
assert-text: (".result-keyword .result-name", "keyword for")

0 commit comments

Comments
 (0)