Skip to content

Commit d314b06

Browse files
Add GUI tests for escape handling
1 parent 281dea4 commit d314b06

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
goto: file://|DOC_PATH|/test_docs/index.html
2+
// First, we check that the search results are hidden when the Escape key is pressed.
3+
write: (".search-input", "test")
4+
wait-for: "#search > h1" // The search element is empty before the first search
5+
assert: ("#search", "class", "content")
6+
assert: ("#main", "class", "content hidden")
7+
press-key: "Escape"
8+
assert: ("#search", "class", "content hidden")
9+
assert: ("#main", "class", "content")
10+
11+
// Check that focusing the search input brings back the search results
12+
focus: ".search-input"
13+
assert: ("#search", "class", "content")
14+
assert: ("#main", "class", "content hidden")
15+
16+
// Now let's check that when the help popup is displayed and we press Escape, it doesn't
17+
// hide the search results too.
18+
click: "#help-button"
19+
assert: ("#help", "class", "")
20+
press-key: "Escape"
21+
assert: ("#help", "class", "hidden")
22+
assert: ("#search", "class", "content")
23+
assert: ("#main", "class", "content hidden")
24+
25+
// FIXME: Once https://github.com/rust-lang/rust/pull/84462 is merged, add check to ensure
26+
// that Escape hides the search results when a result is focused.
27+
// press-key: "ArrowDown"

0 commit comments

Comments
 (0)