indexiatech / ember-idx-modal

Ember Indexia Modal
http://indexiatech.github.io/ember-idx-modal/#/gettingstarted
Apache License 2.0
17 stars 13 forks source link

Error in QUnit #12

Open joshpfosi opened 9 years ago

joshpfosi commented 9 years ago

I am trying to do some integration testing of your modal, and any page I load with a modal on it triggers this exception:

Error: Assertion Failed: You must use Ember.set() to set the `modal` property (of <Ember.Object:ember3987>) to `[object Object]`.

I narrowed it down (I think) to modal-toggler.js, line 61: return this.set('modal', Em.View.views[this.get('modal-id')]); in the function below. Putting a break point there immediately raises the exception. This doesn't appear in production or development only QUnit, which makes me think it has something to do with the test env specifically.

  modalAsProperty: (function() {
    var modalAsAncestor;
    modalAsAncestor = this.nearestOfType(Modal);
    if (modalAsAncestor) {
      return this.set('modal', modalAsAncestor);
    } else {
      return Em.run.schedule('afterRender', this, function() {
        return this.set('modal', Em.View.views[this.get('modal-id')]);
      });
    }
  }).on('willInsertElement')
asaf commented 9 years ago

@joshpfosi Hey,

To be honest I'm not really sure, if you have complete example I can try to debug it,

But in general, the idea is that since the toggler is not a descendant view of the modal it will search in Ember views for the view with the name as mentioned in the 'modal-id' param.

Make sure that: 1) when u create the toggler u've put modal-id='the-modal-id' and of course assigned an id to the modal, 2) Try to debug what is the value of Em.View.views[this.get('modal-id')], it should resolve to the modal view.

Thanks!

joshpfosi commented 9 years ago

Hmm, stepping through modal-id is defined properly. I couldn't reproduce this in an independent app which makes me think its something wrong with my setup. I'll look into it more.

joshpfosi commented 9 years ago

So by couldn't I meant could... Here's a repository that demonstrates the issue.

https://github.com/joshpfosi/ember-idx-modal-issue-12

Clone it, run ember server, and open localhost:4200/tests and you should get a failure on the Landing Page integration test.