#Ember Acceptance Test Help: Submit Form with Enter Key

1 messages · Page 1 of 1 (latest)

swift torrent
#

Hi guys, I’m running into a challenge with writing an acceptance test for form submission via the Enter key.
Context : In our app, we have many forms where users can fill in input fields and press Enter to submit.
Problem : I’m now writing an acceptance test in Ember to verify this behavior — specifically:

Fill in the form ➡️ press Enter ➡️ form should be submitted.

But here’s the catch:

In the test environment, triggerKeyEvent(..., 'keydown', 'Enter') doesn't trigger form submission.

That’s because the test runner expects a keydown handler to be explicitly wired (which we don’t do, because the form uses the standard HTML 'structure submit button inside the form')

Adding key event listeners to every form just for the sake of testing would be redundant and hard to maintain — especially in a large-scale app.
I have attached the simple example for the above issue.

full cave
#

I wonder if it works if you put the handleSubmit on the form itself.
e.g. <form {{on "submit" this.submit}}>...</form>.
At the moment you seem to only listen to the button being clicked, but the keydown happens on the input

#

You may also need to add an event.preventDefault on the submit handler as well to make sure it does not try to send an HTTP request and reload the page

swift torrent
unreal delta
#

synthetic events never trigger default behaviors