cibernox/ember-native-dom-helpers

Simulate Ctrl + Delete in Acceptance tests

devinaction opened this issue · 4 comments

I am trying to do a control + delete on one of my elements. I queried it on SO. My code is not deleting the element:

test('multi-press', async function(assert){
await click();
await triggerEvent(, "keydown", {ctrlKey: true, keyCode: 46});
await triggerEvent(, "keyup", {ctrlKey: false, keyCode: 46});}

Please suggest! Help Needed!

@yrtejas Did you try keyEvent('.somewhere', 'keydown', 46, { ctrlKey: true })?

However be aware that this event WILL NOT delete the text, it will only simulate the event but the browser will not delete the text for real because it is a synthetic event. It is impossible to trigger any event that makes the browser delete for real.
You'd have to clear the text input yourself (find('.input').value = '') and then fire the event.

@cibernox I got this error.

✘ Error: Attempted to handle eventbecameError on <element:oqq4jr61> while in state root.deleted.saved. at Class.exception (serve://dist/assets/test-support.js:8340:44) expected true.

I believe your code worked but I guess the error is an Ember data issue.

Agree, that has nothing to do with the test helper.