Integration tests ignoring promises executed in controller action

I am having some issues with integration tests completing and not waiting for promises on the model to complete. (NOTE: using ember-cli stock setup)

The test code:

test 'Saving a projects bid', ->
  visit('/projects/1').then ->
    fillIn('.rate', '10.00')
    click('.save')
    andThen ->
      equal(find('.save').is(':visible'), false)

The controller

ProjectBidNewController = Ember.ObjectController.extend
  rate: null
  rateBinding: 'rate'
  actions:
    save: ->
      project = @get('model')

      bid = @store.createRecord 'project-bid',
        rate: @get('rate')
        project: project

      project.get('project_bids').then (bids) ->
        debugger # <-- never gets here when integration test is running
        bids.pushObject bid
        bid.save().then ->
          # hide the button

Note in the controller save action there are two nested promises, the first one never runs during the integration test, works just fine in the browser.

Maybe I am doing something wrong? After some googling I came across this stackoverflow post which suggests “andThen will only wait for promises created using Ember Test promises”, if I read that correctly - my model promises in the controller action are being executed outside of ‘Ember Test promises’ and so the test will not wait for them to complete.

Feeling a little lost, it seems like this should ‘just work’? Any pointers in the right direction would be appreciated.

you should open this as a bug. Not that i think the current behaviour is a bug, but because it is entirely non-obvious how to handle these situations.

I think you should be wrapping your test into Ember.run as in my example below. Not sure why you are not getting warning about it during test runs.

test("Account", function() {
  stop();
   Ember.run(function(){
     store.find('account','this').then(function(account){
      start();
      ok(account,"Found account!");
    }, function(err){
      start();
      ok(false, "Account request is rejected, error:" + (err.stack || err.message) );
    });
  });
});