Skip to content

Commit

Permalink
Fix flakyness of GUI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 16, 2022
1 parent 0ed9c64 commit b393e97
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/escape-key.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/search-filter.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-gui/search-reexport.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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']",
Expand All @@ -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: (
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/search-result-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/search-result-display.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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%"...
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/search-result-keyword.goml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand All @@ -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"})
Expand All @@ -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"})
Expand All @@ -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"})
Expand All @@ -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"})
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/settings.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down

0 comments on commit b393e97

Please sign in to comment.