2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-05 08:43:03 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Group empty states' do
|
2017-04-05 08:43:03 -04:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user }
|
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
[:issue, :merge_request].each do |issuable|
|
|
|
|
issuable_name = issuable.to_s.humanize.downcase
|
|
|
|
project_relation = issuable == :issue ? :project : :source_project
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
context "for #{issuable_name}s" do
|
|
|
|
let(:path) { public_send(:"#{issuable}s_group_path", group) }
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
context 'group has a project' do
|
|
|
|
let(:project) { create(:project, namespace: group) }
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2018-02-23 07:10:57 -05:00
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
context "the project has #{issuable_name}s" do
|
2019-01-09 04:02:44 -05:00
|
|
|
it 'does not display an empty state' do
|
2018-02-23 07:10:57 -05:00
|
|
|
create(issuable, project_relation => project)
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
visit path
|
2019-01-09 04:02:44 -05:00
|
|
|
expect(page).not_to have_selector('.empty-state')
|
2018-02-23 07:10:57 -05:00
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2019-01-09 04:02:44 -05:00
|
|
|
it "displays link to create new #{issuable} when no open #{issuable} is found" do
|
|
|
|
create("closed_#{issuable}", project_relation => project)
|
|
|
|
issuable_link_fn = "project_#{issuable}s_path"
|
|
|
|
|
|
|
|
visit public_send(issuable_link_fn, project)
|
|
|
|
|
|
|
|
page.within(find('.empty-state')) do
|
|
|
|
expect(page).to have_content(/There are no open #{issuable.to_s.humanize.downcase}/)
|
|
|
|
expect(page).to have_selector("#new_#{issuable}_body_link")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays link to create new issue when the current search gave no results' do
|
|
|
|
create(issuable, project_relation => project)
|
|
|
|
|
|
|
|
issuable_link_fn = "project_#{issuable}s_path"
|
|
|
|
|
|
|
|
visit public_send(issuable_link_fn, project, author_username: 'foo', scope: 'all', state: 'opened')
|
|
|
|
|
|
|
|
page.within(find('.empty-state')) do
|
|
|
|
expect(page).to have_content(/Sorry, your filter produced no results/)
|
|
|
|
new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path'
|
|
|
|
|
|
|
|
path = public_send(new_issuable_path, project)
|
|
|
|
|
|
|
|
expect(page).to have_selector("#new_#{issuable}_body_link[href='#{path}']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "displays conditional text when no closed #{issuable} is found" do
|
|
|
|
create(issuable, project_relation => project)
|
|
|
|
|
|
|
|
issuable_link_fn = "project_#{issuable}s_path"
|
|
|
|
|
|
|
|
visit public_send(issuable_link_fn, project, state: 'closed')
|
|
|
|
|
|
|
|
page.within(find('.empty-state')) do
|
|
|
|
expect(page).to have_content(/There are no closed #{issuable.to_s.humanize.downcase}/)
|
|
|
|
end
|
2018-02-23 07:10:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "the project has no #{issuable_name}s", :js do
|
|
|
|
before do
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an empty state' do
|
|
|
|
expect(page).to have_selector('.empty-state')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows a new #{issuable_name} button" do
|
|
|
|
within '.empty-state' do
|
|
|
|
expect(page).to have_content("create #{issuable_name}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "the new #{issuable_name} button opens a project dropdown" do
|
|
|
|
within '.empty-state' do
|
|
|
|
find('.new-project-item-select-button').click
|
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
expect(page).to have_selector('.ajax-project-dropdown')
|
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-02 04:04:43 -04:00
|
|
|
shared_examples "no projects" do
|
|
|
|
it 'displays an empty state' do
|
|
|
|
expect(page).to have_selector('.empty-state')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not show a new #{issuable_name} button" do
|
|
|
|
within '.empty-state' do
|
|
|
|
expect(page).not_to have_link("create #{issuable_name}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
context 'group without a project' do
|
2019-07-24 05:20:54 -04:00
|
|
|
context 'group has a subgroup' do
|
2018-02-23 07:10:57 -05:00
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:subgroup_project) { create(:project, namespace: subgroup) }
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
context "the project has #{issuable_name}s" do
|
|
|
|
before do
|
|
|
|
create(issuable, project_relation => subgroup_project)
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
visit path
|
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
it 'does not display an empty state' do
|
|
|
|
expect(page).not_to have_selector('.empty-state')
|
|
|
|
end
|
|
|
|
end
|
2017-04-05 08:43:03 -04:00
|
|
|
|
2018-02-23 07:10:57 -05:00
|
|
|
context "the project has no #{issuable_name}s" do
|
|
|
|
before do
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays an empty state' do
|
|
|
|
expect(page).to have_selector('.empty-state')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'group has no subgroups' do
|
|
|
|
before do
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
2018-07-02 04:04:43 -04:00
|
|
|
it_behaves_like "no projects"
|
|
|
|
end
|
|
|
|
end
|
2018-02-23 07:10:57 -05:00
|
|
|
|
2018-07-02 04:04:43 -04:00
|
|
|
context 'group has only a project with issues disabled' do
|
|
|
|
let(:project_with_issues_disabled) { create(:empty_project, :issues_disabled, group: group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit path
|
2018-02-23 07:10:57 -05:00
|
|
|
end
|
2018-07-02 04:04:43 -04:00
|
|
|
|
|
|
|
it_behaves_like "no projects"
|
2017-04-05 08:43:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|