Ember-cli and ember-simple-auth for testing

I use ember-simple-authwith ember-cli. I cannot figure out how to authenticate during integration tests.

In my startApp, I look at the session from the container and then set the property isAuthenticatedto true, but I think this is not enough.

I re-open the session in the initializer and add the computed user property. To test this, you should also not look for storage.

Session.reopen({
  user: function() {
    var userId = this.get('user_id');
    if (!Ember.isEmpty(userId)) {
      return container.lookup('store:main').find('user', userId);
    }
  }.property('userId')
});

And also I believe that the local storage is not suitable for testing, therefore, how to set the type of storage on store:ephemeralwhen running the tests.

I could not find any complete tutorial or anything about writing an integration test when using ember-cli and ember-simple-auth. thanks in advance

+4

Source: https://habr.com/ru/post/1548061/


All Articles