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

Ember router doesn't know that it's without router.router while testing. #11610

Closed
nathanhammond opened this issue Jul 1, 2015 · 14 comments
Closed

Comments

@nathanhammond
Copy link
Member

This line interacts very oddly in our 1.13 (release channel edge) testing:
https://github.com/emberjs/ember.js/blob/master/packages/ember-routing-views/lib/views/link.js#L269

The get call fails with the obj in that call being undefined (nonsensically, it's clearly being passed in). However, if I change it to:

var routing = get(this, "_routing") || this._routing;

... then it works. This seems counter to failure modes I'm familiar with in Ember. Error message is (since routing isn't set for the subsequent get call): "Assertion Failed: Cannot call get with 'targetState' on an undefined object."

(Posting this primarily for search engines.)

@nathanhammond
Copy link
Member Author

Here's the minimalist reproduction. I'll be tracing this tomorrow.

Notes:

  1. Yes, that syntax is incorrect for the {{link-to}} helper, however, I don't believe that should cause it to fail in this way. (This appears to matter when it's a helper in my more-complicated scenario.)
  2. Fixing that syntax ({{#link-to "index"}}index{{/link-to}}) simply creates a second error: "Cannot read property 'generateURL' of undefined"

Something fishy here.

@nathanhammond nathanhammond reopened this Jul 1, 2015
@nathanhammond
Copy link
Member Author

Original report is a collection of symptoms from just one problem. The issue is simply this: the container set up for testing doesn't resolve for service:-router. This means that the router becomes undefined and results in different failures depending upon where you were when you tried to do something with your reference to the router.

Haven't decided how best to fix this, just documenting.

@nathanhammond nathanhammond changed the title get(LinkComponent, "_routing"); The container set up for testing doesn't resolve for service:-router. Jul 2, 2015
@rwjblue
Copy link
Member

rwjblue commented Jul 2, 2015

@nathanhammond - these lines ensure that the default built registry contains service:-routing, and emberjs/ember-test-helpers#49 (which is incorporated into ember-qunit@0.4.0) ensures that the registry contains all of these default items. Are you using ember-qunit@0.4.0?

@nathanhammond
Copy link
Member Author

Still an error moving to ember-qunit@0.4.0, just a different one. :) I've updated all dependencies to their latest versions in the minimal reproduction.

emberRouter.router is undefined here.

Untraced at this point, will continue to look...

@nathanhammond nathanhammond changed the title The container set up for testing doesn't resolve for service:-router. Ember router doesn't know that it's without router.router while testing. Jul 2, 2015
@nathanhammond
Copy link
Member Author

Two issues:

nathanhammond added a commit to nathanhammond/ember-test-helpers that referenced this issue Jul 2, 2015
The router instance is never set up, though it is expected to be inside of the Ember Router at runtime. Related to [emberjs/ember.js#11610](emberjs/ember.js#11610).
@nathanhammond
Copy link
Member Author

Open cherry-picked PR.

@rwjblue
Copy link
Member

rwjblue commented Jul 2, 2015

#11522 was not targeted for release branch, and we do not want to start routing for integration tests. With the latest beta builds, you should be able to use a {{link-to}} in your ember-qunit integration tests without calling 'startRouting'.

@nathanhammond
Copy link
Member Author

The answer here can't be "don't use 1.13" or "move directly from 1.12 to 2.0." If 1.13 is going to actually receive first class support for the long term (and is our bridge for deprecations), we need testing of components with {{link-to}} in them to actually work. As it stands we still don't have a story for that.

I'm game to code up other solutions, this was the minimally-invasive approach. Proposals?

(We can consolidate conversation here for all of these things.)

/cc @tomdale because of #11522

@rwjblue
Copy link
Member

rwjblue commented Jul 2, 2015

As I commented in that other PR, we need to vet the changes from #11522 to make sure they do not make matters worse in 1.13.

@nathanhammond
Copy link
Member Author

Okay, and calling setupRouter (clarification: not startRouting) isn't kosher inside of ember-test-helpers? I'm doing that primarily to build router.js so that API surface is available (and router.router isn't undefined). Is there a better solution? Just landing #11522 doesn't fix everything.

@nathanhammond
Copy link
Member Author

Offline conversation summary:

  • Acceptance test with a generic {{link-to}} inside a component.
  • Guard router.router instead of running setupRouter.
  • And more...

@rwjblue
Copy link
Member

rwjblue commented Jul 2, 2015 via email

@tomdale
Copy link
Member

tomdale commented Jul 2, 2015

While it isn't elegant, I'm OK with a pragmatic approach to returning compatibility to the 1.13 series. I'd like to revisit this entire code path in 2.x.

@nathanhammond
Copy link
Member Author

Closed by #11639.

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

3 participants