2017-01-25 00:12:06 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
feature 'toggler_behavior', :js do
|
2017-01-25 00:12:06 -05:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 17:52:10 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-01-25 00:12:06 -05:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, author: user) }
|
|
|
|
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
|
|
|
|
let(:fragment_id) { "#note_#{note.id}" }
|
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2017-01-25 00:12:06 -05:00
|
|
|
project = merge_request.source_project
|
|
|
|
page.current_window.resize_to(1000, 300)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}"
|
2017-01-25 00:12:06 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'scroll position' do
|
|
|
|
it 'should be scrolled down to fragment' do
|
|
|
|
page_height = page.current_window.size[1]
|
|
|
|
page_scroll_y = page.evaluate_script("window.scrollY")
|
2017-03-18 08:01:00 -04:00
|
|
|
fragment_position_top = page.evaluate_script("Math.round($('#{fragment_id}').offset().top)")
|
2017-01-25 00:12:06 -05:00
|
|
|
expect(find('.js-toggle-content').visible?).to eq true
|
|
|
|
expect(find(fragment_id).visible?).to eq true
|
2017-02-02 06:09:24 -05:00
|
|
|
expect(fragment_position_top).to be >= page_scroll_y
|
2017-01-25 00:12:06 -05:00
|
|
|
expect(fragment_position_top).to be < (page_scroll_y + page_height)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|