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.