ember-native-dom-helpers icon indicating copy to clipboard operation
ember-native-dom-helpers copied to clipboard

click doesn't trigger <a {{action}}>

Open jamesarosen opened this issue 7 years ago • 6 comments
trafficstars

I have a template:

<a {{action 'delete'}} data-test={{hook 'delete' id=thing.id}}>

and a test

import { click } from 'ember-native-dom-helpers'
...
await click(hook('delete', { id: thing.id }))

With that, the action never fires. If I change the template to

<a onclick={{action 'delete'}} data-test={{hook 'delete' id=thing.id}}>

everything works as expected.

If this is expected behavior, it would be nice to have it in the README. If it's unexpected, I may be able to create a reproduction to help solve it.

jamesarosen avatar Jan 18 '18 00:01 jamesarosen

What kind of test? Acceptance?

rwjblue avatar Jan 18 '18 00:01 rwjblue

Acceptance?

Yes. More fully,

moduleForAcceptance('Acceptance | Delete Thing', {
})

test('deleting things', async function (assert) {
  // create a thing
  await visit('/things')
  await click(hook('delete', { id: thing.id }))
  assert.hasNoElement($hook('thing', { name: thing.name }))
})

jamesarosen avatar Jan 18 '18 00:01 jamesarosen

In moduleForAcceptance tests ember-native-dom-helpers defers to window.click which comes from Ember's own ember-testing package (and therefore this addon's code itself isn't actually being used for clicking).

What Ember version?

rwjblue avatar Jan 18 '18 00:01 rwjblue

@rwjblue I don't think that is right. In ember-native-dom-helpers the global window.click is never used, no matter what.

cibernox avatar Jan 18 '18 00:01 cibernox

😩 thank you for correcting me @cibernox

I was confusing our wait stuff here. 😞

rwjblue avatar Jan 18 '18 00:01 rwjblue

What Ember version?

2.16.0-beta.2

jamesarosen avatar Jan 18 '18 01:01 jamesarosen