 
   it 'should render next screen when Continue is clicked', (done) ->
     tests = (node) ->
-      continueButton = node.querySelector('button.btn-primary')
       introScreenText = node.innerText
 
-      React.addons.TestUtils.Simulate.click(continueButton);
+      exerciseTestActions.clickContinueButton(node)
+
       expect(node.innerText).to.not.be.equal(introScreenText)
 
       done()

VALID_MODEL = require '../../api/courses/1/practice.json'


tasksHelper = (courseId, tests) ->

  # Load practice in CourseStore
  # CourseActions.loaded(model, courseId)
  history = new Router.TestLocation(['/courses/' + courseId + '/tasks/'])

  div = document.createElement('div')
  Router.run routes, history, (Handler, state)->
    router = @
    React.render(<Handler/>, div, ()->
      component = @
      tests?(div, history, component, state, router)
    )

courseHelper = (model, courseId, tests) ->

  # Load practice in CourseStore
  CourseActions.loaded(model, courseId)
  history = new Router.TestLocation(['/courses/' + courseId + '/practice/'])

  div = document.createElement('div')
  Router.run routes, history, (Handler, state)->
    router = @
    React.render(<Handler/>, div, ()->
      component = @
      tests?(div, component, state, router)
    )

describe 'Practice Widget', ->
  beforeEach ->
    CourseActions.reset()

  it 'should load the practice button on the course tasks page', (done) ->
    tests = (node, history) ->

      buttons = Array.prototype.slice.call(node.querySelectorAll('button.btn-primary'))
      practiceButton = _.last(buttons)
      # will need to figure this out, but there's some kind of weird this where this triggers
      # again on the practice front page.  the unless is to avoid a false positive.
      expect(practiceButton.innerText).to.equal('Practice') unless node.querySelector('h1')
      done()

    tasksHelper(1, tests)


{CourseActions, CourseStore} = require '../../src/flux/course'
{TaskActions, TaskStore} = require '../../src/flux/task'
{TaskStepActions, TaskStepStore} = require '../../src/flux/task-step'

{SinglePractice, Tasks} = require '../../src/components'
{routes} = require '../../src/router'
