Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent view registry change breaks tests #91

Closed
mdehoog opened this issue Jul 30, 2015 · 2 comments
Closed

Recent view registry change breaks tests #91

mdehoog opened this issue Jul 30, 2015 · 2 comments

Comments

@mdehoog
Copy link

mdehoog commented Jul 30, 2015

The commit 78ba0c0 breaks the checkbox and switch unit tests over at https://github.com/truenorth/ember-cli-materialize (in particular this assertion: https://github.com/truenorth/ember-cli-materialize/blob/master/tests/helpers/selectable-item.js#L55, because the click() event doesn't propagate to the component).

After doing some debugging on the issue I noticed that, when calling Ember's event_dispatcher.js setupHandler() function, the container that was once undefined is now available, and therefore the viewRegistry is set from the lookup of '-view-registry:main' rather than the global View.views (see https://github.com/emberjs/ember.js/blob/680f997ed0958c420abdcd0b1673111aee26afe7/packages/ember-views/lib/system/event_dispatcher.js#L174).

However, when calling this.subject() from a component test, a view doesn't have the view-registry injected into it, and therefore registers itself with the View.views global (because of the fallback at https://github.com/emberjs/ember.js/blob/360d41da7877cd7b00943f0b8d7e7025bc53dbf2/packages/ember-views/lib/views/view.js#L1323).

This means the view is not available when attempting to look it up by its id in the viewRegistry in the event handling function within event_dispatcher.setupHandler() (at https://github.com/emberjs/ember.js/blob/680f997ed0958c420abdcd0b1673111aee26afe7/packages/ember-views/lib/system/event_dispatcher.js#L177), because two different view-registries are being used, the one by the event dispatcher and the one that the view registers itself on.

Switching the ember-cli-materialize project's ember-qunit bower dependency back to a hardcoded v0.4.6 causes the tests to pass again.

@rwjblue
Copy link
Member

rwjblue commented Jul 30, 2015

Thanks for the great bug report! The issue is ultimately that module unit tests (specifically moduleForComponent in unit test mode) falls back to doing container.lookupFactory('component:some-name'), which would normally still get the proper injections except that Ember is only injecting _viewRegistry on view types (discussed a bit here) which IMHO is an Ember bug.


All of that being said, I am working on a fix for this. Hope to have a PR up shortly...

@mdehoog
Copy link
Author

mdehoog commented Jul 31, 2015

Thanks @rwjblue for the quick fix and great support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants