diff options
author | Semyon Pupkov <mail@semyonpupkov.com> | 2018-05-04 14:34:58 +0300 |
---|---|---|
committer | Semyon Pupkov <mail@semyonpupkov.com> | 2018-05-04 14:34:58 +0300 |
commit | d0c854bd2e21bd810c1982536645927d5b0f7fd0 (patch) | |
tree | 52d7127d3f4c7b3c7e9e47e2321963f313a991d0 /spec/features/projects/compare_spec.rb | |
parent | 31fa96960f7d224a1da4ca1cf1520a657558567d (diff) |
Replace commits spinach tests with RSpec analog
https://gitlab.com/gitlab-org/gitlab-ce/issues/23036
Diffstat (limited to 'spec/features/projects/compare_spec.rb')
-rw-r--r-- | spec/features/projects/compare_spec.rb | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb index 1fb22fd0e4c..7e863d9df32 100644 --- a/spec/features/projects/compare_spec.rb +++ b/spec/features/projects/compare_spec.rb @@ -7,16 +7,19 @@ describe "Compare", :js do before do project.add_master(user) sign_in user - visit project_compare_index_path(project, from: "master", to: "master") end describe "branches" do it "pre-populates fields" do + visit project_compare_index_path(project, from: "master", to: "master") + expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("master") expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("master") end it "compares branches" do + visit project_compare_index_path(project, from: "master", to: "master") + select_using_dropdown "from", "feature" expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("feature") @@ -26,9 +29,58 @@ describe "Compare", :js do click_button "Compare" expect(page).to have_content "Commits" + expect(page).to have_link 'Create merge request' + end + + it 'renders additions info when click unfold diff' do + visit project_compare_index_path(project) + + select_using_dropdown('from', RepoHelpers.sample_commit.parent_id, commit: true) + select_using_dropdown('to', RepoHelpers.sample_commit.id, commit: true) + + click_button 'Compare' + expect(page).to have_content 'Commits (1)' + expect(page).to have_content "Showing 2 changed files" + + diff = first('.js-unfold') + diff.click + wait_for_requests + + page.within diff.query_scope do + expect(first('.new_line').text).not_to have_content "..." + end + end + + context 'when project have an open merge request' do + let!(:merge_request) do + create( + :merge_request, + title: 'Feature', + source_project: project, + source_branch: 'feature', + target_branch: 'master', + author: project.users.first + ) + end + + it 'compares branches' do + visit project_compare_index_path(project) + + select_using_dropdown('from', 'master') + select_using_dropdown('to', 'feature') + + click_button 'Compare' + + expect(page).to have_content 'Commits (1)' + expect(page).to have_content 'Showing 1 changed file with 5 additions and 0 deletions' + expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request) + expect(page).not_to have_link 'Create merge request' + end end it "filters branches" do + visit project_compare_index_path(project, from: "master", to: "master") + select_using_dropdown("from", "wip") find(".js-compare-from-dropdown .compare-dropdown-toggle").click @@ -39,6 +91,8 @@ describe "Compare", :js do describe "tags" do it "compares tags" do + visit project_compare_index_path(project, from: "master", to: "master") + select_using_dropdown "from", "v1.0.0" expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("v1.0.0") @@ -50,15 +104,20 @@ describe "Compare", :js do end end - def select_using_dropdown(dropdown_type, selection) + def select_using_dropdown(dropdown_type, selection, commit: false) dropdown = find(".js-compare-#{dropdown_type}-dropdown") dropdown.find(".compare-dropdown-toggle").click # find input before using to wait for the inputs visiblity dropdown.find('.dropdown-menu') dropdown.fill_in("Filter by Git revision", with: selection) wait_for_requests - # find before all to wait for the items visiblity - dropdown.find("a[data-ref=\"#{selection}\"]", match: :first) - dropdown.all("a[data-ref=\"#{selection}\"]").last.click + + if commit + dropdown.find('input[type="search"]').send_keys(:return) + else + # find before all to wait for the items visiblity + dropdown.find("a[data-ref=\"#{selection}\"]", match: :first) + dropdown.all("a[data-ref=\"#{selection}\"]").last.click + end end end |