test: re-enable the Cmd/Ctrl+Enter form submit hotkey spec - #4685
Merged
Conversation
The example was commented out because it dispatched the keydown on `document.body`. Events bubble up, so it never reached the `form` element that carries the binding (`keydown.ctrl+enter->form#submit keydown.meta+enter->form#submit`, lib/avo/concerns/form_builder.rb). It only ever exercised the Save button's `@github/hotkey` "Mod+Enter", which is document-level but resolves to Meta on macOS and Ctrl on Linux — so it passed locally with `meta_key: true` and would have failed on CI. Dispatch from the focused field instead, which tests the real Stimulus binding and is platform-independent, and cover both modifiers. `fill_in` leaves focus on `body` under Cuprite, hence the explicit `focus_field`. Closes AVO-1117 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
This PR has been merged into Please check the release guide for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes AVO-1117.
Why it was disabled
The
"submits the form with command or control enter"example inspec/system/avo/group_1/hotkey_spec.rbwas commented out during the Avo 4 open beta. It dispatched the keydown ondocument.body— but events bubble up, so it never reached the<form>element that actually carries the binding:What it did exercise was the Save button's
@github/hotkey"Mod+Enter"(app/components/avo/resource_component.rb:217). That one is document-level, butModresolves to Meta on macOS and Ctrl on Linux — so the test passed locally withmeta_key: trueand would have failed on CI.Verified in the browser:
document.body@github/hotkey, macOS only)requestSubmit()requestSubmit()The fix
Dispatch from the focused field so the test covers the real Stimulus binding, which is platform-independent, and run it for both modifiers.
dispatch_active_element_keydowngainedctrl_key:/meta_key:kwargs (defaulting tofalse), matching the siblingdispatch_keydownhelper. Stimulus checks modifier flags exactly, so the unset one must befalse.focus_fieldhelper —fill_inleavesdocument.activeElementonbodyunder Cuprite.Testing
2 examples, 0 failuresfor the re-enabled examples38 examples, 0 failuresfor the full file, three consecutive runs🤖 Generated with Claude Code