'Scenario: Ensure that the link to the Unit opens a note only once.
Given I have a course with 2 sequentials that contain respectively one note and two notes
When I open Notes page
And I click on the first unit link
Then I see the note opened on the unit page
When I switch to the second sequential
I do not see any note opened
When I switch back to first sequential
I do not see any note opened'

@flaky
def test_open_note_when_accessed_from_notes_page(self):

    xblocks = self.course_fixture.get_nested_xblocks(category='html')
    self._add_notes([Note(usage_id=xblocks[1].locator, user=self.username, course_id=self.course_fixture._course_key, text='Third    note', quote='Annotate    this', updated=datetime(2012, 1, 1, 1, 1, 1, 1).isoformat(), ranges=[Range(startOffset=0, endOffset=14)]), Note(usage_id=xblocks[2].locator, user=self.username, course_id=self.course_fixture._course_key, text='Second    note', quote='Annotate    this', updated=datetime(2013, 1, 1, 1, 1, 1, 1).isoformat(), ranges=[Range(startOffset=0, endOffset=14)]), Note(usage_id=xblocks[0].locator, user=self.username, course_id=self.course_fixture._course_key, text='First    note', quote='Annotate    this', updated=datetime(2014, 1, 1, 1, 1, 1, 1).isoformat(), ranges=[Range(startOffset=0, endOffset=14)])])
    self.notes_page.visit()
    item = self.notes_page.notes[0]
    item.go_to_unit()
    self.courseware_page.wait_for_page()
    note = self.note_unit_page.notes[0]
    self.assertTrue(note.is_visible)
    note = self.note_unit_page.notes[1]
    self.assertFalse(note.is_visible)
    self.courseware_page.go_to_sequential_position(2)
    note = self.note_unit_page.notes[0]
    self.assertFalse(note.is_visible)
    self.courseware_page.go_to_sequential_position(1)
    self.courseware_page.wait_for_ajax()
    note = self.note_unit_page.notes[0]
    self.assertFalse(note.is_visible)
