Ember-simple-auth, acceptance tests and awaiting asynchronous actions
Fighting acceptance tests. Started with a basic login test:
import { test } from 'qunit';
import moduleForAcceptance from 'static/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | authentication');
test('login', function(assert) {
visit('/');
click('.nav-bar__login-link');
andThen(function() {
assert.notOk(find('.login-form__submit-button').attr('disabled'));
});
fillIn('.login-form__email-block input', "ruz@email.com");
fillIn('.login-form__password-block input', "qwe");
click('.login-form__submit-button');
andThen(function() {
console.log("ftw");
assert.equal(find('.nav-bar__profile-link').text(), "some");
});
});
The problem is that the andThen callback is called before the authentication is complete. This is a jQuery ajax request and a few promises after. From what I can see, ember is waiting for the ajax request to complete, but not waiting for the promises to be allowed / denied. Should this test work out of the box? Should I write custom waiter?
+3
source to share