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

Component not in dom in willDestroyElement #16

Conversation

craigteegarden
Copy link
Contributor

We found this issue when upgrading ember-cli to 0.1.15

It seems that a change introduced in the new version of ember-test-helpers causes our component tests to fail because the element is no longer in the DOM when the willDestroyElement hook is called.

We use a jquery ui datepicker component that cleans itself up in the willDestroyElement hook, but now when we run the tests the jquery ui datepicker code errors because it can't destroy the datepicker on the component's element.

In test-module-for-component.js a teardown is added to teardownSteps that destroys the containing view:
https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module-for-component.js#L41

but it looks like that teardown is added after teardownTestElements in test-module.js is added:
https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module.js#L65-L67

and teardownTestElements empties the test div using jquery without letting Ember know:
https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module.js#L141-L144

It seems like a fix would be to prepend the module-for-component's teardown -- not sure if this is the right way to do it, but it allows the test in this PR to pass and it allows our project's failing tests to pass:

_this.teardownSteps.unshift(function() {
  // ...
}

Is there a better fix for this issue?

… teardownSteps queue solves issue with the component not being in the dom when willDestroyElement is called.

Test module empties the ember-testing div using jquery in teardownTestElements(), which originally was called before the module-for-component's teardown was called.
@dgeb
Copy link
Member

dgeb commented Feb 19, 2015

LGTM. @rwjblue - how about you?

rwjblue added a commit that referenced this pull request Feb 19, 2015
…llDestroyElement

Component not in dom in willDestroyElement
@rwjblue rwjblue merged commit 2d75219 into emberjs:master Feb 19, 2015
@rwjblue
Copy link
Member

rwjblue commented Feb 19, 2015

👍

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

Successfully merging this pull request may close these issues.

3 participants