     expect(page.home()).to.eventually.match(pat)
   
   it 'should have help text', ->
-    expect(page.hasHelp()).to.eventually.be.true
+    expect(page.help()).to.eventually.exist
   
   describe 'Imaging Profile', ->
     # Note: this is as deep as the chart can be tested,

Page = require('./helpers/page')()

class SubjectDetailPage extends Page
  # @returns the imaging table properties
  imagingTableProperties: ->
    button = this.select('.qi-modeling-profile button')
    button.click().then () ->
      this.select('.qi-modeling-profile .qi-modeling-list')
  
  # @returns whether the imaging profile list is displayed
  #   when the button is clicked
  canDisplayImagingProfileList: ->
    this.select('.qi-modeling-profile .qi-modeling-list').then (list) ->
      if list
        button = this.select('.qi-modeling-profile button')
        button.click().then ->
          list.isDisplayed()
      else
        false

  # @returns the line chart promise
  linechart: ->

    it 'should display the dateline', ->
      expect(page.linechart()).to.eventually.exist
    
    it 'should toggle the imaging chart and table', ->
      expect(page.toggleImagingProfileFormatButton()).to.eventually.be.true

    it 'should show the imaging properties when the format button is clicked', ->
      page.imagingProfileTables().then (tables) ->
        # There are three imaging properties.
        expect(tables.length).to.equal(3)
        # The visit dates are the first column of the first table
        # set below.
        expectedVisitDate = []
        # Validate each table.
        for table, tblNdx in tables
          table.then (rows) ->
            # There are four visits.
            expect(rows.length).to.equal(4)
            for row, rowNdx in rows
              row.then (cols) ->
                # The first table is Ktrans with seven columns.
                # The other tables have three columns.
                # The first column is the visit date.
                if tblNdx == 0
                  expect(cols.length).to.equal(7)
                  cols[0].then (value) ->
                    expectedVisitDate[rowNdx] = value
                else
                  expect(cols.length).to.equal(3)
                  visitDate = cols[0]
                  expect(visitDate).to.eventually.equal(expectedVisitDate[rowNdx])
                # The percent change is in the third, fifth and seventh column.
                # The percent change of the first row is blank. All other columns
                # are non-blank.
                for value, i in cols[1..-1]
                  if rowNdx == 0 and i > 1 and i % 2 == 1
                    expect(value).to.eventually.equal('')
                  else
                    expect(value).to.eventually.exist
          