Commit e9f99309 authored by Adam Hegyi's avatar Adam Hegyi

Sort Value Stream Analytics event names

Test improvement: Use explicit event identifiers when selecting
events from the dropdown in the stage form tests.
parent 50f7d343
...@@ -11,7 +11,7 @@ module Analytics ...@@ -11,7 +11,7 @@ module Analytics
private private
def events def events
Gitlab::Analytics::CycleAnalytics::StageEvents.events Gitlab::Analytics::CycleAnalytics::StageEvents.events.sort_by(&:name)
end end
end end
end end
......
---
title: Sort events alphabetically on Value Stream Analytics Stage form
merge_request: 28005
author:
type: changed
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
module StageEvents module StageEvents
class MergeRequestLabelAdded < LabelBasedStageEvent class MergeRequestLabelAdded < LabelBasedStageEvent
def self.name def self.name
s_("CycleAnalyticsEvent|Merge Request label was added") s_("CycleAnalyticsEvent|Merge request label was added")
end end
def self.identifier def self.identifier
......
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
module StageEvents module StageEvents
class MergeRequestLabelRemoved < LabelBasedStageEvent class MergeRequestLabelRemoved < LabelBasedStageEvent
def self.name def self.name
s_("CycleAnalyticsEvent|Merge Request label was removed") s_("CycleAnalyticsEvent|Merge request label was removed")
end end
def self.identifier def self.identifier
......
...@@ -40,7 +40,7 @@ describe Analytics::CycleAnalytics::StagesController do ...@@ -40,7 +40,7 @@ describe Analytics::CycleAnalytics::StagesController do
response_event_names = json_response['events'].map { |s| s['name'] } response_event_names = json_response['events'].map { |s| s['name'] }
event_names = Gitlab::Analytics::CycleAnalytics::StageEvents.events.map(&:name) event_names = Gitlab::Analytics::CycleAnalytics::StageEvents.events.map(&:name)
expect(response_event_names).to eq(event_names) expect(response_event_names).to eq(event_names.sort)
end end
it 'succeeds for subgroups' do it 'succeeds for subgroups' do
......
...@@ -428,8 +428,8 @@ describe 'Group Value Stream Analytics', :js do ...@@ -428,8 +428,8 @@ describe 'Group Value Stream Analytics', :js do
stage.find(".more-actions-toggle").click stage.find(".more-actions-toggle").click
end end
def select_dropdown_option(name, elem = "option", index = 1) def select_dropdown_option(name, value = start_event_identifier)
page.find("select[name='#{name}']").all(elem)[index].select_option page.find("select[name='#{name}']").all('option').find { |item| item.value == value.to_s }.select_option
end end
def select_dropdown_option_by_value(name, value, elem = "option") def select_dropdown_option_by_value(name, value, elem = "option")
...@@ -569,7 +569,7 @@ describe 'Group Value Stream Analytics', :js do ...@@ -569,7 +569,7 @@ describe 'Group Value Stream Analytics', :js do
end end
it 'submit button is disabled if the start event changes' do it 'submit button is disabled if the start event changes' do
select_dropdown_option 'custom-stage-start-event', 'option', 2 select_dropdown_option 'custom-stage-start-event', 'issue_created'
expect(page).to have_button('Add stage', disabled: true) expect(page).to have_button('Add stage', disabled: true)
end end
...@@ -598,8 +598,8 @@ describe 'Group Value Stream Analytics', :js do ...@@ -598,8 +598,8 @@ describe 'Group Value Stream Analytics', :js do
context 'with all required fields set' do context 'with all required fields set' do
before do before do
fill_in 'custom-stage-name', with: custom_stage_name fill_in 'custom-stage-name', with: custom_stage_name
select_dropdown_option 'custom-stage-start-event' select_dropdown_option 'custom-stage-start-event', start_event_identifier
select_dropdown_option 'custom-stage-stop-event' select_dropdown_option 'custom-stage-stop-event', end_event_identifier
end end
it 'does not have label dropdowns' do it 'does not have label dropdowns' do
......
...@@ -9,46 +9,46 @@ exports[`CustomStageForm Editing a custom stage isSavingCustomStage=true display ...@@ -9,46 +9,46 @@ exports[`CustomStageForm Editing a custom stage isSavingCustomStage=true display
exports[`CustomStageForm Start event with events does not select events with canBeStartEvent=false for the start events dropdown 1`] = ` exports[`CustomStageForm Start event with events does not select events with canBeStartEvent=false for the start events dropdown 1`] = `
"<select name=\\"custom-stage-start-event\\" required=\\"required\\" aria-required=\\"true\\" class=\\"gl-form-select custom-select\\" id=\\"__BVID__277\\"> "<select name=\\"custom-stage-start-event\\" required=\\"required\\" aria-required=\\"true\\" class=\\"gl-form-select custom-select\\" id=\\"__BVID__277\\">
<option value=\\"\\">Select start event</option> <option value=\\"\\">Select start event</option>
<option value=\\"issue_closed\\">Issue closed</option>
<option value=\\"issue_created\\">Issue created</option> <option value=\\"issue_created\\">Issue created</option>
<option value=\\"issue_first_added_to_board\\">Issue first added to a board</option>
<option value=\\"issue_first_associated_with_milestone\\">Issue first associated with a milestone</option>
<option value=\\"plan_stage_start\\">Issue first associated with a milestone or issue first added to a board</option>
<option value=\\"issue_first_mentioned_in_commit\\">Issue first mentioned in a commit</option> <option value=\\"issue_first_mentioned_in_commit\\">Issue first mentioned in a commit</option>
<option value=\\"code_stage_start\\">Issue first mentioned in a commit</option>
<option value=\\"issue_label_added\\">Issue label was added</option>
<option value=\\"issue_label_removed\\">Issue label was removed</option>
<option value=\\"merge_request_closed\\">Merge request closed</option>
<option value=\\"merge_request_created\\">Merge request created</option> <option value=\\"merge_request_created\\">Merge request created</option>
<option value=\\"merge_request_first_deployed_to_production\\">Merge request first deployed to production</option> <option value=\\"merge_request_first_deployed_to_production\\">Merge request first deployed to production</option>
<option value=\\"merge_request_label_added\\">Merge request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge request label was removed</option>
<option value=\\"merge_request_last_build_finished\\">Merge request last build finish time</option> <option value=\\"merge_request_last_build_finished\\">Merge request last build finish time</option>
<option value=\\"merge_request_last_build_started\\">Merge request last build start time</option> <option value=\\"merge_request_last_build_started\\">Merge request last build start time</option>
<option value=\\"merge_request_merged\\">Merge request merged</option> <option value=\\"merge_request_merged\\">Merge request merged</option>
<option value=\\"code_stage_start\\">Issue first mentioned in a commit</option>
<option value=\\"plan_stage_start\\">Issue first associated with a milestone or issue first added to a board</option>
<option value=\\"issue_closed\\">Issue closed</option>
<option value=\\"issue_first_added_to_board\\">Issue first added to a board</option>
<option value=\\"issue_first_associated_with_milestone\\">Issue first associated with a milestone</option>
<option value=\\"issue_label_added\\">Issue label was added</option>
<option value=\\"issue_label_removed\\">Issue label was removed</option>
<option value=\\"merge_request_closed\\">Merge request closed</option>
<option value=\\"merge_request_label_added\\">Merge Request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge Request label was removed</option>
</select>" </select>"
`; `;
exports[`CustomStageForm Start event with events selects events with canBeStartEvent=true for the start events dropdown 1`] = ` exports[`CustomStageForm Start event with events selects events with canBeStartEvent=true for the start events dropdown 1`] = `
"<select name=\\"custom-stage-start-event\\" required=\\"required\\" aria-required=\\"true\\" class=\\"gl-form-select custom-select\\" id=\\"__BVID__237\\"> "<select name=\\"custom-stage-start-event\\" required=\\"required\\" aria-required=\\"true\\" class=\\"gl-form-select custom-select\\" id=\\"__BVID__237\\">
<option value=\\"\\">Select start event</option> <option value=\\"\\">Select start event</option>
<option value=\\"issue_closed\\">Issue closed</option>
<option value=\\"issue_created\\">Issue created</option> <option value=\\"issue_created\\">Issue created</option>
<option value=\\"issue_first_added_to_board\\">Issue first added to a board</option>
<option value=\\"issue_first_associated_with_milestone\\">Issue first associated with a milestone</option>
<option value=\\"plan_stage_start\\">Issue first associated with a milestone or issue first added to a board</option>
<option value=\\"issue_first_mentioned_in_commit\\">Issue first mentioned in a commit</option> <option value=\\"issue_first_mentioned_in_commit\\">Issue first mentioned in a commit</option>
<option value=\\"code_stage_start\\">Issue first mentioned in a commit</option>
<option value=\\"issue_label_added\\">Issue label was added</option>
<option value=\\"issue_label_removed\\">Issue label was removed</option>
<option value=\\"merge_request_closed\\">Merge request closed</option>
<option value=\\"merge_request_created\\">Merge request created</option> <option value=\\"merge_request_created\\">Merge request created</option>
<option value=\\"merge_request_first_deployed_to_production\\">Merge request first deployed to production</option> <option value=\\"merge_request_first_deployed_to_production\\">Merge request first deployed to production</option>
<option value=\\"merge_request_label_added\\">Merge request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge request label was removed</option>
<option value=\\"merge_request_last_build_finished\\">Merge request last build finish time</option> <option value=\\"merge_request_last_build_finished\\">Merge request last build finish time</option>
<option value=\\"merge_request_last_build_started\\">Merge request last build start time</option> <option value=\\"merge_request_last_build_started\\">Merge request last build start time</option>
<option value=\\"merge_request_merged\\">Merge request merged</option> <option value=\\"merge_request_merged\\">Merge request merged</option>
<option value=\\"code_stage_start\\">Issue first mentioned in a commit</option>
<option value=\\"plan_stage_start\\">Issue first associated with a milestone or issue first added to a board</option>
<option value=\\"issue_closed\\">Issue closed</option>
<option value=\\"issue_first_added_to_board\\">Issue first added to a board</option>
<option value=\\"issue_first_associated_with_milestone\\">Issue first associated with a milestone</option>
<option value=\\"issue_label_added\\">Issue label was added</option>
<option value=\\"issue_label_removed\\">Issue label was removed</option>
<option value=\\"merge_request_closed\\">Merge request closed</option>
<option value=\\"merge_request_label_added\\">Merge Request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge Request label was removed</option>
</select>" </select>"
`; `;
......
...@@ -25,6 +25,9 @@ const initData = { ...@@ -25,6 +25,9 @@ const initData = {
endEventLabelId: groupLabels[1].id, endEventLabelId: groupLabels[1].id,
}; };
const MERGE_REQUEST_CREATED = 'merge_request_created';
const MERGE_REQUEST_CLOSED = 'merge_request_closed';
let store = null; let store = null;
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -72,7 +75,20 @@ describe('CustomStageForm', () => { ...@@ -72,7 +75,20 @@ describe('CustomStageForm', () => {
getDropdownOption(_wrapper, dropdown, index).setSelected(); getDropdownOption(_wrapper, dropdown, index).setSelected();
} }
function setEventDropdowns({ startEventDropdownIndex = 1, stopEventDropdownIndex = 1 } = {}) { // Valid start and end event pair: merge request created - merge request closed
const mergeRequestCreatedIndex = startEvents.findIndex(
e => e.identifier === MERGE_REQUEST_CREATED,
);
const mergeRequestCreatedDropdownIndex = mergeRequestCreatedIndex;
const mergeReqestCreatedEvent = startEvents[mergeRequestCreatedIndex];
const mergeRequestClosedDropdownIndex = mergeReqestCreatedEvent.allowedEndEvents.findIndex(
e => e === MERGE_REQUEST_CLOSED,
);
function setEventDropdowns({
startEventDropdownIndex = mergeRequestCreatedDropdownIndex,
stopEventDropdownIndex = mergeRequestClosedDropdownIndex,
} = {}) {
selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex); selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex);
return Vue.nextTick().then(() => { return Vue.nextTick().then(() => {
selectDropdownOption(wrapper, sel.endEvent, stopEventDropdownIndex); selectDropdownOption(wrapper, sel.endEvent, stopEventDropdownIndex);
...@@ -219,8 +235,8 @@ describe('CustomStageForm', () => { ...@@ -219,8 +235,8 @@ describe('CustomStageForm', () => {
}); });
describe('Stop event', () => { describe('Stop event', () => {
const startEventArrayIndex = 2; const startEventArrayIndex = mergeRequestCreatedIndex;
const startEventDropdownIndex = 1; const startEventDropdownIndex = startEventArrayIndex + 1;
const currAllowed = startEvents[startEventArrayIndex].allowedEndEvents; const currAllowed = startEvents[startEventArrayIndex].allowedEndEvents;
beforeEach(() => { beforeEach(() => {
...@@ -269,7 +285,7 @@ describe('CustomStageForm', () => { ...@@ -269,7 +285,7 @@ describe('CustomStageForm', () => {
expect(stopOptions.at(0).html()).toEqual('<option value="">Select stop event</option>'); expect(stopOptions.at(0).html()).toEqual('<option value="">Select stop event</option>');
selectDropdownOption(wrapper, sel.startEvent, startEventArrayIndex + 1); selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex - 1);
return Vue.nextTick().then(() => { return Vue.nextTick().then(() => {
stopOptions = wrapper.find(sel.endEvent); stopOptions = wrapper.find(sel.endEvent);
...@@ -306,9 +322,9 @@ describe('CustomStageForm', () => { ...@@ -306,9 +322,9 @@ describe('CustomStageForm', () => {
wrapper.setData({ wrapper.setData({
fields: { fields: {
name: 'Cool stage', name: 'Cool stage',
startEventIdentifier: 'issue_created', startEventIdentifier: MERGE_REQUEST_CREATED,
startEventLabelId: null, startEventLabelId: null,
endEventIdentifier: 'issue_stage_end', endEventIdentifier: MERGE_REQUEST_CLOSED,
endEventLabelId: null, endEventLabelId: null,
}, },
}); });
......
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
module StageEvents module StageEvents
class ProductionStageEnd < StageEvent class ProductionStageEnd < StageEvent
def self.name def self.name
PlanStageStart.name _("Issue first depoloyed to production")
end end
def self.identifier def self.identifier
......
...@@ -6127,19 +6127,19 @@ msgstr "" ...@@ -6127,19 +6127,19 @@ msgstr ""
msgid "CycleAnalyticsEvent|Issue last edited" msgid "CycleAnalyticsEvent|Issue last edited"
msgstr "" msgstr ""
msgid "CycleAnalyticsEvent|Merge Request label was added" msgid "CycleAnalyticsEvent|Merge request closed"
msgstr "" msgstr ""
msgid "CycleAnalyticsEvent|Merge Request label was removed" msgid "CycleAnalyticsEvent|Merge request created"
msgstr "" msgstr ""
msgid "CycleAnalyticsEvent|Merge request closed" msgid "CycleAnalyticsEvent|Merge request first deployed to production"
msgstr "" msgstr ""
msgid "CycleAnalyticsEvent|Merge request created" msgid "CycleAnalyticsEvent|Merge request label was added"
msgstr "" msgstr ""
msgid "CycleAnalyticsEvent|Merge request first deployed to production" msgid "CycleAnalyticsEvent|Merge request label was removed"
msgstr "" msgstr ""
msgid "CycleAnalyticsEvent|Merge request last build finish time" msgid "CycleAnalyticsEvent|Merge request last build finish time"
...@@ -11158,6 +11158,9 @@ msgstr "" ...@@ -11158,6 +11158,9 @@ msgstr ""
msgid "Issue events" msgid "Issue events"
msgstr "" msgstr ""
msgid "Issue first depoloyed to production"
msgstr ""
msgid "Issue or Merge Request ID is required" msgid "Issue or Merge Request ID is required"
msgstr "" msgstr ""
......
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