diff --git a/tests/rustdoc-gui/search-about-this-result.goml b/tests/rustdoc-gui/search-about-this-result.goml index ec1df737c8150..c3fea3ba9e5c4 100644 --- a/tests/rustdoc-gui/search-about-this-result.goml +++ b/tests/rustdoc-gui/search-about-this-result.goml @@ -1,13 +1,15 @@ // Check the "About this Result" popover. // Try a complex result. + +include: "utils.goml" + go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=scroll_traits::Iterator,(T->bool)->(Extend,Extend)" // These two commands are used to be sure the search will be run. focus: ".search-input" press-key: "Enter" -wait-for: "#search-tabs" -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-count: ("#search-tabs button", 1) assert-count: (".search-results > a", 1) @@ -32,8 +34,7 @@ go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=F->lib2::WhereWhitespac focus: ".search-input" press-key: "Enter" -wait-for: "#search-tabs" -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-text: ("//div[@class='type-signature']", "F -> WhereWhitespace") assert-count: ("#search-tabs button", 1) assert-count: (".search-results > a", 1) diff --git a/tests/rustdoc-gui/search-error.goml b/tests/rustdoc-gui/search-error.goml index 4d7c2263fd123..5d2ad41dc5615 100644 --- a/tests/rustdoc-gui/search-error.goml +++ b/tests/rustdoc-gui/search-error.goml @@ -8,7 +8,7 @@ define-function: ( [theme, error_background], block { call-function: ("switch-theme", {"theme": |theme|}) - wait-for-false: "#search-tabs .count.loading" + call-function: ("wait-for-search-results", {}) wait-for: "#search .error code" assert-css: ("#search .error code", {"background-color": |error_background|}) } diff --git a/tests/rustdoc-gui/search-filter.goml b/tests/rustdoc-gui/search-filter.goml index 7d0facfb7202b..86893b7867d2f 100644 --- a/tests/rustdoc-gui/search-filter.goml +++ b/tests/rustdoc-gui/search-filter.goml @@ -8,9 +8,7 @@ assert-text: ("#results .externcrate", "test_docs") wait-for: "#crate-search" // We now want to change the crate filter to "lib2". click: "#crate-search option[value='lib2']" -// Waiting for the search results to appear... -wait-for: "#search-tabs" -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-document-property: ({"URL": "&filter-crate="}, CONTAINS) // We check that there is no more "test_docs" appearing. assert-false: "#results .externcrate" @@ -30,9 +28,7 @@ assert-property: ("#crate-search", {"value": "lib2"}) // Selecting back "All crates" click: "#crate-search option[value='all crates']" -// Waiting for the search results to appear... -wait-for: "#search-tabs" -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-property: ("#crate-search", {"value": "all crates"}) // Checking that the URL parameter is taken into account for crate filtering. diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index fdf0afb7e8f72..a1e44032bff70 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -1,8 +1,7 @@ // This test ensures that the elements in ".search-form" have the expected display. include: "utils.goml" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test" -wait-for: "#search-tabs" // Waiting for the search.js to load. -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) show-text: true define-function: ( @@ -120,11 +119,9 @@ call-function: ( // Check that search input correctly decodes form encoding. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a+b" -wait-for: "#search-tabs" // Waiting for the search.js to load. -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-property: (".search-input", { "value": "a b" }) // Check that literal + is not treated as space. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a%2Bb" -wait-for: "#search-tabs" // Waiting for the search.js to load. -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-property: (".search-input", { "value": "a+b" }) diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index e5c11651bd27d..fa7b0658c0923 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -13,9 +13,7 @@ define-function: ( block { call-function: ("switch-theme", {"theme": |theme|}) - // Waiting for the search results to appear... - wait-for: "#search-tabs" - wait-for-false: "#search-tabs .count.loading" + call-function: ("wait-for-search-results", {}) assert-css: ( "#search-tabs > button > .count", {"color": |count_color|}, diff --git a/tests/rustdoc-gui/search-result-description.goml b/tests/rustdoc-gui/search-result-description.goml index 4ab250b472d0f..a3b07466c69a3 100644 --- a/tests/rustdoc-gui/search-result-description.goml +++ b/tests/rustdoc-gui/search-result-description.goml @@ -1,6 +1,5 @@ // This test is to ensure that the codeblocks are correctly rendered in the search results. +include: "utils.goml" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=some_more_function" -// Waiting for the search results to appear... -wait-for: "#search-tabs" -wait-for-false: "#search-tabs .count.loading" +call-function: ("wait-for-search-results", {}) assert-text: (".search-results .desc code", "format!") diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml new file mode 100644 index 0000000000000..fa74a7452185c --- /dev/null +++ b/tests/rustdoc-gui/search-result-display.goml @@ -0,0 +1,112 @@ +// ignore-tidy-linelength +// Checks that the search results have the expected width. +include: "utils.goml" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (900, 1000) +call-function: ("perform-search", {"query": "test"}) +// The width is returned by "getComputedStyle" which returns the exact number instead of the +// CSS rule which is "50%"... +assert-size: (".search-results div.desc", {"width": 248}) +store-size: (".search-results .result-name .typename", {"width": width}) +set-window-size: (600, 100) +// As counter-intuitive as it may seem, in this width, the width is "100%", which is why +// when computed it's larger. +assert-size: (".search-results div.desc", {"width": 566}) + +// The result set is all on one line. +compare-elements-position-near: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"y": 2}, +) +compare-elements-position-near-false: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"x": 5}, +) +// The width of the "typename" isn't fixed anymore in this display mode. +store-size: (".search-results .result-name .typename", {"width": new_width}) +assert: |new_width| < |width| - 10 + +store-value: ( + value, + "SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName", +) +// Check that if the search is too long on mobile, it'll go under the "typename". +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=" + |value| +call-function: ("wait-for-search-results", {}) +compare-elements-position-near: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"y": 2, "x": 0}, +) +compare-elements-size-near: ( + ".search-results .result-name", + ".search-results .result-name .path", + {"width": 8, "height": 8}, +) + +// Check that the crate filter `