fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// Checks that the setting "Directly go to item in search if there is only one result " is working as expected. 2 3define-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 14go-to: "file://" + |DOC_PATH| + "/lib2/index.html" 15 16call-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. 22go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" 23// It will timeout if the setting isn't working. 24wait-for: "#search" 25assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS) 26 27// Now we change its value. 28click: "#settings-menu" 29wait-for: "#settings" 30click: "#go-to-only-result" 31assert-local-storage: {"rustdoc-go-to-only-result": "true"} 32 33go-to: "file://" + |DOC_PATH| + "/lib2/index.html" 34// We enter it into the search. 35write: (".search-input", "HasALongTraitWithParams") 36wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} 37assert-window-property: ({"location": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) 38 39// Regression test for <https://github.com/rust-lang/rust/issues/112676>. 40// If "go-to-only-result" is enabled and you go back to history, it should not lead you back to the 41// page result again automatically. 42history-go-back: 43wait-for-document-property: {"title": "lib2 - Rust"} 44assert-window-property: ({"location": "/lib2/index.html"}, ENDS_WITH) 45 46// We try again to see if it goes to the only result 47go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" 48wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} 49assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) 50 51// We check the settings 52call-function: ("check-setting", { 53 "storage_value": "true", 54 "setting_attribute_value": "true", 55}) 56 57// And now we re-disable the setting. 58click: "#go-to-only-result" 59assert-local-storage: {"rustdoc-go-to-only-result": "false"} 60 61go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams" 62// It will timeout if the setting isn't working. 63wait-for: "#search" 64assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS) 65 66// And we check everything is back the way it was before. 67call-function: ("check-setting", { 68 "storage_value": "false", 69 "setting_attribute_value": "false", 70})