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

TestModuleForComponent, integration: true, and {{link-to}} incompatible #41

Closed
jamesarosen opened this issue May 2, 2015 · 23 comments
Closed

Comments

@jamesarosen
Copy link

I have a very simple component:

{{#if (some-helper-that-relies-on-the-session)}}
  {{#link-to 'index'}}Home{{/link-to}}
{{/if}}

and a very simple test:

componentTest('home-link', 'HomeLinkComponent', {
  integration: true,

  beforeEach: function() {
    App = startApp();
    component = this.subject();
    this.render();
  },

  afterEach: function() {
    Ember.run(App, 'destroy');
    App = null;
  }
});

test('anything, really', function(assert) {
  assert.ok(true);
});

With those three factors together, I get Cannot read property 'recognizer' of undefined and Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.

If I remove the link, the test passes. If I turn off integration: true, the test passes.

In this case, I need integration: true because the helper requires the basic app infrastructure.

@jamesarosen
Copy link
Author

This seems related to eviltrout/ember-performance#34

@jamesarosen
Copy link
Author

I've opened ember-cli/ember-cli#3995 as a possible solution since it doesn't seem to me that TestModuleForComponent should really be responsible for starting routing.

@jamesarosen
Copy link
Author

It's possible this will be -- or could be -- resolved by #38.

@technomage
Copy link

Still seeing this after the merge of #38.

@mitchlloyd
Copy link

Just a note that this issue with { integration: true } and {{link-to}} remains after the merge of #49.

@rwjblue
Copy link
Member

rwjblue commented May 18, 2015

@mitchlloyd - Yep, I tested just a bit ago. It is getting closer though.... 😄

@jeremywrowe
Copy link

I am seeing the same thing with { integration: true } {{input}}

here is the error:

Uncaught Error: Assertion Failed: HTMLBars error: Could not find component named "-text-field" (no component or template with that name was found)

Hope it helps. I am very excited to see this style of testing for components moving forward!

i've whipped up a quick project to reproduce: https://github.com/jeremywrowe/ember-component-tests-wip

@MattMSumner
Copy link

I ran into this today. Adding import Router from 'appName/router'fixed it. Is this expected?

Lies! This isn't working for me.

@MattMSumner
Copy link

Is there a solution for this yet? I'm loving { integration: true } component tests but also using link-to.

@rwjblue
Copy link
Member

rwjblue commented Jun 29, 2015

Should be working with beta of ember and 0.4.0 of ember-qunit

@MattMSumner
Copy link

Thanks! For anyone curious here's the PR in Ember: emberjs/ember.js#11522

@rwjblue
Copy link
Member

rwjblue commented Jun 29, 2015

Ok, closing for now. Happy to reopen if folks are still having an issue on 2.0.0-beta.1+.

@rwjblue rwjblue closed this as completed Jun 29, 2015
@seanpdoyle
Copy link
Contributor

I'm seeing something similar.

An integration: true component test, where the component has a {{link-to "route"}} in the template is throwing:

undefined is  an object (evaluating 'routerjs.applyIntent')

(thrown from here)

function calculatePostTransitionState(emberRouter, leafRouteName, contexts) {
  var routerjs = emberRouter.router;
  var state = routerjs.applyIntent(leafRouteName, contexts);
  var handlerInfos = state.handlerInfos;
  var params = state.params;

  for (var i = 0, len = handlerInfos.length; i < len; ++i) {
    var handlerInfo = handlerInfos[i];
    if (!handlerInfo.isResolved) {
      handlerInfo = handlerInfo.becomeResolved(null, handlerInfo.context);
    }
    params[handlerInfo.name] = handlerInfo.params;
  }
  return state;
}

It looks like emberRouter.router is undefined.

@rwjblue
Copy link
Member

rwjblue commented Jul 1, 2015

What Ember version? This is fixed in the beta channel (but won't be back ported to 1.13 most likely).

@seanpdoyle
Copy link
Contributor

@rwjblue in both 1.13.2 and 2.0.0-beta.1

@thec0keman
Copy link

We had similar issues on 1.13.2, and used this hack:

Ember.Router.reopen({
  generate: function () {
    if (!this.router)
      return;
    this._super.apply(this, arguments);
  },

  _prepareQueryParams: function () {
    if (!this.router)
      return;
    this._super.apply(this, arguments);
  }
})

That, plus the patch that is on 2.0-beta and all tests are passing.

@seanpdoyle
Copy link
Contributor

@thec0keman tried that out to no avail. 😞

@rwjblue
Copy link
Member

rwjblue commented Jul 2, 2015

@seanpdoyle - I think the fix landed after 2.0.0-beta.1, so you'll have to test in the latest beta builds (bower install --save ember#beta).

@rwjblue
Copy link
Member

rwjblue commented Jul 3, 2015

The fixes needed have been pulled into release channel, and will be included in 1.13.3.

Thanks to @nathanhammond and @tomdale for making this happen.

@givanse
Copy link

givanse commented Jul 13, 2015

For anyone reading, I was seeing this error with the following combination:

  • ember-cli 1.13.1
  • ember 0.12.0
  • ember-data 1.0.0-beta.18

(gradual upgrade of an app)

Downgraded ember-qunit to 0.3.4 and all is good.

@blimmer
Copy link
Contributor

blimmer commented Jul 18, 2015

@rwjblue is there any chance that the fixes needed to make integration testing of {{link-to}} available in 1.12.x ? I have a project that I'm stuck on 1.12 and would love to be able to use integration test components with link-to's.

@blimmer
Copy link
Contributor

blimmer commented Jul 20, 2015

I've opened this issue asking to get this functionality into 1.12.x.

UPDATE: If anyone needs to get this working before the PR I've submitted has been looked at/merged/released, you can use my fork by changing ember in your bower.json to this:

"ember": "Ibotta/ember#4bbe01039db57ca5759ab6f6e7a44c35fc346ab9",

@alexlafroscia
Copy link

@blimmer Thanks for that PR and for providing the Bower info, that's exactly what I needed!

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