debian-mirror-gitlab/spec/features/groups/issues_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

223 lines
6.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2016-11-24 13:41:30 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Group issues page', feature_category: :subgroups do
2017-09-10 17:25:29 +05:30
include FilteredSearchHelpers
2019-09-30 21:07:59 +05:30
include DragTo
2017-09-10 17:25:29 +05:30
2018-05-09 12:01:36 +05:30
let(:group) { create(:group) }
2022-08-27 11:52:29 +05:30
let(:project) { create(:project, :public, group: group) }
2018-11-08 19:23:39 +05:30
let(:project_with_issues_disabled) { create(:project, :issues_disabled, group: group) }
2018-05-09 12:01:36 +05:30
let(:path) { issues_group_path(group) }
2023-03-04 22:38:38 +05:30
before do
stub_feature_flags(or_issuable_queries: false)
end
2020-10-24 23:57:45 +05:30
context 'with shared examples', :js do
2022-08-27 11:52:29 +05:30
let(:issuable) { create(:issue, project: project, title: "this is my created issuable") }
2016-11-24 13:41:30 +05:30
2018-03-17 18:26:18 +05:30
include_examples 'project features apply to issuables', Issue
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context 'rss feed' do
let(:access_level) { ProjectFeature::ENABLED }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context 'when signed in' do
2018-11-08 19:23:39 +05:30
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-10-24 23:57:45 +05:30
# 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
2021-11-11 11:23:49 +05:30
expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=#{user.feed_token}/
2020-10-24 23:57:45 +05:30
end
end
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context 'when signed out' do
let(:user) { nil }
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
it_behaves_like "an autodiscoverable RSS feed without a feed token"
2020-10-24 23:57:45 +05:30
# 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
2021-11-11 11:23:49 +05:30
expect(page).not_to have_link 'Subscribe to RSS feed', href: /feed_token/
2020-10-24 23:57:45 +05:30
end
end
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
end
2020-10-24 23:57:45 +05:30
context 'assignee' do
2018-03-17 18:26:18 +05:30
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
let(:user2) { user_outside_group }
it 'filters by only group users' do
2022-07-16 23:28:13 +05:30
select_tokens 'Assignee', '='
2017-08-17 22:00:37 +05:30
2022-07-16 23:28:13 +05:30
expect_suggestion(user.name)
expect_no_suggestion(user2.name)
2018-03-17 18:26:18 +05:30
end
end
end
2017-08-17 22:00:37 +05:30
2020-10-24 23:57:45 +05:30
context 'issues list', :js do
2018-03-17 18:26:18 +05:30
let(:subgroup) { create(:group, parent: group) }
2022-08-27 11:52:29 +05:30
let(:subgroup_project) { create(:project, :public, group: subgroup) }
2023-01-13 00:05:48 +05:30
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user }
2018-03-17 18:26:18 +05:30
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)
2022-07-16 23:28:13 +05:30
expect(page).to have_selector('li.issue', count: 2)
expect(page).to have_content('root group issue')
expect(page).to have_content('subgroup issue')
2021-12-11 22:18:48 +05:30
end
2018-05-09 12:01:36 +05:30
context 'when project is archived' do
before do
2018-11-18 11:00:15 +05:30
::Projects::UpdateService.new(project, user_in_group, archived: true).execute
2018-05-09 12:01:36 +05:30
end
it 'does not render issue' do
visit path
expect(page).not_to have_content issue.title[0..80]
end
end
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
2022-05-07 20:08:51 +05:30
context 'group with no issues', :js do
let!(:group_with_no_issues) { create(:group) }
let!(:subgroup_with_issues) { create(:group, parent: group_with_no_issues) }
let!(:subgroup_project) { create(:project, :public, group: subgroup_with_issues) }
let!(:subgroup_issue) { create(:issue, project: subgroup_project) }
before do
visit issues_group_path(group_with_no_issues)
end
it 'shows issues from subgroups on issues list' do
expect(page).to have_text subgroup_issue.title
end
end
2018-11-08 19:23:39 +05:30
context 'projects with issues disabled' do
describe 'issue dropdown' do
2023-01-13 00:05:48 +05:30
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user }
2018-11-08 19:23:39 +05:30
before do
2018-11-18 11:00:15 +05:30
[project, project_with_issues_disabled].each { |project| project.add_maintainer(user_in_group) }
2018-11-08 19:23:39 +05:30
sign_in(user_in_group)
visit issues_group_path(group)
end
it 'shows projects only with issues feature enabled', :js do
2022-07-16 23:28:13 +05:30
click_button 'Toggle project select'
2018-11-08 19:23:39 +05:30
2022-07-16 23:28:13 +05:30
expect(page).to have_button project.full_name
expect(page).not_to have_button project_with_issues_disabled.full_name
2018-11-08 19:23:39 +05:30
end
end
end
2019-09-30 21:07:59 +05:30
2020-10-24 23:57:45 +05:30
context 'manual ordering', :js do
2023-01-13 00:05:48 +05:30
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user }
2019-09-30 21:07:59 +05:30
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) }
before do
sign_in(user_in_group)
end
it 'displays all issues' do
visit issues_group_path(group, sort: 'relative_position')
2022-07-16 23:28:13 +05:30
expect(page).to have_selector('li.issue', count: 3)
2019-09-30 21:07:59 +05:30
end
it 'has manual-ordering css applied' do
visit issues_group_path(group, sort: 'relative_position')
expect(page).to have_selector('.manual-ordering')
end
2022-03-02 08:16:31 +05:30
it 'each issue item has a gl-cursor-grab css applied' do
2019-09-30 21:07:59 +05:30
visit issues_group_path(group, sort: 'relative_position')
2022-03-02 08:16:31 +05:30
expect(page).to have_selector('.issue.gl-cursor-grab', count: 3)
2019-09-30 21:07:59 +05:30
end
2020-10-24 23:57:45 +05:30
it 'issues should be draggable and persist order' do
2022-07-23 23:45:48 +05:30
visit issues_group_path(group)
select_manual_sort
2020-10-24 23:57:45 +05:30
2023-01-13 00:05:48 +05:30
wait_for_requests
2022-07-23 23:45:48 +05:30
drag_to(selector: '.manual-ordering', from_index: 0, to_index: 2)
2019-09-30 21:07:59 +05:30
2022-07-23 23:45:48 +05:30
expect_issue_order
2019-09-30 21:07:59 +05:30
2022-07-23 23:45:48 +05:30
visit issues_group_path(group)
2019-09-30 21:07:59 +05:30
2022-07-23 23:45:48 +05:30
expect_issue_order
2019-09-30 21:07:59 +05:30
end
2020-10-24 23:57:45 +05:30
it 'issues should not be draggable when user is not logged in' do
2019-09-30 21:07:59 +05:30
sign_out(user_in_group)
2020-10-24 23:57:45 +05:30
wait_for_requests
2022-07-23 23:45:48 +05:30
visit issues_group_path(group)
select_manual_sort
2020-10-24 23:57:45 +05:30
2023-01-13 00:05:48 +05:30
wait_for_requests
2022-07-23 23:45:48 +05:30
drag_to(selector: '.manual-ordering', from_index: 0, to_index: 2)
2019-09-30 21:07:59 +05:30
2022-07-23 23:45:48 +05:30
expect(page).to have_text 'An error occurred while reordering issues.'
end
2019-09-30 21:07:59 +05:30
2022-07-23 23:45:48 +05:30
def select_manual_sort
click_button 'Created date'
click_button 'Manual'
wait_for_requests
2019-09-30 21:07:59 +05:30
end
2022-07-23 23:45:48 +05:30
def expect_issue_order
2022-07-16 23:28:13 +05:30
expect(page).to have_css('.issue:nth-child(1) .title', text: 'Issue #2')
expect(page).to have_css('.issue:nth-child(2) .title', text: 'Issue #3')
expect(page).to have_css('.issue:nth-child(3) .title', text: 'Issue #1')
2019-09-30 21:07:59 +05:30
end
end
2020-05-24 23:13:21 +05:30
2020-10-24 23:57:45 +05:30
context 'issues pagination', :js do
2023-01-13 00:05:48 +05:30
let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user }
2020-05-24 23:13:21 +05:30
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
2022-07-16 23:28:13 +05:30
expect(page).to have_button 'Prev', disabled: true
expect(page).to have_button 'Next'
2020-05-24 23:13:21 +05:30
end
end
2016-11-24 13:41:30 +05:30
end