Add a test for global keypress with ACE editor focused

This is a regression test for
https://github.com/rust-lang/mdBook/issues/3064.
This commit is contained in:
Eric Huss 2026-04-27 15:32:09 -07:00
parent 22f3035df0
commit 4adc4b08ba
5 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,6 @@
[book]
title = "editor"
language = "en"
[output.html.playground]
editable = true

View file

@ -0,0 +1,4 @@
# Summary
- [Chapter 1](./chapter_1.md)
- [Chapter 2](./chapter_2.md)

View file

@ -0,0 +1,7 @@
# Chapter 1
```rust,editable
fn main() {
println!("Hello, world!");
}
```

View file

@ -0,0 +1 @@
# Chapter 2

View file

@ -0,0 +1,23 @@
// Tests for global keypress handlers when ACE editor is in focus.
// See https://github.com/rust-lang/mdBook/issues/3064
go-to: |DOC_PATH| + "editor/chapter_1.html"
click: ".ace_editor"
press-key: "s"
// Wait briefly to allow any event handlers triggered by the keypress to run.
// Otherwise there is a race here since the wrapper is already display:none.
wait-for: 200
wait-for-css: ("#mdbook-search-wrapper", {"display": "none"})
press-key: "?"
wait-for: 200
wait-for-css: ("#mdbook-help-container", {"display": "flex"})
// Make sure arrow keys don"t navigate.
press-key: "ArrowRight"
wait-for: 200
assert-window-property: ({"location": |DOC_PATH| + "editor/chapter_1.html"})
press-key: "ArrowLeft"
wait-for: 200
assert-window-property: ({"location": |DOC_PATH| + "editor/chapter_1.html"})