Commit 4962d32d authored by Thong Kuah's avatar Thong Kuah

Merge branch '328682-field-labels-should-be-sentence-case' into 'master'

Use sentence case for trigger events on the integrations form

See merge request gitlab-org/gitlab!80899
parents 8908711a a0ff8f3c
<script> <script>
import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui';
import { startCase } from 'lodash';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -45,7 +44,6 @@ export default { ...@@ -45,7 +44,6 @@ export default {
fieldName(name) { fieldName(name) {
return `service[${name}]`; return `service[${name}]`;
}, },
startCase,
}, },
}; };
</script> </script>
...@@ -58,10 +56,10 @@ export default { ...@@ -58,10 +56,10 @@ export default {
data-testid="trigger-fields-group" data-testid="trigger-fields-group"
> >
<div id="trigger-fields" class="gl-pt-3"> <div id="trigger-fields" class="gl-pt-3">
<gl-form-group v-for="event in events" :key="event.title" :description="event.description"> <gl-form-group v-for="event in events" :key="event.name" :description="event.description">
<input :name="checkboxName(event.name)" type="hidden" :value="event.value || false" /> <input :name="checkboxName(event.name)" type="hidden" :value="event.value || false" />
<gl-form-checkbox v-model="event.value" :disabled="isInheriting"> <gl-form-checkbox v-model="event.value" :disabled="isInheriting">
{{ startCase(event.title) }} {{ event.title }}
</gl-form-checkbox> </gl-form-checkbox>
<gl-form-input <gl-form-input
v-if="event.field" v-if="event.field"
......
# frozen_string_literal: true # frozen_string_literal: true
module IntegrationsHelper module IntegrationsHelper
def integration_event_title(event)
case event
when "push", "push_events"
_("Push")
when "tag_push", "tag_push_events"
_("Tag push")
when "note", "note_events"
_("Note")
when "confidential_note", "confidential_note_events"
_("Confidential note")
when "issue", "issue_events"
_("Issue")
when "confidential_issue", "confidential_issue_events"
_("Confidential issue")
when "merge_request", "merge_request_events"
_("Merge request")
when "pipeline", "pipeline_events"
_("Pipeline")
when "wiki_page", "wiki_page_events"
_("Wiki page")
when "commit", "commit_events"
_("Commit")
when "deployment"
_("Deployment")
when "alert"
_("Alert")
end
end
def integration_event_description(integration, event) def integration_event_description(integration, event)
case integration case integration
when Integrations::Jira when Integrations::Jira
......
...@@ -4,7 +4,7 @@ class ServiceEventEntity < Grape::Entity ...@@ -4,7 +4,7 @@ class ServiceEventEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
expose :title do |event| expose :title do |event|
event IntegrationsHelper.integration_event_title(event)
end end
expose :event_field_name, as: :name expose :event_field_name, as: :name
......
...@@ -56,6 +56,13 @@ module EE ...@@ -56,6 +56,13 @@ module EE
} }
end end
override :integration_event_title
def integration_event_title(event)
return _('Vulnerability') if event == 'vulnerability'
super
end
override :default_integration_event_description override :default_integration_event_description
def default_integration_event_description(event) def default_integration_event_description(event)
return s_("ProjectService|Trigger event when a new, unique vulnerability is recorded. (Note: This feature requires an Ultimate plan.)") if event == 'vulnerability' return s_("ProjectService|Trigger event when a new, unique vulnerability is recorded. (Note: This feature requires an Ultimate plan.)") if event == 'vulnerability'
......
...@@ -3150,6 +3150,9 @@ msgstr "" ...@@ -3150,6 +3150,9 @@ msgstr ""
msgid "Akismet helps prevent the creation of spam issues in public projects." msgid "Akismet helps prevent the creation of spam issues in public projects."
msgstr "" msgstr ""
msgid "Alert"
msgstr ""
msgid "AlertManagement|Acknowledged" msgid "AlertManagement|Acknowledged"
msgstr "" msgstr ""
...@@ -9110,6 +9113,12 @@ msgstr "" ...@@ -9110,6 +9113,12 @@ msgstr ""
msgid "Confidential" msgid "Confidential"
msgstr "" msgstr ""
msgid "Confidential issue"
msgstr ""
msgid "Confidential note"
msgstr ""
msgid "Confidentiality" msgid "Confidentiality"
msgstr "" msgstr ""
...@@ -12194,6 +12203,9 @@ msgstr "" ...@@ -12194,6 +12203,9 @@ msgstr ""
msgid "Deploying to AWS is easy with GitLab" msgid "Deploying to AWS is easy with GitLab"
msgstr "" msgstr ""
msgid "Deployment"
msgstr ""
msgid "Deployment Frequency" msgid "Deployment Frequency"
msgstr "" msgstr ""
...@@ -35822,6 +35834,9 @@ msgstr "" ...@@ -35822,6 +35834,9 @@ msgstr ""
msgid "Tag name is required" msgid "Tag name is required"
msgstr "" msgstr ""
msgid "Tag push"
msgstr ""
msgid "Tag push events" msgid "Tag push events"
msgstr "" msgstr ""
...@@ -40564,6 +40579,9 @@ msgstr "" ...@@ -40564,6 +40579,9 @@ msgstr ""
msgid "Vulnerabilities over time" msgid "Vulnerabilities over time"
msgstr "" msgstr ""
msgid "Vulnerability"
msgstr ""
msgid "Vulnerability Report" msgid "Vulnerability Report"
msgstr "" msgstr ""
...@@ -41373,6 +41391,9 @@ msgstr "" ...@@ -41373,6 +41391,9 @@ msgstr ""
msgid "Wiki" msgid "Wiki"
msgstr "" msgstr ""
msgid "Wiki page"
msgstr ""
msgid "Wiki page was successfully created." msgid "Wiki page was successfully created."
msgstr "" msgstr ""
......
...@@ -12,7 +12,7 @@ RSpec.describe 'User activates JetBrains TeamCity CI' do ...@@ -12,7 +12,7 @@ RSpec.describe 'User activates JetBrains TeamCity CI' do
it 'activates integration', :js do it 'activates integration', :js do
visit_project_integration('JetBrains TeamCity') visit_project_integration('JetBrains TeamCity')
check('Push') check('Push')
check('Merge Request') check('Merge request')
fill_in('TeamCity server URL', with: 'http://teamcity.example.com') fill_in('TeamCity server URL', with: 'http://teamcity.example.com')
fill_in('Build type', with: 'GitlabTest_Build') fill_in('Build type', with: 'GitlabTest_Build')
fill_in('Username', with: 'user') fill_in('Username', with: 'user')
......
...@@ -40,13 +40,13 @@ describe('TriggerFields', () => { ...@@ -40,13 +40,13 @@ describe('TriggerFields', () => {
describe('events without field property', () => { describe('events without field property', () => {
const events = [ const events = [
{ {
title: 'push', title: 'Push',
name: 'push_event', name: 'push_event',
description: 'Event on push', description: 'Event on push',
value: true, value: true,
}, },
{ {
title: 'merge_request', title: 'Merge request',
name: 'merge_requests_event', name: 'merge_requests_event',
description: 'Event on merge_request', description: 'Event on merge_request',
value: false, value: false,
...@@ -81,7 +81,7 @@ describe('TriggerFields', () => { ...@@ -81,7 +81,7 @@ describe('TriggerFields', () => {
const checkboxes = findAllGlFormGroups(); const checkboxes = findAllGlFormGroups();
const expectedResults = [ const expectedResults = [
{ labelText: 'Push', inputName: 'service[push_event]' }, { labelText: 'Push', inputName: 'service[push_event]' },
{ labelText: 'Merge Request', inputName: 'service[merge_requests_event]' }, { labelText: 'Merge request', inputName: 'service[merge_requests_event]' },
]; ];
expect(checkboxes).toHaveLength(2); expect(checkboxes).toHaveLength(2);
......
...@@ -3,17 +3,41 @@ ...@@ -3,17 +3,41 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe IntegrationsHelper do RSpec.describe IntegrationsHelper do
shared_examples 'is defined for each integration event' do
Integration.available_integration_names.each do |integration|
events = Integration.integration_name_to_model(integration).new.configurable_events
events.each do |event|
context "when integration is #{integration}, event is #{event}" do
let(:integration) { integration }
let(:event) { event }
it { is_expected.not_to be_nil }
end
end
end
end
describe '#integration_event_title' do
subject { helper.integration_event_title(event) }
it_behaves_like 'is defined for each integration event'
end
describe '#integration_event_description' do describe '#integration_event_description' do
subject(:description) { helper.integration_event_description(integration, 'merge_request_events') } subject { helper.integration_event_description(integration, event) }
it_behaves_like 'is defined for each integration event'
context 'when integration is Jira' do context 'when integration is Jira' do
let(:integration) { Integrations::Jira.new } let(:integration) { Integrations::Jira.new }
let(:event) { 'merge_request_events' }
it { is_expected.to include('Jira') } it { is_expected.to include('Jira') }
end end
context 'when integration is Team City' do context 'when integration is Team City' do
let(:integration) { Integrations::Teamcity.new } let(:integration) { Integrations::Teamcity.new }
let(:event) { 'merge_request_events' }
it { is_expected.to include('TeamCity') } it { is_expected.to include('TeamCity') }
end end
......
...@@ -19,7 +19,7 @@ RSpec.describe ServiceEventEntity do ...@@ -19,7 +19,7 @@ RSpec.describe ServiceEventEntity do
it 'exposes correct attributes' do it 'exposes correct attributes' do
expect(subject[:description]).to eq('Trigger event for pushes to the repository.') expect(subject[:description]).to eq('Trigger event for pushes to the repository.')
expect(subject[:name]).to eq('push_events') expect(subject[:name]).to eq('push_events')
expect(subject[:title]).to eq('push') expect(subject[:title]).to eq('Push')
expect(subject[:value]).to be(true) expect(subject[:value]).to be(true)
end end
end end
...@@ -31,7 +31,7 @@ RSpec.describe ServiceEventEntity do ...@@ -31,7 +31,7 @@ RSpec.describe ServiceEventEntity do
it 'exposes correct attributes' do it 'exposes correct attributes' do
expect(subject[:description]).to eq('Trigger event for new comments.') expect(subject[:description]).to eq('Trigger event for new comments.')
expect(subject[:name]).to eq('note_events') expect(subject[:name]).to eq('note_events')
expect(subject[:title]).to eq('note') expect(subject[:title]).to eq('Note')
expect(subject[:value]).to eq(false) expect(subject[:value]).to eq(false)
expect(subject[:field][:name]).to eq('note_channel') expect(subject[:field][:name]).to eq('note_channel')
expect(subject[:field][:value]).to eq('note-channel') expect(subject[:field][:value]).to eq('note-channel')
......
...@@ -22,10 +22,7 @@ RSpec.shared_examples 'integration settings form' do ...@@ -22,10 +22,7 @@ RSpec.shared_examples 'integration settings form' do
events = parse_json(trigger_events_for_integration(integration)) events = parse_json(trigger_events_for_integration(integration))
events.each do |trigger| events.each do |trigger|
# normalizing the title because capybara location is case sensitive expect(page).to have_field(trigger[:title], type: 'checkbox', wait: 0),
title = normalize_title trigger[:title], integration
expect(page).to have_field(title, type: 'checkbox', wait: 0),
"#{integration.title} field #{title} checkbox not present" "#{integration.title} field #{title} checkbox not present"
end end
end end
...@@ -35,12 +32,6 @@ RSpec.shared_examples 'integration settings form' do ...@@ -35,12 +32,6 @@ RSpec.shared_examples 'integration settings form' do
private private
def normalize_title(title, integration)
return 'Merge request' if integration.is_a?(Integrations::Jira) && title == 'merge_request'
title.titlecase
end
def parse_json(json) def parse_json(json)
Gitlab::Json.parse(json, symbolize_names: true) Gitlab::Json.parse(json, symbolize_names: true)
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