-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Fix bug when rustdoc "go to only result" setting is not working as expected" #158308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,16 +33,18 @@ assert-local-storage: {"rustdoc-go-to-only-result": "true"} | |
|
|
||
| go-to: "file://" + |DOC_PATH| + "/lib2/index.html" | ||
| // We enter it into the search. | ||
| click: "#search-button" | ||
| wait-for: "#alternative-display .search-input" | ||
| write-into: (".search-input", "HasALongTraitWithParams") | ||
| wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} | ||
| assert-window-property: ({"location": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) | ||
| assert-window-property: ({"location"."pathname": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no clue how this could have work before since
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // Regression test for <https://github.com/rust-lang/rust/issues/112676>. | ||
| // If "go-to-only-result" is enabled and you go back to history, it should not lead you back to the | ||
| // page result again automatically. | ||
| history-go-back: | ||
| wait-for-document-property: {"title": "lib2 - Rust"} | ||
| assert-window-property: ({"location": "/lib2/index.html"}, ENDS_WITH) | ||
| assert-window-property: ({"location"."pathname": "/lib2/index.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" | ||
|
|
@@ -69,3 +71,43 @@ call-function: ("check-setting", { | |
| "storage_value": "false", | ||
| "setting_attribute_value": "false", | ||
| }) | ||
|
|
||
| define-function: ( | ||
| "search-multiple-results", | ||
| [location], | ||
| block { | ||
| // We wait for the search to be done. | ||
| wait-for: ".search-form" | ||
| // We ensure the page didn't change. | ||
| assert-window-property: {"location"."pathname": |location|} | ||
| // We ensure that there is more than 0 results. | ||
| wait-for-text: ("#search-tabs > button:nth-child(1) .count", "(2)", CONTAINS) | ||
| wait-for-text: ("#search-tabs > button:nth-child(2) .count", "(1)", CONTAINS) | ||
| wait-for-text: ("#search-tabs > button:nth-child(3) .count", "(0)", CONTAINS) | ||
| }, | ||
| ) | ||
|
|
||
| // This is a regression test to ensure that it works when the setting is switched in-between. It | ||
| // could be reproduced by: | ||
| // 1. Doing a search (with "in parameters" or "in return types" having exactly one result) | ||
| // 2. Enabling the setting to true. | ||
| // 3. Reloading the page. | ||
|
|
||
| // First we go to a different page. | ||
| go-to: "file://" + |DOC_PATH| + "/lib2/index.html" | ||
|
|
||
| // The setting should be disabled. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To confirm this test works, run it without the fix. It should fail. :) |
||
| assert-local-storage-false: {"rustdoc-go-to-only-result": "true"} | ||
| store-window-property: {"location"."pathname": location} | ||
| click: "#search-button" | ||
| wait-for: "#alternative-display .search-input" | ||
| write-into: (".search-input", "Whitespace") | ||
| call-function: ("search-multiple-results", {"location": |location|}) | ||
|
|
||
| // We now toggle the setting and reload the page. | ||
| call-function: ("open-settings-menu", {}) | ||
| click: "#go-to-only-result" | ||
| assert-local-storage: {"rustdoc-go-to-only-result": "true"} | ||
|
|
||
| reload: | ||
| call-function: ("search-multiple-results", {"location": |location|}) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised it worked before to directly write into the search input even if it's not displayed. It triggered a bug when I wrote
Whitespaceinto it: it only hadpace, the beginning was removed. I think it's because the item gets moved in-between and if there are few enough letters, it works, but it's only by change.View changes since the review