2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-05 08:43:03 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Dashboard Merge Requests' do
|
2018-04-03 06:27:56 -04:00
|
|
|
include Spec::Support::Helpers::Features::SortingHelpers
|
2018-10-28 23:03:43 -04:00
|
|
|
include FilteredSearchHelpers
|
2017-09-29 04:04:50 -04:00
|
|
|
include ProjectForksHelper
|
2017-06-25 04:14:07 -04:00
|
|
|
|
2017-04-05 08:43:03 -04:00
|
|
|
let(:current_user) { create :user }
|
2018-12-06 08:41:20 -05:00
|
|
|
let(:user) { current_user }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:public_project) { create(:project, :public, :repository) }
|
2017-09-29 04:04:50 -04:00
|
|
|
let(:forked_project) { fork_project(public_project, current_user, repository: true) }
|
2017-05-30 00:35:49 -04:00
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(current_user)
|
2017-06-25 04:14:07 -04:00
|
|
|
sign_in(current_user)
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
|
2020-10-12 11:08:32 -04:00
|
|
|
it 'disables target branch filter' do
|
|
|
|
visit merge_requests_dashboard_path
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('#js-dropdown-target-branch', visible: false)
|
|
|
|
end
|
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
context 'new merge request dropdown' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project_with_disabled_merge_requests) { create(:project, :merge_requests_disabled) }
|
2017-06-25 04:14:07 -04:00
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project_with_disabled_merge_requests.add_maintainer(current_user)
|
2017-06-14 14:18:56 -04:00
|
|
|
visit merge_requests_dashboard_path
|
|
|
|
end
|
2017-05-30 00:35:49 -04:00
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'shows projects only with merge requests feature enabled', :js do
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.new-project-item-select-button').click
|
2017-05-30 00:35:49 -04:00
|
|
|
|
|
|
|
page.within('.select2-results') do
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(page).to have_content(project.full_name)
|
|
|
|
expect(page).not_to have_content(project_with_disabled_merge_requests.full_name)
|
2017-05-30 00:35:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
context 'no merge requests exist' do
|
|
|
|
it 'shows an empty state' do
|
2018-10-28 23:03:43 -04:00
|
|
|
visit merge_requests_dashboard_path(assignee_username: current_user.username)
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
expect(page).to have_selector('.empty-state')
|
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
context 'merge requests exist' do
|
2020-11-23 13:09:14 -05:00
|
|
|
let_it_be(:author_user) { create(:user) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2019-04-04 10:54:25 -04:00
|
|
|
let(:label) { create(:label) }
|
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
let!(:assigned_merge_request) do
|
2017-08-04 13:14:04 -04:00
|
|
|
create(:merge_request,
|
2019-04-07 14:35:16 -04:00
|
|
|
assignees: [current_user],
|
2017-08-04 13:14:04 -04:00
|
|
|
source_project: project,
|
2020-11-23 13:09:14 -05:00
|
|
|
author: author_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:review_requested_merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
reviewers: [current_user],
|
|
|
|
source_branch: 'review',
|
|
|
|
source_project: project,
|
|
|
|
author: author_user)
|
2017-06-25 04:14:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:assigned_merge_request_from_fork) do
|
|
|
|
create(:merge_request,
|
2019-04-07 14:35:16 -04:00
|
|
|
source_branch: 'markdown', assignees: [current_user],
|
2017-08-04 13:14:04 -04:00
|
|
|
target_project: public_project, source_project: forked_project,
|
2020-11-23 13:09:14 -05:00
|
|
|
author: author_user)
|
2017-06-25 04:14:07 -04:00
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
let!(:authored_merge_request) do
|
|
|
|
create(:merge_request,
|
2017-08-04 13:14:04 -04:00
|
|
|
source_branch: 'markdown',
|
|
|
|
source_project: project,
|
|
|
|
author: current_user)
|
2017-06-25 04:14:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
let!(:authored_merge_request_from_fork) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_branch: 'feature_conflict',
|
|
|
|
author: current_user,
|
2017-08-04 13:14:04 -04:00
|
|
|
target_project: public_project, source_project: forked_project)
|
2017-06-25 04:14:07 -04:00
|
|
|
end
|
|
|
|
|
2019-04-04 10:54:25 -04:00
|
|
|
let!(:labeled_merge_request) do
|
|
|
|
create(:labeled_merge_request,
|
|
|
|
source_branch: 'labeled',
|
|
|
|
labels: [label],
|
|
|
|
author: current_user,
|
|
|
|
source_project: project)
|
|
|
|
end
|
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
let!(:other_merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_branch: 'fix',
|
2017-08-04 13:14:04 -04:00
|
|
|
source_project: project,
|
2020-11-23 13:09:14 -05:00
|
|
|
author: author_user)
|
2017-06-25 04:14:07 -04:00
|
|
|
end
|
|
|
|
|
2017-04-05 08:43:03 -04:00
|
|
|
before do
|
2018-10-28 23:03:43 -04:00
|
|
|
visit merge_requests_dashboard_path(assignee_username: current_user.username)
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
|
2021-01-04 19:10:20 -05:00
|
|
|
it 'includes assigned and reviewers in badge' do
|
|
|
|
expect(find('.merge-requests-count')).to have_content('3')
|
|
|
|
expect(find('.js-assigned-mr-count')).to have_content('2')
|
|
|
|
expect(find('.js-reviewer-mr-count')).to have_content('1')
|
|
|
|
end
|
|
|
|
|
2017-06-25 04:14:07 -04:00
|
|
|
it 'shows assigned merge requests' do
|
|
|
|
expect(page).to have_content(assigned_merge_request.title)
|
|
|
|
expect(page).to have_content(assigned_merge_request_from_fork.title)
|
|
|
|
|
|
|
|
expect(page).not_to have_content(authored_merge_request.title)
|
|
|
|
expect(page).not_to have_content(authored_merge_request_from_fork.title)
|
|
|
|
expect(page).not_to have_content(other_merge_request.title)
|
2019-04-04 10:54:25 -04:00
|
|
|
expect(page).not_to have_content(labeled_merge_request.title)
|
2017-06-25 04:14:07 -04:00
|
|
|
end
|
|
|
|
|
2020-11-23 13:09:14 -05:00
|
|
|
it 'does not show review requested merge requests' do
|
|
|
|
expect(page).not_to have_content(review_requested_merge_request.title)
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'shows authored merge requests', :js do
|
2018-10-28 23:03:43 -04:00
|
|
|
reset_filters
|
2020-03-04 04:08:20 -05:00
|
|
|
input_filtered_search("author:=#{current_user.to_reference}")
|
2017-06-25 04:14:07 -04:00
|
|
|
|
|
|
|
expect(page).to have_content(authored_merge_request.title)
|
|
|
|
expect(page).to have_content(authored_merge_request_from_fork.title)
|
2019-04-04 10:54:25 -04:00
|
|
|
expect(page).to have_content(labeled_merge_request.title)
|
|
|
|
|
|
|
|
expect(page).not_to have_content(assigned_merge_request.title)
|
|
|
|
expect(page).not_to have_content(assigned_merge_request_from_fork.title)
|
|
|
|
expect(page).not_to have_content(other_merge_request.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows labeled merge requests', :js do
|
|
|
|
reset_filters
|
2020-03-04 04:08:20 -05:00
|
|
|
input_filtered_search("label:=#{label.name}")
|
2017-06-25 04:14:07 -04:00
|
|
|
|
2019-04-04 10:54:25 -04:00
|
|
|
expect(page).to have_content(labeled_merge_request.title)
|
|
|
|
|
|
|
|
expect(page).not_to have_content(authored_merge_request.title)
|
|
|
|
expect(page).not_to have_content(authored_merge_request_from_fork.title)
|
2017-06-25 04:14:07 -04:00
|
|
|
expect(page).not_to have_content(assigned_merge_request.title)
|
|
|
|
expect(page).not_to have_content(assigned_merge_request_from_fork.title)
|
|
|
|
expect(page).not_to have_content(other_merge_request.title)
|
|
|
|
end
|
|
|
|
|
2018-03-27 11:29:13 -04:00
|
|
|
it 'shows error message without filter', :js do
|
2018-10-28 23:03:43 -04:00
|
|
|
reset_filters
|
2017-06-25 04:14:07 -04:00
|
|
|
|
2018-03-27 11:29:13 -04:00
|
|
|
expect(page).to have_content('Please select at least one filter to see results')
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
2017-07-14 09:36:37 -04:00
|
|
|
|
|
|
|
it 'shows sorted merge requests' do
|
2018-04-03 06:27:56 -04:00
|
|
|
sort_by('Created date')
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-10-28 23:03:43 -04:00
|
|
|
visit merge_requests_dashboard_path(assignee_username: current_user.username)
|
2017-07-14 09:36:37 -04:00
|
|
|
|
2017-09-22 20:46:53 -04:00
|
|
|
expect(find('.issues-filters')).to have_content('Created date')
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
|
2017-07-14 09:36:37 -04:00
|
|
|
it 'keeps sorting merge requests after visiting Projects MR page' do
|
2018-04-03 06:27:56 -04:00
|
|
|
sort_by('Created date')
|
2017-07-14 09:36:37 -04:00
|
|
|
|
|
|
|
visit project_merge_requests_path(project)
|
|
|
|
|
2017-09-22 20:46:53 -04:00
|
|
|
expect(find('.issues-filters')).to have_content('Created date')
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
end
|
2020-12-04 13:09:55 -05:00
|
|
|
|
|
|
|
context 'merge request review', :js do
|
|
|
|
let_it_be(:author_user) { create(:user) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2020-12-04 13:09:55 -05:00
|
|
|
let!(:review_requested_merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
reviewers: [current_user],
|
|
|
|
source_branch: 'review',
|
|
|
|
source_project: project,
|
|
|
|
author: author_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit merge_requests_dashboard_path(reviewer_username: current_user.username)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays review requested merge requests' do
|
|
|
|
expect(page).to have_content(review_requested_merge_request.title)
|
|
|
|
|
|
|
|
expect_tokens([reviewer_token(current_user.name)])
|
|
|
|
end
|
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|