'Scenario: Tabs behaves correctly.
Given I have a course with 5 notes
When I open Notes page
Then I see only "Recent Activity", "Location in Course", and "Tags" tabs
When I run the search with "note" query
And I see that "Search Results" tab appears with 4 notes found
Then I switch to "Recent Activity" tab
And I see all 5 notes
Then I switch to "Location in Course" tab
And I see all 2 groups and 5 notes
When I switch back to "Search Results" tab
Then I can still see 4 notes found
When I close "Search Results" tab
Then I see that "Recent Activity" tab becomes active
And "Search Results" tab disappears
And I see all 5 notes'

def test_tabs_behaves_correctly(self):

    self._add_default_notes()
    self.notes_page.visit()
    self.assertEqual(len(self.notes_page.tabs), 3)
    self.assertEqual([u'Recent    Activity', u'Location    in    Course', u'Tags'], self.notes_page.tabs)
    self.notes_page.search('note')
    self.assertEqual(len(self.notes_page.tabs), 4)
    self.assertIn(u'Search    Results', self.notes_page.tabs)
    self.assertEqual(len(self.notes_page.notes), 4)
    self.notes_page.switch_to_tab('recent')
    self.assertEqual(len(self.notes_page.notes), 5)
    self.notes_page.switch_to_tab('structure')
    self.assertEqual(len(self.notes_page.chapter_groups), 2)
    self.assertEqual(len(self.notes_page.notes), 5)
    self.notes_page.switch_to_tab('search')
    self.assertEqual(len(self.notes_page.notes), 4)
    self.notes_page.close_tab()
    self.assertEqual(len(self.notes_page.tabs), 3)
    self.assertNotIn(u'Search    Results', self.notes_page.tabs)
    self.assertEqual(len(self.notes_page.notes), 5)
