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

123 lines
3.3 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2018-11-08 19:23:39 +05:30
describe 'Group empty states' do
2017-08-17 22:00:37 +05:30
let(:group) { create(:group) }
let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user }
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
[:issue, :merge_request].each do |issuable|
issuable_name = issuable.to_s.humanize.downcase
project_relation = issuable == :issue ? :project : :source_project
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context "for #{issuable_name}s" do
let(:path) { public_send(:"#{issuable}s_group_path", group) }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context 'group has a project' do
let(:project) { create(:project, namespace: group) }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
before do
project.add_master(user)
end
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context "the project has #{issuable_name}s" do
before do
create(issuable, project_relation => project)
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
visit path
end
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
it 'does not display an empty state' do
expect(page).not_to have_selector('.empty-state')
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-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
expect(page).to have_selector('.ajax-project-dropdown')
end
2017-08-17 22:00:37 +05:30
end
end
2018-11-08 19:23:39 +05:30
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-03-17 18:26:18 +05:30
context 'group without a project' do
context 'group has a subgroup', :nested_groups do
let(:subgroup) { create(:group, parent: group) }
let(:subgroup_project) { create(:project, namespace: subgroup) }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context "the project has #{issuable_name}s" do
before do
create(issuable, project_relation => subgroup_project)
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
visit path
end
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
it 'does not display an empty state' do
expect(page).not_to have_selector('.empty-state')
end
end
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
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-11-08 19:23:39 +05:30
it_behaves_like "no projects"
end
end
2018-03-17 18:26:18 +05:30
2018-11-08 19:23:39 +05:30
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-03-17 18:26:18 +05:30
end
2018-11-08 19:23:39 +05:30
it_behaves_like "no projects"
2017-08-17 22:00:37 +05:30
end
end
end
end