1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Service Desk Setting', :js, :clean_gitlab_redis_cache, feature_category: :service_desk do
let_it_be_with_reload(:project) { create(:project_empty_repo, :private, service_desk_enabled: false) }
let(:presenter) { project.present(current_user: user) }
let_it_be_with_reload(:user) { create(:user) }
before do
project.add_maintainer(user)
sign_in(user)
allow_next_instance_of(Project) do |project|
allow(project).to receive(:present).with(current_user: user).and_return(presenter)
end
allow(::Gitlab::Email::IncomingEmail).to receive(:enabled?).and_return(true)
allow(::Gitlab::Email::IncomingEmail).to receive(:supports_wildcard?).and_return(true)
end
it 'shows activation checkbox' do
visit edit_project_path(project)
expect(page).to have_selector("#service-desk-checkbox")
end
context 'when service_desk_email is disabled' do
before do
allow(::Gitlab::Email::ServiceDeskEmail).to receive(:enabled?).and_return(false)
visit edit_project_path(project)
end
it 'shows incoming email but not project name suffix after activating' do
find("#service-desk-checkbox").click
wait_for_requests
project.reload
expect(project.service_desk_enabled).to be_truthy
expect(project.service_desk_address).to be_present
expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_incoming_address)
end
end
context 'when service_desk_email is enabled' do
before do
allow(::Gitlab::Email::ServiceDeskEmail).to receive(:enabled?).and_return(true)
allow(::Gitlab::Email::ServiceDeskEmail).to receive(:address_for_key).and_return('address-suffix@example.com')
visit edit_project_path(project)
end
it 'allows setting of custom address suffix' do
find("#service-desk-checkbox").click
wait_for_requests
project.reload
expect(find('[data-testid="incoming-email"]').value).to eq(project.service_desk_custom_address)
page.within '#js-service-desk' do
fill_in('service-desk-project-suffix', with: 'foo')
click_button 'Save changes'
end
wait_for_requests
expect(find('[data-testid="incoming-email"]').value).to eq('address-suffix@example.com')
end
describe 'issue description templates' do
let_it_be(:issuable_project_template_files) do
{
'.gitlab/issue_templates/project-issue-bar.md' => 'Project Issue Template Bar',
'.gitlab/issue_templates/project-issue-foo.md' => 'Project Issue Template Foo'
}
end
let_it_be(:issuable_group_template_files) do
{
'.gitlab/issue_templates/group-issue-bar.md' => 'Group Issue Template Bar',
'.gitlab/issue_templates/group-issue-foo.md' => 'Group Issue Template Foo'
}
end
let_it_be_with_reload(:group) { create(:group) }
let_it_be_with_reload(:project) do
create(:project, :custom_repo, group: group, files: issuable_project_template_files)
end
let_it_be(:group_template_repo) do
create(:project, :custom_repo, group: group, files: issuable_group_template_files)
end
before do
stub_licensed_features(custom_file_templates_for_namespace: false, custom_file_templates: false)
group.update_columns(file_template_project_id: group_template_repo.id)
visit edit_project_path(project)
end
it_behaves_like 'issue description templates from current project only'
end
end
it 'pushes service_desk_custom_email feature flag to frontend' do
visit edit_project_path(project)
expect(page).to have_pushed_frontend_feature_flags(serviceDeskCustomEmail: true)
end
end
|