From b393e979dc8edf1807b19e0619c617eb786012c6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 16 Jul 2022 13:53:43 +0200 Subject: [PATCH] Fix flakyness of GUI tests --- src/test/rustdoc-gui/escape-key.goml | 2 ++ src/test/rustdoc-gui/search-filter.goml | 2 ++ src/test/rustdoc-gui/search-reexport.goml | 4 ++++ src/test/rustdoc-gui/search-result-color.goml | 2 ++ src/test/rustdoc-gui/search-result-display.goml | 2 ++ src/test/rustdoc-gui/search-result-keyword.goml | 2 ++ .../rustdoc-gui/search-tab-change-title-fn-sig.goml | 10 ++++++++++ src/test/rustdoc-gui/settings.goml | 2 ++ 8 files changed, 26 insertions(+) diff --git a/src/test/rustdoc-gui/escape-key.goml b/src/test/rustdoc-gui/escape-key.goml index d083b0ae0c931..a5afb037d0fd5 100644 --- a/src/test/rustdoc-gui/escape-key.goml +++ b/src/test/rustdoc-gui/escape-key.goml @@ -3,6 +3,8 @@ goto: file://|DOC_PATH|/test_docs/index.html // First, we check that the search results are hidden when the Escape key is pressed. write: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' wait-for: "#search h1" // The search element is empty before the first search // Check that the currently displayed element is search. wait-for: "#alternative-display #search" diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml index d0b3175114cce..d645e23706161 100644 --- a/src/test/rustdoc-gui/search-filter.goml +++ b/src/test/rustdoc-gui/search-filter.goml @@ -2,6 +2,8 @@ goto: file://|DOC_PATH|/test_docs/index.html show-text: true write: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" assert-text: ("#results .externcrate", "test_docs") diff --git a/src/test/rustdoc-gui/search-reexport.goml b/src/test/rustdoc-gui/search-reexport.goml index 557781d481092..5ef890d472b90 100644 --- a/src/test/rustdoc-gui/search-reexport.goml +++ b/src/test/rustdoc-gui/search-reexport.goml @@ -7,6 +7,8 @@ reload: assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;") assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"}) write: (".search-input", "TheStdReexport") +// To be SURE that the search will be run. +press-key: 'Enter' wait-for: "//a[@class='result-import']" assert-attribute: ( "//a[@class='result-import']", @@ -18,6 +20,8 @@ click: "//a[@class='result-import']" wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"}) // We now check that the alias is working as well on the reexport. +// To be SURE that the search will be run. +press-key: 'Enter' write: (".search-input", "AliasForTheStdReexport") wait-for: "//a[@class='result-import']" assert-text: ( diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index 901634fe0e635..9a49ae2c6b853 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -89,6 +89,8 @@ show-text: true // We reload the page so the local storage settings are being used. reload: write: (".search-input", "thisisanalias") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" // Checking that the colors for the alias element are the ones expected. diff --git a/src/test/rustdoc-gui/search-result-display.goml b/src/test/rustdoc-gui/search-result-display.goml index b31905a126a0e..6295d7fae8907 100644 --- a/src/test/rustdoc-gui/search-result-display.goml +++ b/src/test/rustdoc-gui/search-result-display.goml @@ -2,6 +2,8 @@ goto: file://|DOC_PATH|/test_docs/index.html size: (900, 1000) write: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' wait-for: "#search-settings" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... diff --git a/src/test/rustdoc-gui/search-result-keyword.goml b/src/test/rustdoc-gui/search-result-keyword.goml index 8b50c5c5e1a5b..16ae10431acf2 100644 --- a/src/test/rustdoc-gui/search-result-keyword.goml +++ b/src/test/rustdoc-gui/search-result-keyword.goml @@ -1,6 +1,8 @@ // Checks that the "keyword" results have the expected text alongside them. goto: file://|DOC_PATH|/test_docs/index.html write: (".search-input", "CookieMonster") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" // Note: The two next assert commands could be merged as one but readability would be diff --git a/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml b/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml index 763927f9d0fe9..9d506c1519e6b 100644 --- a/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml +++ b/src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml @@ -2,6 +2,8 @@ // First, try a search-by-name goto: file://|DOC_PATH|/test_docs/index.html write: (".search-input", "Foo") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"}) @@ -22,6 +24,8 @@ wait-for-attribute: ("#titles > button:nth-of-type(3)", {"class": "selected"}) // Now try search-by-return goto: file://|DOC_PATH|/test_docs/index.html write: (".search-input", "-> String") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"}) @@ -42,6 +46,8 @@ wait-for-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"}) // Try with a search-by-return with no results goto: file://|DOC_PATH|/test_docs/index.html write: (".search-input", "-> Something") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"}) @@ -50,6 +56,8 @@ assert-text: ("#titles > button:nth-of-type(1)", "In Function Return Types", STA // Try with a search-by-parameter goto: file://|DOC_PATH|/test_docs/index.html write: (".search-input", "usize pattern") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"}) @@ -58,6 +66,8 @@ assert-text: ("#titles > button:nth-of-type(1)", "In Function Parameters", START // Try with a search-by-parameter-and-return goto: file://|DOC_PATH|/test_docs/index.html write: (".search-input", "pattern -> str") +// To be SURE that the search will be run. +press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#titles" assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"}) diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index c402c7991c8bb..8a3365d3cc25e 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -20,6 +20,8 @@ wait-for-css: ("#settings", {"display": "none"}) // Let's click on it when the search results are displayed. focus: ".search-input" write: "test" +// To be SURE that the search will be run. +press-key: 'Enter' wait-for: "#alternative-display #search" click: "#settings-menu" wait-for-css: ("#settings", {"display": "block"})