Skip to content

Commit bc9eec0

Browse files
Add GUI test for "Directly go to item in search if there is only one result" setting
1 parent 28982a1 commit bc9eec0

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Diff for: tests/rustdoc-gui/setting-go-to-only-result.goml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Checks that the setting "Directly go to item in search if there is only one result " is working as expected.
2+
3+
define-function: (
4+
"check-setting",
5+
(storage_value, setting_attribute_value),
6+
block {
7+
assert-local-storage: {"rustdoc-go-to-only-result": |storage_value|}
8+
click: "#settings-menu"
9+
wait-for: "#settings"
10+
assert-property: ("#go-to-only-result", {"checked": |setting_attribute_value|})
11+
}
12+
)
13+
14+
goto: "file://" + |DOC_PATH| + "/lib2/index.html"
15+
16+
call-function: ("check-setting", {
17+
"storage_value": null,
18+
"setting_attribute_value": "false",
19+
})
20+
21+
// By default, the search doesn't automatically go to the page if there is only one result.
22+
goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
23+
// It will timeout if the setting isn't working.
24+
wait-for: "#search"
25+
assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
26+
27+
// Now we change its value.
28+
click: "#settings-menu"
29+
wait-for: "#settings"
30+
click: "#go-to-only-result"
31+
assert-local-storage: {"rustdoc-go-to-only-result": "true"}
32+
33+
goto: "file://" + |DOC_PATH| + "/lib2/index.html"
34+
// We enter it into the search.
35+
write: (".search-input", "HasALongTraitWithParams")
36+
wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
37+
assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
38+
39+
// We try again to see if it goes to the only result
40+
goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
41+
wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
42+
assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
43+
44+
// We check the settings
45+
call-function: ("check-setting", {
46+
"storage_value": "true",
47+
"setting_attribute_value": "true",
48+
})
49+
50+
// And now we re-disable the setting.
51+
click: "#go-to-only-result"
52+
assert-local-storage: {"rustdoc-go-to-only-result": "false"}
53+
54+
goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
55+
// It will timeout if the setting isn't working.
56+
wait-for: "#search"
57+
assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
58+
59+
// And we check everything is back the way it was before.
60+
call-function: ("check-setting", {
61+
"storage_value": "false",
62+
"setting_attribute_value": "false",
63+
})

0 commit comments

Comments
 (0)