2016-06-29 06:24:58 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
describe "Compare", :js do
|
2016-06-29 06:24:58 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-07-24 18:51:14 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-06-29 06:24:58 -04:00
|
|
|
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_master(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in user
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_compare_index_path(project, from: "master", to: "master")
|
2016-06-29 06:24:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "branches" do
|
2016-07-25 14:16:19 -04:00
|
|
|
it "pre-populates fields" do
|
2016-09-27 13:29:12 -04:00
|
|
|
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")
|
2016-06-29 06:24:58 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "compares branches" do
|
2016-09-27 13:29:12 -04:00
|
|
|
select_using_dropdown "from", "feature"
|
|
|
|
expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("feature")
|
2016-06-29 06:24:58 -04:00
|
|
|
|
2016-09-27 13:29:12 -04:00
|
|
|
select_using_dropdown "to", "binary-encoding"
|
|
|
|
expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("binary-encoding")
|
2016-06-29 06:24:58 -04:00
|
|
|
|
|
|
|
click_button "Compare"
|
2017-05-12 12:44:03 -04:00
|
|
|
|
2016-06-29 06:24:58 -04:00
|
|
|
expect(page).to have_content "Commits"
|
|
|
|
end
|
2017-03-16 08:04:51 -04:00
|
|
|
|
|
|
|
it "filters branches" do
|
|
|
|
select_using_dropdown("from", "wip")
|
|
|
|
|
|
|
|
find(".js-compare-from-dropdown .compare-dropdown-toggle").click
|
|
|
|
|
|
|
|
expect(find(".js-compare-from-dropdown .dropdown-content")).to have_selector("li", count: 3)
|
|
|
|
end
|
2016-06-29 06:24:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "tags" do
|
2016-07-25 14:16:19 -04:00
|
|
|
it "compares tags" do
|
2016-09-27 13:29:12 -04:00
|
|
|
select_using_dropdown "from", "v1.0.0"
|
|
|
|
expect(find(".js-compare-from-dropdown .dropdown-toggle-text")).to have_content("v1.0.0")
|
2016-06-29 06:24:58 -04:00
|
|
|
|
2016-09-27 13:29:12 -04:00
|
|
|
select_using_dropdown "to", "v1.1.0"
|
|
|
|
expect(find(".js-compare-to-dropdown .dropdown-toggle-text")).to have_content("v1.1.0")
|
2016-06-29 06:24:58 -04:00
|
|
|
|
|
|
|
click_button "Compare"
|
|
|
|
expect(page).to have_content "Commits"
|
|
|
|
end
|
|
|
|
end
|
2016-09-27 13:29:12 -04:00
|
|
|
|
|
|
|
def select_using_dropdown(dropdown_type, selection)
|
|
|
|
dropdown = find(".js-compare-#{dropdown_type}-dropdown")
|
|
|
|
dropdown.find(".compare-dropdown-toggle").click
|
2017-05-24 04:47:25 -04:00
|
|
|
# find input before using to wait for the inputs visiblity
|
2017-05-21 08:53:35 -04:00
|
|
|
dropdown.find('.dropdown-menu')
|
2016-10-17 00:09:38 -04:00
|
|
|
dropdown.fill_in("Filter by Git revision", with: selection)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-24 04:47:25 -04:00
|
|
|
# find before all to wait for the items visiblity
|
2017-05-21 08:53:35 -04:00
|
|
|
dropdown.find("a[data-ref=\"#{selection}\"]", match: :first)
|
|
|
|
dropdown.all("a[data-ref=\"#{selection}\"]").last.click
|
2016-09-27 13:29:12 -04:00
|
|
|
end
|
2016-06-29 06:24:58 -04:00
|
|
|
end
|