fenichelar/ember-simple-auth-token

[4.x] [Bug] App does not 'settle' after login in acceptance test

niranjan94 opened this issue · 5 comments

After upgrading ember-simple-auth-token to 4.0.2 from 3.0.0, we are facing a weird issue. In our acceptance tests, after login, the app does not reach a settlled state.

A call to getSettledState gives the following response

{
  hasPendingTimers    : true,
  hasRunLoop          : false,
  hasPendingWaiters   : false,
  hasPendingRequests  : false,
  pendingRequestCount : 0
}

This causing the test suite to just freeze since the promise never resolves. (As it is still waiting for the app to settle down).


I have created an isolated application and a test case that shows this very clearly.

Application: https://github.com/niranjan94/token-settle-test

Test case:
https://github.com/niranjan94/token-settle-test/blob/f1fe3393b91f25c2b7b36e4e72258553c3074562/tests/acceptance/failure-case-test.js#L1-L18

This was a fun one but I figured it out! scheduleAccessTokenExpiration schedules the session invalidation based on the expiration of the token which is why the app is never settled. You can confirm this by commenting out this line: https://github.com/jpadilla/ember-simple-auth-token/blob/master/addon/authenticators/jwt.js#L338. I'm not sure what the solution for this is. Using a token with a short expiration is one option but not ideal.

@jpadilla Thoughts?

Using a token with a short expiration is one option but not ideal.

That would be correct. Since we want to test the app when the token is valid too. Maybe there could be a config flag that turns off automated expiration handling of tokens. That way, for testing, we could just turn it off since the tokens we use are anyway short-lived dummy tokens.

Maybe there could be a config flag that turns off automated expiration handling of tokens.

Config flag added in #235

This was not easy to track down..