vendredi 21 avril 2017

ember-simple-auth, acceptance tests and waiting for async actions

Struggling with acceptance tests. Started with 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 andThen callback is called before authentication completes. It's jQuery ajax request and a few promises after. From what I can see ember waits for ajax query to complete, but doesn't wait for promises to get resolved/rejected. Should this test work out of the box? Do I have to write a custom waiter?




Aucun commentaire:

Enregistrer un commentaire