debian-mirror-gitlab/spec/features/dashboard/merge_requests_spec.rb

163 lines
5.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Dashboard Merge Requests' do
2018-05-09 12:01:36 +05:30
include Spec::Support::Helpers::Features::SortingHelpers
2019-02-15 15:39:39 +05:30
include FilteredSearchHelpers
2018-03-17 18:26:18 +05:30
include ProjectForksHelper
2017-09-10 17:25:29 +05:30
2017-08-17 22:00:37 +05:30
let(:current_user) { create :user }
2019-02-15 15:39:39 +05:30
let(:user) { current_user }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
let(:public_project) { create(:project, :public, :repository) }
2018-03-17 18:26:18 +05:30
let(:forked_project) { fork_project(public_project, current_user, repository: true) }
2017-08-17 22:00:37 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(current_user)
2017-09-10 17:25:29 +05:30
sign_in(current_user)
end
2021-01-03 14:25:43 +05:30
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-09-10 17:25:29 +05:30
context 'new merge request dropdown' do
let(:project_with_disabled_merge_requests) { create(:project, :merge_requests_disabled) }
before do
2018-11-18 11:00:15 +05:30
project_with_disabled_merge_requests.add_maintainer(current_user)
2017-09-10 17:25:29 +05:30
visit merge_requests_dashboard_path
end
2018-03-17 18:26:18 +05:30
it 'shows projects only with merge requests feature enabled', :js do
find('.new-project-item-select-button').click
2017-09-10 17:25:29 +05:30
page.within('.select2-results') do
2018-03-27 19:54:05 +05:30
expect(page).to have_content(project.full_name)
expect(page).not_to have_content(project_with_disabled_merge_requests.full_name)
2017-09-10 17:25:29 +05:30
end
end
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
context 'no merge requests exist' do
it 'shows an empty state' do
2019-02-15 15:39:39 +05:30
visit merge_requests_dashboard_path(assignee_username: current_user.username)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(page).to have_selector('.empty-state')
end
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
context 'merge requests exist' do
2019-07-07 11:18:12 +05:30
let(:label) { create(:label) }
2017-09-10 17:25:29 +05:30
let!(:assigned_merge_request) do
2018-03-17 18:26:18 +05:30
create(:merge_request,
2019-07-31 22:56:46 +05:30
assignees: [current_user],
2018-03-17 18:26:18 +05:30
source_project: project,
author: create(:user))
2017-09-10 17:25:29 +05:30
end
let!(:assigned_merge_request_from_fork) do
create(:merge_request,
2019-07-31 22:56:46 +05:30
source_branch: 'markdown', assignees: [current_user],
2018-03-17 18:26:18 +05:30
target_project: public_project, source_project: forked_project,
author: create(:user))
2017-09-10 17:25:29 +05:30
end
let!(:authored_merge_request) do
create(:merge_request,
2018-03-17 18:26:18 +05:30
source_branch: 'markdown',
source_project: project,
author: current_user)
2017-09-10 17:25:29 +05:30
end
let!(:authored_merge_request_from_fork) do
create(:merge_request,
source_branch: 'feature_conflict',
author: current_user,
2018-03-17 18:26:18 +05:30
target_project: public_project, source_project: forked_project)
2017-09-10 17:25:29 +05:30
end
2019-07-07 11:18:12 +05:30
let!(:labeled_merge_request) do
create(:labeled_merge_request,
source_branch: 'labeled',
labels: [label],
author: current_user,
source_project: project)
end
2017-09-10 17:25:29 +05:30
let!(:other_merge_request) do
create(:merge_request,
source_branch: 'fix',
2018-03-17 18:26:18 +05:30
source_project: project,
author: create(:user))
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
before do
2019-02-15 15:39:39 +05:30
visit merge_requests_dashboard_path(assignee_username: current_user.username)
2017-09-10 17:25:29 +05:30
end
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-07-07 11:18:12 +05:30
expect(page).not_to have_content(labeled_merge_request.title)
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
it 'shows authored merge requests', :js do
2019-02-15 15:39:39 +05:30
reset_filters
2020-04-08 14:13:33 +05:30
input_filtered_search("author:=#{current_user.to_reference}")
2017-09-10 17:25:29 +05:30
expect(page).to have_content(authored_merge_request.title)
expect(page).to have_content(authored_merge_request_from_fork.title)
2019-07-07 11:18:12 +05:30
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-04-08 14:13:33 +05:30
input_filtered_search("label:=#{label.name}")
2017-09-10 17:25:29 +05:30
2019-07-07 11:18:12 +05:30
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-09-10 17:25:29 +05:30
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-05-09 12:01:36 +05:30
it 'shows error message without filter', :js do
2019-02-15 15:39:39 +05:30
reset_filters
2017-09-10 17:25:29 +05:30
2018-05-09 12:01:36 +05:30
expect(page).to have_content('Please select at least one filter to see results')
2017-09-10 17:25:29 +05:30
end
it 'shows sorted merge requests' do
2018-05-09 12:01:36 +05:30
sort_by('Created date')
2017-08-17 22:00:37 +05:30
2019-02-15 15:39:39 +05:30
visit merge_requests_dashboard_path(assignee_username: current_user.username)
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
expect(find('.issues-filters')).to have_content('Created date')
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
it 'keeps sorting merge requests after visiting Projects MR page' do
2018-05-09 12:01:36 +05:30
sort_by('Created date')
2017-09-10 17:25:29 +05:30
visit project_merge_requests_path(project)
2018-03-17 18:26:18 +05:30
expect(find('.issues-filters')).to have_content('Created date')
2017-08-17 22:00:37 +05:30
end
end
end