summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-gui/setting-go-to-only-result.goml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/rustdoc-gui/setting-go-to-only-result.goml
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc-gui/setting-go-to-only-result.goml')
-rw-r--r--tests/rustdoc-gui/setting-go-to-only-result.goml63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/rustdoc-gui/setting-go-to-only-result.goml b/tests/rustdoc-gui/setting-go-to-only-result.goml
new file mode 100644
index 000000000..c5720b4bf
--- /dev/null
+++ b/tests/rustdoc-gui/setting-go-to-only-result.goml
@@ -0,0 +1,63 @@
+// Checks that the setting "Directly go to item in search if there is only one result " is working as expected.
+
+define-function: (
+ "check-setting",
+ (storage_value, setting_attribute_value),
+ block {
+ assert-local-storage: {"rustdoc-go-to-only-result": |storage_value|}
+ click: "#settings-menu"
+ wait-for: "#settings"
+ assert-property: ("#go-to-only-result", {"checked": |setting_attribute_value|})
+ }
+)
+
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
+
+call-function: ("check-setting", {
+ "storage_value": null,
+ "setting_attribute_value": "false",
+})
+
+// By default, the search doesn't automatically go to the page if there is only one result.
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
+// It will timeout if the setting isn't working.
+wait-for: "#search"
+assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
+
+// Now we change its value.
+click: "#settings-menu"
+wait-for: "#settings"
+click: "#go-to-only-result"
+assert-local-storage: {"rustdoc-go-to-only-result": "true"}
+
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html"
+// We enter it into the search.
+write: (".search-input", "HasALongTraitWithParams")
+wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
+assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
+
+// We try again to see if it goes to the only result
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
+wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
+assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
+
+// We check the settings
+call-function: ("check-setting", {
+ "storage_value": "true",
+ "setting_attribute_value": "true",
+})
+
+// And now we re-disable the setting.
+click: "#go-to-only-result"
+assert-local-storage: {"rustdoc-go-to-only-result": "false"}
+
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
+// It will timeout if the setting isn't working.
+wait-for: "#search"
+assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
+
+// And we check everything is back the way it was before.
+call-function: ("check-setting", {
+ "storage_value": "false",
+ "setting_attribute_value": "false",
+})