2016-11-11 21:42:40 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'Filter merge requests' do
|
2017-02-15 22:13:53 +00:00
|
|
|
include FilteredSearchHelpers
|
|
|
|
include MergeRequestHelpers
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-07-26 21:52:10 +00:00
|
|
|
let!(:project) { create(:project, :repository) }
|
2016-11-11 21:42:40 +00:00
|
|
|
let!(:group) { create(:group) }
|
2017-02-15 22:13:53 +00:00
|
|
|
let!(:user) { create(:user) }
|
2016-11-11 21:42:40 +00:00
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
|
|
|
let!(:label) { create(:label, project: project) }
|
|
|
|
let!(:wontfix) { create(:label, project: project, title: "Won't fix") }
|
|
|
|
|
|
|
|
before do
|
2017-08-10 17:44:17 +00:00
|
|
|
project.add_master(user)
|
2016-11-11 21:42:40 +00:00
|
|
|
group.add_developer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2016-11-11 21:42:40 +00:00
|
|
|
create(:merge_request, source_project: project, target_project: project)
|
2017-02-15 22:13:53 +00:00
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'for assignee from mr#index' do
|
2017-02-15 22:13:53 +00:00
|
|
|
let(:search_query) { "assignee:@#{user.username}" }
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
def expect_assignee_visual_tokens
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([assignee_token(user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
|
|
|
end
|
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
before do
|
|
|
|
input_filtered_search(search_query)
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(0)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'assignee', :js do
|
2016-11-11 21:42:40 +00:00
|
|
|
it 'updates to current user' do
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_assignee_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not change when closed link is clicked' do
|
2017-06-07 15:54:54 +00:00
|
|
|
find('.issues-state-filters [data-state="closed"]').click
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_assignee_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not change when all link is clicked' do
|
2017-06-07 15:54:54 +00:00
|
|
|
find('.issues-state-filters [data-state="all"]').click
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_assignee_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'for milestone from mr#index' do
|
2017-01-30 22:53:18 +00:00
|
|
|
let(:search_query) { "milestone:%\"#{milestone.title}\"" }
|
|
|
|
|
|
|
|
def expect_milestone_visual_tokens
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([milestone_token("\"#{milestone.title}\"")])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
|
|
|
end
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
before do
|
|
|
|
input_filtered_search(search_query)
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(0)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'milestone', :js do
|
2016-11-11 21:42:40 +00:00
|
|
|
it 'updates to current milestone' do
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_milestone_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not change when closed link is clicked' do
|
2017-06-07 15:54:54 +00:00
|
|
|
find('.issues-state-filters [data-state="closed"]').click
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_milestone_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not change when all link is clicked' do
|
2017-06-07 15:54:54 +00:00
|
|
|
find('.issues-state-filters [data-state="all"]').click
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_milestone_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'for label from mr#index', :js do
|
2016-11-11 21:42:40 +00:00
|
|
|
it 'filters by no label' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('label:none')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(1)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([label_token('none', false)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by a label' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search("label:~#{label.title}")
|
|
|
|
|
|
|
|
expect_mr_list_count(0)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([label_token(label.title)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "filters by `won't fix` and another label" do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search("label:~\"#{wontfix.title}\" label:~#{label.title}")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(0)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([label_token("\"#{wontfix.title}\""), label_token(label.title)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "filters by `won't fix` label followed by another label after page load" do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search("label:~\"#{wontfix.title}\"")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(0)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([label_token("\"#{wontfix.title}\"")])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
input_filtered_search_keys("label:~#{label.title}")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(0)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([label_token("\"#{wontfix.title}\""), label_token(label.title)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-19 09:34:00 +00:00
|
|
|
describe 'for assignee and label from mr#index' do
|
2017-02-15 22:13:53 +00:00
|
|
|
let(:search_query) { "assignee:@#{user.username} label:~#{label.title}" }
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
before do
|
2017-07-19 09:34:00 +00:00
|
|
|
input_filtered_search(search_query)
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-07-19 09:34:00 +00:00
|
|
|
expect_mr_list_count(0)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'assignee and label', :js do
|
2017-01-30 22:53:18 +00:00
|
|
|
def expect_assignee_label_visual_tokens
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([assignee_token(user.name), label_token(label.title)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
|
|
|
end
|
|
|
|
|
2016-11-11 21:42:40 +00:00
|
|
|
it 'updates to current assignee and label' do
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_assignee_label_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not change when closed link is clicked' do
|
2017-06-07 15:54:54 +00:00
|
|
|
find('.issues-state-filters [data-state="closed"]').click
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_assignee_label_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not change when all link is clicked' do
|
2017-06-07 15:54:54 +00:00
|
|
|
find('.issues-state-filters [data-state="all"]').click
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_assignee_label_visual_tokens()
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'filter merge requests by text' do
|
|
|
|
before do
|
2017-08-10 17:44:17 +00:00
|
|
|
create(:merge_request, title: "Bug", source_project: project, target_project: project, source_branch: "wip")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
|
|
|
bug_label = create(:label, project: project, title: 'bug')
|
|
|
|
milestone = create(:milestone, title: "8", project: project)
|
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
mr = create(:merge_request,
|
|
|
|
title: "Bug 2",
|
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
2017-08-10 17:44:17 +00:00
|
|
|
source_branch: "fix",
|
2016-11-11 21:42:40 +00:00
|
|
|
milestone: milestone,
|
|
|
|
author: user,
|
|
|
|
assignee: user)
|
|
|
|
mr.labels << bug_label
|
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'only text', :js do
|
2016-11-11 21:42:40 +00:00
|
|
|
it 'filters merge requests by searched text' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(2)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show any merge requests' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('testing')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
|
|
|
page.within '.mr-list' do
|
|
|
|
expect(page).not_to have_selector('.merge-request')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'filters and searches', :js do
|
2016-11-11 21:42:40 +00:00
|
|
|
it 'filters by text and label' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(2)
|
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search_keys(' label:~bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(1)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([label_token('bug')])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by text and milestone' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(2)
|
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search_keys(' milestone:%8')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(1)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([milestone_token('8')])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by text and assignee' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(2)
|
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search_keys(" assignee:@#{user.username}")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(1)
|
2017-08-16 12:11:35 +00:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([assignee_token(user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by text and author' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(2)
|
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search_keys(" author:@#{user.username}")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(1)
|
2017-08-16 12:11:35 +00:00
|
|
|
expect_tokens([author_token(user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input('Bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-10 17:44:17 +00:00
|
|
|
describe 'filter merge requests and sort', :js do
|
2016-11-11 21:42:40 +00:00
|
|
|
before do
|
|
|
|
bug_label = create(:label, project: project, title: 'bug')
|
|
|
|
|
2017-08-10 17:44:17 +00:00
|
|
|
mr1 = create(:merge_request, title: "Frontend", source_project: project, target_project: project, source_branch: "wip")
|
|
|
|
mr2 = create(:merge_request, title: "Bug 2", source_project: project, target_project: project, source_branch: "fix")
|
2016-11-11 21:42:40 +00:00
|
|
|
|
|
|
|
mr1.labels << bug_label
|
|
|
|
mr2.labels << bug_label
|
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'is able to filter and sort merge requests' do
|
2017-02-15 22:13:53 +00:00
|
|
|
input_filtered_search('label:~bug')
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-02-15 22:13:53 +00:00
|
|
|
expect_mr_list_count(2)
|
2016-11-11 21:42:40 +00:00
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
click_button 'Created date'
|
2016-11-11 21:42:40 +00:00
|
|
|
page.within '.dropdown-menu-sort' do
|
2017-09-23 00:46:53 +00:00
|
|
|
click_link 'Priority'
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-11-11 21:42:40 +00:00
|
|
|
|
|
|
|
page.within '.mr-list' do
|
|
|
|
expect(page).to have_content('Frontend')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-02-15 22:13:53 +00:00
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'filter by assignee id', :js do
|
2017-02-15 22:13:53 +00:00
|
|
|
it 'filter by current user' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project, assignee_id: user.id)
|
2017-02-15 22:13:53 +00:00
|
|
|
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([assignee_token(user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2017-02-15 22:13:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filter by new user' do
|
|
|
|
new_user = create(:user)
|
|
|
|
project.add_developer(new_user)
|
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project, assignee_id: new_user.id)
|
2017-02-15 22:13:53 +00:00
|
|
|
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([assignee_token(new_user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2017-02-15 22:13:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'filter by author id', :js do
|
2017-02-15 22:13:53 +00:00
|
|
|
it 'filter by current user' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project, author_id: user.id)
|
2017-02-15 22:13:53 +00:00
|
|
|
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([author_token(user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2017-02-15 22:13:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'filter by new user' do
|
|
|
|
new_user = create(:user)
|
|
|
|
project.add_developer(new_user)
|
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project, author_id: new_user.id)
|
2017-02-15 22:13:53 +00:00
|
|
|
|
2017-08-16 12:11:35 +00:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect_tokens([author_token(new_user.name)])
|
2017-01-30 22:53:18 +00:00
|
|
|
expect_filtered_search_input_empty
|
2017-02-15 22:13:53 +00:00
|
|
|
end
|
|
|
|
end
|
2016-11-11 21:42:40 +00:00
|
|
|
end
|