diff --git a/tests/.jshintrc b/tests/.jshintrc index 6ec0b7c1..f060e79b 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -21,7 +21,8 @@ "andThen", "currentURL", "currentPath", - "currentRouteName" + "currentRouteName", + "nativeClick" ], "node": false, "browser": false, diff --git a/tests/helpers/acceptance-helpers.js b/tests/helpers/acceptance-helpers.js new file mode 100644 index 00000000..161c2513 --- /dev/null +++ b/tests/helpers/acceptance-helpers.js @@ -0,0 +1,23 @@ +import Ember from 'ember'; + +function fireNativeMouseEvent(eventType, selectorOrDomElement, context) { + let event = new window.Event(eventType, { bubbles: true, cancelable: true, view: window }); + let target; + if (typeof selectorOrDomElement === 'string') { + target = Ember.$(selectorOrDomElement, context)[0]; + } else { + target = selectorOrDomElement; + } + Ember.run(() => target.dispatchEvent(event)); +} + +export default function acceptanceTestHelpers() { + + Ember.Test.registerAsyncHelper('nativeClick', function(app, selectorOrDomElement, context) { + fireNativeMouseEvent('click', selectorOrDomElement, context); + wait(); + }); + +} + +export default acceptanceTestHelpers(); diff --git a/tests/helpers/modal-asserts.js b/tests/helpers/modal-asserts.js index bae7a4d9..5870ae01 100644 --- a/tests/helpers/modal-asserts.js +++ b/tests/helpers/modal-asserts.js @@ -25,7 +25,7 @@ export default function registerAssertHelpers() { message = message || `Dialog triggered by ${options.openSelector} failed to open and close`; const dialogContent = [dialogSelector, `:contains(${options.dialogText})`].join(''); const self = this; - return click(options.openSelector, options.context).then(function() { + return nativeClick(options.openSelector, options.context).then(function() { if (options.hasOverlay) { self.isPresentOnce(overlaySelector); } @@ -33,7 +33,7 @@ export default function registerAssertHelpers() { if (options.whileOpen) { options.whileOpen(); } - return click(options.closeSelector, options.context).then(function() { + return nativeClick(options.closeSelector, options.context).then(function() { self.isAbsent(overlaySelector); self.isAbsent(dialogContent); }); diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index 3fe35b97..ec53eb8f 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -2,6 +2,7 @@ import Ember from 'ember'; import Application from '../../app'; import config from '../../config/environment'; import registerAssertHelpers from './modal-asserts'; +import './acceptance-helpers'; export default function startApp(attrs) { let application;