diff options
author | Simon Knox <psimyn@gmail.com> | 2018-05-07 08:48:27 +1000 |
---|---|---|
committer | Simon Knox <psimyn@gmail.com> | 2018-05-07 08:48:27 +1000 |
commit | e3f817d93e4131746f4ff3224ed337e432a2872a (patch) | |
tree | bd43c57293058a88d246682e1708e594962f9556 | |
parent | f70dbfddea90a2b82050d656407102522f92f170 (diff) | |
download | gitlab-ce-e3f817d93e4131746f4ff3224ed337e432a2872a.tar.gz |
fix scroll to note specs
3 files changed, 6 insertions, 4 deletions
diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue index 3a3153b0118..9d0a9cd7746 100644 --- a/app/assets/javascripts/notes/components/noteable_discussion.vue +++ b/app/assets/javascripts/notes/components/noteable_discussion.vue @@ -257,7 +257,7 @@ Please check your network connection and try again.`; </div> <div class="timeline-content"> <div - class="discussion" + class="discussion js-discussion-container" :data-discussion-id="discussion.discussion_id" > <div diff --git a/app/assets/javascripts/notes/components/notes_app.vue b/app/assets/javascripts/notes/components/notes_app.vue index fcf81c4a7f5..1254c4bc52d 100644 --- a/app/assets/javascripts/notes/components/notes_app.vue +++ b/app/assets/javascripts/notes/components/notes_app.vue @@ -137,6 +137,7 @@ export default { }, checkLocationHash() { const hash = getLocationHash(); + const noteAnchor = document.querySelector(`a[href="${hash}"]`); const noteId = hash && hash.replace(/^note_/, ''); if (noteId) { @@ -144,7 +145,7 @@ export default { if (discussion.notes) { discussion.notes.forEach(note => { if (`${note.id}` === `${noteId}`) { - this.toggleDiscussion({ discussionId: discussion.id }); + discussion.expanded = true; } }); } diff --git a/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb b/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb index da0585df5e5..586a8fb23fc 100644 --- a/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb +++ b/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb @@ -17,11 +17,12 @@ describe 'Merge request > User scrolls to note on load', :js do it 'scrolls note into view' do visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}" + wait_for_requests + page_height = page.current_window.size[1] page_scroll_y = page.evaluate_script("window.scrollY") fragment_position_top = page.evaluate_script("Math.round($('#{fragment_id}').offset().top)") - expect(find('.js-toggle-content').visible?).to eq true expect(find(fragment_id).visible?).to eq true expect(fragment_position_top).to be >= page_scroll_y expect(fragment_position_top).to be < (page_scroll_y + page_height) @@ -35,7 +36,7 @@ describe 'Merge request > User scrolls to note on load', :js do page.execute_script "window.scrollTo(0,0)" note_element = find(fragment_id) - note_container = note_element.ancestor('.js-toggle-container') + note_container = note_element.ancestor('.js-discussion-container') expect(note_element.visible?).to eq true |