'Scenario: Searching behaves correctly.
Given I have a course with 5 notes
When I open Notes page
When I run the search with "   " query
Then I see the following error message "Please enter a term in the search field."
And I do not see "Search Results" tab
When I run the search with "note" query
Then I see that error message disappears
And I see that "Search Results" tab appears with 4 notes found
And an event has fired indicating that the Search Results view was selected
And an event has fired recording the search that was performed'

def test_search_behaves_correctly(self):

    self._add_default_notes()
    self.notes_page.visit()
    self.notes_page.search('            ')
    self.assertTrue(self.notes_page.is_error_visible)
    self.assertEqual(self.notes_page.error_text, u'Please    enter    a    term    in    the    search    field.')
    self.assertNotIn(u'Search    Results', self.notes_page.tabs)
    self.notes_page.search('note')
    self.assertFalse(self.notes_page.is_error_visible)
    self.assertIn(u'Search    Results', self.notes_page.tabs)
    notes = self.notes_page.notes
    self.assertEqual(len(notes), 4)
    self.assertNoteContent(notes[0], quote=u'Annotate    this', text=u'Fifth    note', unit_name='Test    Unit    1', time_updated='Jan    01,    2015    at    01:01    UTC')
    self.assertNoteContent(notes[1], text=u'Fourth    note', unit_name='Test    Unit    3', time_updated='Jan    01,    2014    at    01:01    UTC', tags=['review'])
    self.assertNoteContent(notes[2], quote='Annotate    this', text=u'Third    note', unit_name='Test    Unit    1', time_updated='Jan    01,    2013    at    01:01    UTC', tags=['Cool', 'TODO'])
    self.assertNoteContent(notes[3], quote=u'Annotate    this', text=u'First    note', unit_name='Test    Unit    4', time_updated='Jan    01,    2011    at    01:01    UTC')
    self.assert_viewed_event('Search    Results')
    self.assert_search_event('note', 4)
