mardi 9 août 2016

Acceptance test Redirecting to spacific URL

I created an Acceptance test on ember-cli, in order to check when a user is on a URL and clicks on the "Cancel" button on that page, should be redirected to other URL. When running the test I'm getting this error: "Promise rejected during Redirects to previous URL if cancel button is clicked: Element .close-button not found". But I have that element on my template. Could someone suggest me what I'm missing here or suggest me a documentation I can read in order to solved this error?.

This is my acceptance test:

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

moduleForAcceptance('Acceptance | test/company');
test('Redirects to previous URL if cancel button is clicked', function() {
    return visit('test/company/add').then(function(){
      return click('.close-button');
    }).then(function(assert){
      assert.equal(currentURL(), 'test/company');
    });
});

I tried this test too, but I keep getting similar error:

test('Redirects to previous URL if cancel button is clicked', function(assert) {
  visit('/test/company/add');
  click ('.close-button');
  andThen(function() {
    assert.equal(currentURL(), '/test/company');
  });
});

This is the error: Error: Element .close-button not found.

This is part of the template where I have the cancel button( add.hbs)

<div class="form-add">
    <a href="#" class="close-button" >Close</a>
</div>

This is the controller, where the action 'cancel' is defined:

actions: {
    cancel() {
       if (this.get('isSaved')) {
           return;
       }
         this.transitionToRoute('test/company');
    }
}




Aucun commentaire:

Enregistrer un commentaire