vendredi 6 octobre 2017

Login Test with Ember Test

I have write a ember test file for a login formular. The redirect Page is a Dashboard with a Time Ticker Sidebar. Now, when i tested this, i became a test time out after 60000ms. Can i exclude the Time Ticker Component in ember test?

My Test Code:

import {test} from 'qunit';
import moduleForAcceptance from 'frontend/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | Login', {
   integration: true
});

test('visiting /user_session/new', function (assert) {
  visit('/user_session/new');
  fillIn('input#login-email', 'mail@eoceo.de');
  fillIn('input#login-password', 'testtest');
  click('button.btn-primary');

  let done = assert.async();

  andThen(() => {
    Ember.run.later(null, () => {
        assert.equal(currentURL(), '/dashboard', 'redirects to the dashboard');
        done();
    }, 1000);
  });
});

The Time Ticker Component:

import Ember from 'ember';

export default Ember.Component.extend({
  tagName: 'time',

  date: moment().format('DD.MM.YYYY'),

  time: Ember.computed('value', function() {
    return moment().format('HH:mm:ss');
  }),

  didInsertElement: function() {
    this.tick();
  },

  tick: function() {
    this.set('nextTick', Ember.run.later(this, function() {
        this.notifyPropertyChange('value');
        this.tick();
    }, 1000));
  },

  willDestroyElement: function() {
    Ember.run.cancel(this.get('nextTick'));
  }
});




Aucun commentaire:

Enregistrer un commentaire