-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
handleFindAll not playing well with handleUpdate #128
Comments
@eliotpiering, this is a really interesting problem .. I would not quite call it a bug, but maybe an interesting use case, because handleFindAll does actually populate the records .. just AFTER the findAll query has returned ( once that promise is completed in other words ). Here is example of what you have to do to make this work: Ember.run(function () {
var done = assert.async();
TestHelper.handleFindAll('user', 2);
FactoryGuy.getStore().findAll('user').then(function (users) {
TestHelper.handleUpdate('user', 1);
var user = FactoryGuy.getStore().peekRecord('user',1);
user.set('name', 'BOB').save();
done();
});
}); This of course is contrived because its not a real world scenario .. but if you give me an idea of what you are doing .. in your test .. I can try and do better at getting the mocks right in your testing scenario TestHelper.handleFindAll('user', 2);
visit('users')
andThen(function() {
TestHelper.handleUpdate('user', 1);
# now update the user
fillIn('input.user', 'BOB');
click('#save-that-sucker') |
Ahh yes, this last code example made it perfectly clear. I see my mistake now. I just updated my tests and it is working properly. I don't think anything should be different, it makes total sense the way it currently works, but maybe something about handleFindAll populating records after the request resolves in the readme would be helpful. I'll make a pull request for the docs later today. Thanks for the quick response and the great library. |
your welcome @eliotpiering, and yes, it's something I have done in my tests a few times so I think your right that it would be nice to document. In that pull request @eliotpiering, if you want to be a rock star, could you create a test in the acceptance directory ( that you can point to and that people can see when they click on it .. like I did in doc's with some of the other tests ( user.js etc. ) .. that shows the idea too. |
sure no problem, will do shortly. |
I'm trying to write integration tests for an index page. One test involves updating one of the items on the index page. Basically I haven't been able to get this to work.:
handleFindAll doesn't seem to put the records in the store so when handleUpdate calls
it returns null and errors out later on.
I have instead tried using makeList to create the records, which works with handleUpdate but then my tests fail when the route fails to load all the 'connections' because the query has not been mocked out.
I have also tried to pass the result of makeList to handleFindAll but that also doesn't seem to work.
Am I missing something simple here, or is there another strategy I should be using? Or is this a bug?
It would be nice if handleFindAll loaded the records it creates into the store so that we could interact with them afterwards.
I just updated to version 2.0.1 of FactoryGuy and using ember and ember-data 2.0.0. I was experiencing the same issue in version 1.13 of FactoryGuy as well.
The text was updated successfully, but these errors were encountered: