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>
import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui';
import { startCase } from 'lodash';
import { mapGetters } from 'vuex';
import { __ } from '~/locale';
......@@ -45,7 +44,6 @@ export default {
fieldName(name) {
return `service[${name}]`;
},
startCase,
},
};
</script>
......@@ -58,10 +56,10 @@ export default {
data-testid="trigger-fields-group"
>
<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" />
<gl-form-checkbox v-model="event.value" :disabled="isInheriting">
{{ startCase(event.title) }}
{{ event.title }}
</gl-form-checkbox>
<gl-form-input
v-if="event.field"
......
# frozen_string_literal: true
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)
case integration
when Integrations::Jira
......
......@@ -4,7 +4,7 @@ class ServiceEventEntity < Grape::Entity
include RequestAwareEntity
expose :title do |event|
event
IntegrationsHelper.integration_event_title(event)
end
expose :event_field_name, as: :name
......
......@@ -56,6 +56,13 @@ module EE
}
end
override :integration_event_title
def integration_event_title(event)
return _('Vulnerability') if event == 'vulnerability'
super
end
override :default_integration_event_description
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'
......
......@@ -3150,6 +3150,9 @@ msgstr ""
msgid "Akismet helps prevent the creation of spam issues in public projects."
msgstr ""
msgid "Alert"
msgstr ""
msgid "AlertManagement|Acknowledged"
msgstr ""
......@@ -9110,6 +9113,12 @@ msgstr ""
msgid "Confidential"
msgstr ""
msgid "Confidential issue"
msgstr ""
msgid "Confidential note"
msgstr ""
msgid "Confidentiality"
msgstr ""
......@@ -12194,6 +12203,9 @@ msgstr ""
msgid "Deploying to AWS is easy with GitLab"
msgstr ""
msgid "Deployment"
msgstr ""
msgid "Deployment Frequency"
msgstr ""
......@@ -35822,6 +35834,9 @@ msgstr ""
msgid "Tag name is required"
msgstr ""
msgid "Tag push"
msgstr ""
msgid "Tag push events"
msgstr ""
......@@ -40564,6 +40579,9 @@ msgstr ""
msgid "Vulnerabilities over time"
msgstr ""
msgid "Vulnerability"
msgstr ""
msgid "Vulnerability Report"
msgstr ""
......@@ -41373,6 +41391,9 @@ msgstr ""
msgid "Wiki"
msgstr ""
msgid "Wiki page"
msgstr ""
msgid "Wiki page was successfully created."
msgstr ""
......
......@@ -12,7 +12,7 @@ RSpec.describe 'User activates JetBrains TeamCity CI' do
it 'activates integration', :js do
visit_project_integration('JetBrains TeamCity')
check('Push')
check('Merge Request')
check('Merge request')
fill_in('TeamCity server URL', with: 'http://teamcity.example.com')
fill_in('Build type', with: 'GitlabTest_Build')
fill_in('Username', with: 'user')
......
......@@ -40,13 +40,13 @@ describe('TriggerFields', () => {
describe('events without field property', () => {
const events = [
{
title: 'push',
title: 'Push',
name: 'push_event',
description: 'Event on push',
value: true,
},
{
title: 'merge_request',
title: 'Merge request',
name: 'merge_requests_event',
description: 'Event on merge_request',
value: false,
......@@ -81,7 +81,7 @@ describe('TriggerFields', () => {
const checkboxes = findAllGlFormGroups();
const expectedResults = [
{ 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);
......
......@@ -3,17 +3,41 @@
require 'spec_helper'
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
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
let(:integration) { Integrations::Jira.new }
let(:event) { 'merge_request_events' }
it { is_expected.to include('Jira') }
end
context 'when integration is Team City' do
let(:integration) { Integrations::Teamcity.new }
let(:event) { 'merge_request_events' }
it { is_expected.to include('TeamCity') }
end
......
......@@ -19,7 +19,7 @@ RSpec.describe ServiceEventEntity do
it 'exposes correct attributes' do
expect(subject[:description]).to eq('Trigger event for pushes to the repository.')
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)
end
end
......@@ -31,7 +31,7 @@ RSpec.describe ServiceEventEntity do
it 'exposes correct attributes' do
expect(subject[:description]).to eq('Trigger event for new comments.')
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[:field][:name]).to eq('note_channel')
expect(subject[:field][:value]).to eq('note-channel')
......
......@@ -22,10 +22,7 @@ RSpec.shared_examples 'integration settings form' do
events = parse_json(trigger_events_for_integration(integration))
events.each do |trigger|
# normalizing the title because capybara location is case sensitive
title = normalize_title trigger[:title], integration
expect(page).to have_field(title, type: 'checkbox', wait: 0),
expect(page).to have_field(trigger[:title], type: 'checkbox', wait: 0),
"#{integration.title} field #{title} checkbox not present"
end
end
......@@ -35,12 +32,6 @@ RSpec.shared_examples 'integration settings form' do
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)
Gitlab::Json.parse(json, symbolize_names: true)
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