Acceptance testing - wait for route transition

I have the following in my acceptance test:

  assert.expect(1); 

  visit('/signup');
  fillIn('#login-account-name', '123@342343.com');
  fillIn('#login-username', '123-o');
  fillIn('#login-account-password', 'super-hectic-password0921');
  click('#login-register');

  andThen(function() {
    assert.equal(currentURL(), '/');
  }); 

Now - it all seems to be going ok - I can see that the signup posts to my mock api and the session gets authenticated in ember-simple-auth - however the transition to ‘/’ never happens.

In my controller I have:

// i know LoginControllerMixin is being deprecated - i am planning that upgrade work for later
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';
export default Ember.Controller.extend(LoginControllerMixin, {
actions: {
    authenticate: function() {
        //do some basic validation on the inputs:
        this._super()
	    .then(function() {
                _this.transitionToRoute('index');
            });
    }   
}
});

Now, my question is - is the test not waiting for a promise to return because my

authenticate

action doesn’t return anything?

Or am I missing something else? Should/can actions return promises?

1 Like

And now I have a stack of tests failing because I don’t know how to handle this!

It seems that calling click on a button / link that causes a transition to another route doesn’t work. Is this right?

My guess is it’s simple-auth related. If you console log inside the action do you see it’s hitting your code? also -is the super call required? Also -if you drop down into the simple-auth source can you console log from it’s authenticate method (the one you call w/ super?) to see if you are hitting that ?