2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-26 13:34:06 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Group issues page' do
|
2017-08-02 05:27:24 -04:00
|
|
|
include FilteredSearchHelpers
|
2019-06-26 04:29:23 -04:00
|
|
|
include DragTo
|
2017-08-02 05:27:24 -04:00
|
|
|
|
2018-03-17 04:29:05 -04:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, :public, group: group)}
|
2018-07-02 04:04:43 -04:00
|
|
|
let(:project_with_issues_disabled) { create(:project, :issues_disabled, group: group) }
|
2018-03-17 04:29:05 -04:00
|
|
|
let(:path) { issues_group_path(group) }
|
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
context 'with shared examples', :js do
|
2018-01-24 01:06:24 -05:00
|
|
|
let(:issuable) { create(:issue, project: project, title: "this is my created issuable")}
|
2016-10-26 13:34:06 -04:00
|
|
|
|
2018-01-24 01:06:24 -05:00
|
|
|
include_examples 'project features apply to issuables', Issue
|
2017-02-28 15:50:57 -05:00
|
|
|
|
2018-01-24 01:06:24 -05:00
|
|
|
context 'rss feed' do
|
|
|
|
let(:access_level) { ProjectFeature::ENABLED }
|
2017-02-28 15:50:57 -05:00
|
|
|
|
2018-01-24 01:06:24 -05:00
|
|
|
context 'when signed in' do
|
2018-05-31 10:01:04 -04:00
|
|
|
let(:user) do
|
|
|
|
user_in_group.ensure_feed_token
|
|
|
|
user_in_group.save!
|
|
|
|
user_in_group
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
|
2020-07-31 11:10:14 -04:00
|
|
|
|
|
|
|
# Note: The one from rss_shared_example.rb uses a css pseudo-class `:has`
|
|
|
|
# which is VERY experimental and only supported in Nokogiri used by Capybara
|
|
|
|
# However,`:js` option forces Capybara to use Selenium that doesn't support`:has`
|
|
|
|
context "it has an RSS button with current_user's feed token" do
|
|
|
|
it "shows the RSS button with current_user's feed token" do
|
|
|
|
expect(find('[data-testid="rss-feed-link"]')['href']).to have_content(user.feed_token)
|
|
|
|
end
|
|
|
|
end
|
2018-01-24 01:06:24 -05:00
|
|
|
end
|
2017-02-28 15:50:57 -05:00
|
|
|
|
2018-01-24 01:06:24 -05:00
|
|
|
context 'when signed out' do
|
|
|
|
let(:user) { nil }
|
2017-02-28 15:50:57 -05:00
|
|
|
|
2018-05-31 10:01:04 -04:00
|
|
|
it_behaves_like "an autodiscoverable RSS feed without a feed token"
|
2020-07-31 11:10:14 -04:00
|
|
|
|
|
|
|
# Note: please see the above
|
|
|
|
context "it has an RSS button without a feed token" do
|
|
|
|
it "shows the RSS button without a feed token" do
|
|
|
|
expect(find('[data-testid="rss-feed-link"]')['href']).not_to have_content('feed_token')
|
|
|
|
end
|
|
|
|
end
|
2018-01-24 01:06:24 -05:00
|
|
|
end
|
2017-02-28 15:50:57 -05:00
|
|
|
end
|
2017-04-24 11:15:24 -04:00
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
context 'assignee' do
|
2018-01-24 01:06:24 -05:00
|
|
|
let(:access_level) { ProjectFeature::ENABLED }
|
|
|
|
let(:user) { user_in_group }
|
|
|
|
let(:user2) { user_outside_group }
|
|
|
|
|
|
|
|
it 'filters by only group users' do
|
2020-03-04 04:08:20 -05:00
|
|
|
filtered_search.set('assignee:=')
|
2017-04-24 11:15:24 -04:00
|
|
|
|
2018-01-24 01:06:24 -05:00
|
|
|
expect(find('#js-dropdown-assignee .filter-dropdown')).to have_content(user.name)
|
|
|
|
expect(find('#js-dropdown-assignee .filter-dropdown')).not_to have_content(user2.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-24 11:15:24 -04:00
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
context 'issues list', :js do
|
2018-01-24 01:06:24 -05:00
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:subgroup_project) { create(:project, :public, group: subgroup)}
|
2018-08-02 15:39:46 -04:00
|
|
|
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
|
2018-01-24 01:06:24 -05:00
|
|
|
let!(:issue) { create(:issue, project: project, title: 'root group issue') }
|
|
|
|
let!(:subgroup_issue) { create(:issue, project: subgroup_project, title: 'subgroup issue') }
|
|
|
|
|
|
|
|
it 'returns all group and subgroup issues' do
|
|
|
|
visit issues_group_path(group)
|
|
|
|
|
|
|
|
page.within('.issuable-list') do
|
|
|
|
expect(page).to have_selector('li.issue', count: 2)
|
|
|
|
expect(page).to have_content('root group issue')
|
|
|
|
expect(page).to have_content('subgroup issue')
|
|
|
|
end
|
2017-04-24 11:15:24 -04:00
|
|
|
end
|
2018-03-17 04:29:05 -04:00
|
|
|
|
|
|
|
context 'when project is archived' do
|
|
|
|
before do
|
2018-08-02 15:39:46 -04:00
|
|
|
::Projects::UpdateService.new(project, user_in_group, archived: true).execute
|
2018-03-17 04:29:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not render issue' do
|
|
|
|
visit path
|
|
|
|
|
|
|
|
expect(page).not_to have_content issue.title[0..80]
|
|
|
|
end
|
|
|
|
end
|
2017-04-24 11:15:24 -04:00
|
|
|
end
|
2018-07-02 04:04:43 -04:00
|
|
|
|
|
|
|
context 'projects with issues disabled' do
|
|
|
|
describe 'issue dropdown' do
|
2018-07-11 10:36:08 -04:00
|
|
|
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
|
2018-07-02 04:04:43 -04:00
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
[project, project_with_issues_disabled].each { |project| project.add_maintainer(user_in_group) }
|
2018-07-02 04:04:43 -04:00
|
|
|
sign_in(user_in_group)
|
|
|
|
visit issues_group_path(group)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows projects only with issues feature enabled', :js do
|
2019-10-18 07:11:44 -04:00
|
|
|
find('.empty-state .js-lazy-loaded')
|
2018-07-02 04:04:43 -04:00
|
|
|
find('.new-project-item-link').click
|
|
|
|
|
|
|
|
page.within('.select2-results') do
|
|
|
|
expect(page).to have_content(project.full_name)
|
|
|
|
expect(page).not_to have_content(project_with_issues_disabled.full_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-06-26 04:29:23 -04:00
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
context 'manual ordering', :js do
|
2019-06-26 17:51:53 -04:00
|
|
|
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
|
|
|
|
|
2019-06-26 11:44:41 -04:00
|
|
|
let!(:issue1) { create(:issue, project: project, title: 'Issue #1', relative_position: 1) }
|
|
|
|
let!(:issue2) { create(:issue, project: project, title: 'Issue #2', relative_position: 2) }
|
|
|
|
let!(:issue3) { create(:issue, project: project, title: 'Issue #3', relative_position: 3) }
|
2019-06-26 04:29:23 -04:00
|
|
|
|
2019-06-26 17:51:53 -04:00
|
|
|
before do
|
|
|
|
sign_in(user_in_group)
|
|
|
|
end
|
|
|
|
|
2019-06-26 04:29:23 -04:00
|
|
|
it 'displays all issues' do
|
|
|
|
visit issues_group_path(group, sort: 'relative_position')
|
|
|
|
|
|
|
|
page.within('.issues-list') do
|
|
|
|
expect(page).to have_selector('li.issue', count: 3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has manual-ordering css applied' do
|
|
|
|
visit issues_group_path(group, sort: 'relative_position')
|
|
|
|
|
|
|
|
expect(page).to have_selector('.manual-ordering')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'each issue item has a user-can-drag css applied' do
|
|
|
|
visit issues_group_path(group, sort: 'relative_position')
|
|
|
|
|
|
|
|
page.within('.manual-ordering') do
|
|
|
|
expect(page).to have_selector('.issue.user-can-drag', count: 3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
it 'issues should be draggable and persist order' do
|
2019-06-26 04:29:23 -04:00
|
|
|
visit issues_group_path(group, sort: 'relative_position')
|
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2019-06-26 04:29:23 -04:00
|
|
|
drag_to(selector: '.manual-ordering',
|
|
|
|
from_index: 0,
|
2019-06-26 11:44:41 -04:00
|
|
|
to_index: 2)
|
2019-06-26 06:58:10 -04:00
|
|
|
|
2019-06-26 17:51:53 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
check_issue_order
|
|
|
|
|
|
|
|
visit issues_group_path(group, sort: 'relative_position')
|
|
|
|
|
|
|
|
check_issue_order
|
|
|
|
end
|
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
it 'issues should not be draggable when user is not logged in' do
|
2019-07-02 08:33:45 -04:00
|
|
|
sign_out(user_in_group)
|
|
|
|
|
|
|
|
visit issues_group_path(group, sort: 'relative_position')
|
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
2019-07-02 08:33:45 -04:00
|
|
|
drag_to(selector: '.manual-ordering',
|
|
|
|
from_index: 0,
|
|
|
|
to_index: 2)
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
# Issue order should remain the same
|
|
|
|
page.within('.manual-ordering') do
|
|
|
|
expect(find('.issue:nth-child(1) .title')).to have_content('Issue #1')
|
|
|
|
expect(find('.issue:nth-child(2) .title')).to have_content('Issue #2')
|
|
|
|
expect(find('.issue:nth-child(3) .title')).to have_content('Issue #3')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-26 17:51:53 -04:00
|
|
|
def check_issue_order
|
2019-06-26 04:29:23 -04:00
|
|
|
page.within('.manual-ordering') do
|
|
|
|
expect(find('.issue:nth-child(1) .title')).to have_content('Issue #2')
|
2019-06-26 06:58:10 -04:00
|
|
|
expect(find('.issue:nth-child(2) .title')).to have_content('Issue #3')
|
|
|
|
expect(find('.issue:nth-child(3) .title')).to have_content('Issue #1')
|
2019-06-26 04:29:23 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-05-12 17:08:14 -04:00
|
|
|
|
2020-07-31 11:10:14 -04:00
|
|
|
context 'issues pagination', :js do
|
2020-05-12 17:08:14 -04:00
|
|
|
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
|
|
|
|
|
|
|
|
let!(:issues) do
|
|
|
|
(1..25).to_a.map { |index| create(:issue, project: project, title: "Issue #{index}") }
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user_in_group)
|
|
|
|
visit issues_group_path(group)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pagination' do
|
|
|
|
expect(page).to have_selector('.gl-pagination')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'first pagination item is active' do
|
2020-07-31 11:10:14 -04:00
|
|
|
page.within('.gl-pagination') do
|
|
|
|
expect(find('.active')).to have_content('1')
|
|
|
|
end
|
2020-05-12 17:08:14 -04:00
|
|
|
end
|
|
|
|
end
|
2016-10-26 13:34:06 -04:00
|
|
|
end
|