Commit e86cde7d authored by Tom Quirk's avatar Tom Quirk

Redo feature specs for service templates

In light of changes to service templates,
this commit updates/adds/removes
related specs.
parent 70b6e75b
......@@ -5,4 +5,4 @@
= sprite_icon('error', css_class: 'gl-alert-icon gl-alert-icon-no-title')
%h4.gl-alert-title= _('Service templates are deprecated and will be removed in GitLab 14.0.')
.gl-alert-body
= html_escape(s_("AdminSettings|You can't add new templates or edit existing ones. To migrate or remove a Service template, create a new integration at %{settings_link_start}Settings > Integrations%{link_end}. Learn more about %{doc_link_start}Project integration management%{link_end}.")) % { settings_link_start: settings_link_start, doc_link_start: doc_link_start, link_end: '</a>'.html_safe }
= html_escape(s_("AdminSettings|You can't add new templates. To migrate or remove a Service template, create a new integration at %{settings_link_start}Settings &gt; Integrations%{link_end}. Learn more about %{doc_link_start}Project integration management%{link_end}.")) % { settings_link_start: settings_link_start, doc_link_start: doc_link_start, link_end: '</a>'.html_safe }
......@@ -2352,7 +2352,7 @@ msgstr ""
msgid "AdminSettings|When creating a new environment variable it will be protected by default."
msgstr ""
msgid "AdminSettings|You can't add new templates or edit existing ones. To migrate or remove a Service template, create a new integration at %{settings_link_start}Settings > Integrations%{link_end}. Learn more about %{doc_link_start}Project integration management%{link_end}."
msgid "AdminSettings|You can't add new templates. To migrate or remove a Service template, create a new integration at %{settings_link_start}Settings &gt; Integrations%{link_end}. Learn more about %{doc_link_start}Project integration management%{link_end}."
msgstr ""
msgid "AdminStatistics|Active Users"
......
......@@ -251,6 +251,45 @@ RSpec.describe 'Admin updates settings' do
end
end
context 'when the Slack Notifications Service template is active' do
before do
create(:service, :template, type: 'SlackService', active: true)
visit general_admin_application_settings_path
end
it 'change Slack Notifications Service template settings', :js do
first(:link, 'Service Templates').click
click_link 'Slack notifications'
fill_in 'Webhook', with: 'http://localhost'
fill_in 'Username', with: 'test_user'
fill_in 'service[push_channel]', with: '#test_channel'
page.check('Notify only broken pipelines')
page.select 'All branches', from: 'Branches to be notified'
check_all_events
click_button 'Save changes'
expect(page).to have_content 'Application settings saved successfully'
click_link 'Slack notifications'
expect(page.all('input[type=checkbox]')).to all(be_checked)
expect(find_field('Webhook').value).to eq 'http://localhost'
expect(find_field('Username').value).to eq 'test_user'
expect(find('[name="service[push_channel]"]').value).to eq '#test_channel'
end
it 'defaults Deployment events to false for chat notification template settings', :js do
first(:link, 'Service Templates').click
click_link 'Slack notifications'
expect(find_field('Deployment')).not_to be_checked
end
end
context 'Integration page', :js do
before do
visit integrations_admin_application_settings_path
......
......@@ -9,23 +9,45 @@ RSpec.describe 'Admin visits service templates' do
before do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit(admin_application_settings_services_path)
end
context 'without instance-level integration' do
it 'shows a link to service template' do
expect(page).to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
context 'without an active service template' do
before do
visit(admin_application_settings_services_path)
end
it 'does not show service template content' do
expect(page).not_to have_content('Service template allows you to set default values for integrations')
end
end
context 'with instance-level integration' do
let_it_be(:slack_instance_integration) { create(:slack_service, instance: true, project: nil) }
context 'with an active service template' do
before do
create(:slack_service, :template, active: true)
visit(admin_application_settings_services_path)
end
it 'shows service template content' do
expect(page).to have_content('Service template allows you to set default values for integrations')
end
context 'without instance-level integration' do
it 'shows a link to service template' do
expect(page).to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
end
end
context 'with instance-level integration' do
before do
create(:slack_service, instance: true, project: nil)
visit(admin_application_settings_services_path)
end
it 'shows a link to instance-level integration' do
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
expect(page).to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
it 'shows a link to instance-level integration' do
expect(page).not_to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
expect(page).to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment