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

Add support for integration: 'legacy' #115

Closed
wants to merge 1 commit into from

Conversation

hjdivad
Copy link
Member

@hjdivad hjdivad commented Oct 28, 2015

This semantics of the integration flag have changed in a
backwards-incompatible way since v0.4.3. This corresponds to an ember upgrade
(using ember-cli) between v1.12 and v1.13.

In order to ease this upgrade path for ember-cli users, integration: 'legacy'
will set up a component test with v0.4.3 semantics. Of course, newer tests
would still be encouraged to be written with integration: true.

@hjdivad
Copy link
Member Author

hjdivad commented Oct 28, 2015

@rwjblue here's a PR for that integration: 'legacy' flag we talked about. I'm still not 100% on the internals of ember-test-helpers so please let me know if there's stuff in this PR that looks wonky that I should examine more closely.

Thanks.

This semantics of the `integration` flag have changed in a
backwards-incompatible way since v0.4.3.  This corresponds to an ember upgrade
(using ember-cli) between v1.12 and v1.13.

In order to ease this upgrade path for ember-cli users, `integration: 'legacy'`
will set up a component test with v0.4.3 semantics.  Of course, newer tests
would still be encouraged to be written with `integration: true`.
@hjdivad
Copy link
Member Author

hjdivad commented Oct 28, 2015

Now the tests even pass!

As an aside the test failures indicate that this feature will not work with ember 2.0, which seems fine to me.

thoughts?

hjdivad added a commit to hjdivad/ember-qunit that referenced this pull request Oct 28, 2015
Obviously this commit is never intended to be merged to master: just here until
emberjs/ember-test-helpers#115 is merged.
hjdivad added a commit to hjdivad/ember-qunit that referenced this pull request Oct 29, 2015
This is just a temporary commit so we can install while waiting for
emberjs/ember-test-helpers#115.
@ef4
Copy link
Contributor

ef4 commented Oct 29, 2015

What was the semantic change for the integration flag?

@hjdivad
Copy link
Member Author

hjdivad commented Oct 29, 2015

@ef4 There are two things that impacted tests I had written.

  1. render now renders into an outer context rather than rendering the component directly. Among other things, this means that render requires a template. This isn't really that big of a deal as it's easy to make this change to tests.
  2. subject is now disallowed. This means primarily that there is no sensible way of getting a reference to the component. That makes a lot of sense with the current approach, in which interaction with the component in a component test is done primarily via the DOM. But previously, where integration: true more or less just meant "you don't have to write needs entries for everything" it would often make sense to set the flag when writing component unit tests in which you would make assertions about component properties.

@ef4
Copy link
Contributor

ef4 commented Oct 29, 2015

But those semantics are literally the original definition of integration:true. There was no earlier integration:true mode with different semantics.

Prior to the introduction of that flag, all tests were unit tests, and they used render and subject as you describe.

@hjdivad
Copy link
Member Author

hjdivad commented Oct 29, 2015

@ef4 whatever the intended semantics, on version 0.4.3 with ember 1.12, you could use subject and render as I describe with integration: true as a means of writing unit tests without needing to specify needs.

ie on version 0.4.3 you could write tests like

moduleForComponent('my-component', {
  integration: true, // no need to specify `needs` now
});

test("my-component has this flag set after you click a thing", function () {
  const component = this.subject();

  this.render();

  Ember.run(function () {
    component.$('button').click();
  });

  equal(component.get('flagB'), true, 'flagB is now set');
});

@rwjblue
Copy link
Member

rwjblue commented Oct 30, 2015

@ef4 - integration: true for moduleForComponent definitely changed meaning when the current (this.render with a template string) style was added. Prior to those changes, integration: true simply gave you a container with no resolver restrictions (so you didn't have to specify needs).

@rwjblue
Copy link
Member

rwjblue commented Oct 30, 2015

Specifically, the chain of events (as far as I can track down) is:

So from 0.3.6 through 0.4.3 you could use integration: true as a way to avoid specifying needs.


tldr; I really mucked things up 😞

}
},

setupLegacyComponentTest: function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module.js#L129-L135 determines if the container that is being used is isolated or has the full resolver (note how we clobber the underlying resolver here after manually resolving all of the needs specified items).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for beating around the bush so much here. I think that legacy mode should only need to do the following:

The combination of those two changes, essentially sets us back to the behavior of ember-test-helpers 0.3.6 - 0.4.3.

@rwjblue
Copy link
Member

rwjblue commented Nov 10, 2015

@hjdivad -- Let me know if you have any questions about my last few comments here...

@rwjblue
Copy link
Member

rwjblue commented Nov 19, 2015

Closing for now, happy to reopen if you want to pick this back up.

@rwjblue rwjblue closed this Nov 19, 2015
@hjdivad
Copy link
Member Author

hjdivad commented Nov 23, 2015

@rwjblue hey sorry it took so long to find time to try this out again. I've redone the branch with the changes you mentioned and our test suite passes. The only other change I had to make was this one: https://github.com/hjdivad/ember-test-helpers/blob/integration-legacy/lib/ember-test-helpers/test-module-for-component.js#L202-L204 to prevent subject from getting indirectly stomped.

Should be good to reopen or I can open a new PR if you'd prefer.

hjdivad added a commit to hjdivad/ember-qunit that referenced this pull request Nov 23, 2015
This is just a temporary commit so we can install while waiting for
emberjs/ember-test-helpers#115.
@rwjblue
Copy link
Member

rwjblue commented Nov 23, 2015

Weird, apparently I can only reopen if there hasn't been a force push to the branch the closed PR was submitted from (which seems kinda dumb/weird).

@rwjblue
Copy link
Member

rwjblue commented Nov 23, 2015

Submitted #121 to replace

@hjdivad
Copy link
Member Author

hjdivad commented Nov 23, 2015

@rwjblue that is a strange restriction.

@rwjblue
Copy link
Member

rwjblue commented Nov 23, 2015

D'OH!! The comment above was about the GH restriction of reopening PR's. 🤦

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