Skip to content

Commit 0c6e01b

Browse files
authored
Rollup merge of rust-lang#99323 - GuillaumeGomez:fix-gui-flaky, r=Dylan-DPC
Fix flakyness of GUI tests Fixes rust-lang#98163. All flaky tests seemed to be linked to the search. Since the search JS is loaded when we focus the search input, I think it's possible that we enter faster than the JS is actually loaded. The solution for that would be to do it in two steps: first we write into the search input (`browser-ui-test` adds a small sleep time after such commands) and then we press enter to be sure that it wasn't missed. cc `@JohnTitor` r? `@Dylan-DPC`
2 parents ddc32d1 + b393e97 commit 0c6e01b

8 files changed

+26
-0
lines changed

src/test/rustdoc-gui/escape-key.goml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
goto: file://|DOC_PATH|/test_docs/index.html
44
// First, we check that the search results are hidden when the Escape key is pressed.
55
write: (".search-input", "test")
6+
// To be SURE that the search will be run.
7+
press-key: 'Enter'
68
wait-for: "#search h1" // The search element is empty before the first search
79
// Check that the currently displayed element is search.
810
wait-for: "#alternative-display #search"

src/test/rustdoc-gui/search-filter.goml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
goto: file://|DOC_PATH|/test_docs/index.html
33
show-text: true
44
write: (".search-input", "test")
5+
// To be SURE that the search will be run.
6+
press-key: 'Enter'
57
// Waiting for the search results to appear...
68
wait-for: "#titles"
79
assert-text: ("#results .externcrate", "test_docs")

src/test/rustdoc-gui/search-reexport.goml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ reload:
77
assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;")
88
assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"})
99
write: (".search-input", "TheStdReexport")
10+
// To be SURE that the search will be run.
11+
press-key: 'Enter'
1012
wait-for: "//a[@class='result-import']"
1113
assert-attribute: (
1214
"//a[@class='result-import']",
@@ -18,6 +20,8 @@ click: "//a[@class='result-import']"
1820
wait-for-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgb(73, 74, 61)"})
1921

2022
// We now check that the alias is working as well on the reexport.
23+
// To be SURE that the search will be run.
24+
press-key: 'Enter'
2125
write: (".search-input", "AliasForTheStdReexport")
2226
wait-for: "//a[@class='result-import']"
2327
assert-text: (

src/test/rustdoc-gui/search-result-color.goml

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ show-text: true
8989
// We reload the page so the local storage settings are being used.
9090
reload:
9191
write: (".search-input", "thisisanalias")
92+
// To be SURE that the search will be run.
93+
press-key: 'Enter'
9294
// Waiting for the search results to appear...
9395
wait-for: "#titles"
9496
// Checking that the colors for the alias element are the ones expected.

src/test/rustdoc-gui/search-result-display.goml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
goto: file://|DOC_PATH|/test_docs/index.html
33
size: (900, 1000)
44
write: (".search-input", "test")
5+
// To be SURE that the search will be run.
6+
press-key: 'Enter'
57
wait-for: "#search-settings"
68
// The width is returned by "getComputedStyle" which returns the exact number instead of the
79
// CSS rule which is "50%"...

src/test/rustdoc-gui/search-result-keyword.goml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Checks that the "keyword" results have the expected text alongside them.
22
goto: file://|DOC_PATH|/test_docs/index.html
33
write: (".search-input", "CookieMonster")
4+
// To be SURE that the search will be run.
5+
press-key: 'Enter'
46
// Waiting for the search results to appear...
57
wait-for: "#titles"
68
// Note: The two next assert commands could be merged as one but readability would be

src/test/rustdoc-gui/search-tab-change-title-fn-sig.goml

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// First, try a search-by-name
33
goto: file://|DOC_PATH|/test_docs/index.html
44
write: (".search-input", "Foo")
5+
// To be SURE that the search will be run.
6+
press-key: 'Enter'
57
// Waiting for the search results to appear...
68
wait-for: "#titles"
79
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"})
2224
// Now try search-by-return
2325
goto: file://|DOC_PATH|/test_docs/index.html
2426
write: (".search-input", "-> String")
27+
// To be SURE that the search will be run.
28+
press-key: 'Enter'
2529
// Waiting for the search results to appear...
2630
wait-for: "#titles"
2731
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"})
4246
// Try with a search-by-return with no results
4347
goto: file://|DOC_PATH|/test_docs/index.html
4448
write: (".search-input", "-> Something")
49+
// To be SURE that the search will be run.
50+
press-key: 'Enter'
4551
// Waiting for the search results to appear...
4652
wait-for: "#titles"
4753
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
5056
// Try with a search-by-parameter
5157
goto: file://|DOC_PATH|/test_docs/index.html
5258
write: (".search-input", "usize pattern")
59+
// To be SURE that the search will be run.
60+
press-key: 'Enter'
5361
// Waiting for the search results to appear...
5462
wait-for: "#titles"
5563
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
5866
// Try with a search-by-parameter-and-return
5967
goto: file://|DOC_PATH|/test_docs/index.html
6068
write: (".search-input", "pattern -> str")
69+
// To be SURE that the search will be run.
70+
press-key: 'Enter'
6171
// Waiting for the search results to appear...
6272
wait-for: "#titles"
6373
assert-attribute: ("#titles > button:nth-of-type(1)", {"class": "selected"})

src/test/rustdoc-gui/settings.goml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ wait-for-css: ("#settings", {"display": "none"})
2020
// Let's click on it when the search results are displayed.
2121
focus: ".search-input"
2222
write: "test"
23+
// To be SURE that the search will be run.
24+
press-key: 'Enter'
2325
wait-for: "#alternative-display #search"
2426
click: "#settings-menu"
2527
wait-for-css: ("#settings", {"display": "block"})

0 commit comments

Comments
 (0)