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
private
def events
Gitlab::Analytics::CycleAnalytics::StageEvents.events
Gitlab::Analytics::CycleAnalytics::StageEvents.events.sort_by(&:name)
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
module StageEvents
class MergeRequestLabelAdded < LabelBasedStageEvent
def self.name
s_("CycleAnalyticsEvent|Merge Request label was added")
s_("CycleAnalyticsEvent|Merge request label was added")
end
def self.identifier
......
......@@ -6,7 +6,7 @@ module Gitlab
module StageEvents
class MergeRequestLabelRemoved < LabelBasedStageEvent
def self.name
s_("CycleAnalyticsEvent|Merge Request label was removed")
s_("CycleAnalyticsEvent|Merge request label was removed")
end
def self.identifier
......
......@@ -40,7 +40,7 @@ describe Analytics::CycleAnalytics::StagesController do
response_event_names = json_response['events'].map { |s| s['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
it 'succeeds for subgroups' do
......
......@@ -428,8 +428,8 @@ describe 'Group Value Stream Analytics', :js do
stage.find(".more-actions-toggle").click
end
def select_dropdown_option(name, elem = "option", index = 1)
page.find("select[name='#{name}']").all(elem)[index].select_option
def select_dropdown_option(name, value = start_event_identifier)
page.find("select[name='#{name}']").all('option').find { |item| item.value == value.to_s }.select_option
end
def select_dropdown_option_by_value(name, value, elem = "option")
......@@ -569,7 +569,7 @@ describe 'Group Value Stream Analytics', :js do
end
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)
end
......@@ -598,8 +598,8 @@ describe 'Group Value Stream Analytics', :js do
context 'with all required fields set' do
before do
fill_in 'custom-stage-name', with: custom_stage_name
select_dropdown_option 'custom-stage-start-event'
select_dropdown_option 'custom-stage-stop-event'
select_dropdown_option 'custom-stage-start-event', start_event_identifier
select_dropdown_option 'custom-stage-stop-event', end_event_identifier
end
it 'does not have label dropdowns' do
......
......@@ -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`] = `
"<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=\\"issue_closed\\">Issue closed</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=\\"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_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_started\\">Merge request last build start time</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>"
`;
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\\">
<option value=\\"\\">Select start event</option>
<option value=\\"issue_closed\\">Issue closed</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=\\"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_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_started\\">Merge request last build start time</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>"
`;
......
......@@ -25,6 +25,9 @@ const initData = {
endEventLabelId: groupLabels[1].id,
};
const MERGE_REQUEST_CREATED = 'merge_request_created';
const MERGE_REQUEST_CLOSED = 'merge_request_closed';
let store = null;
const localVue = createLocalVue();
localVue.use(Vuex);
......@@ -72,7 +75,20 @@ describe('CustomStageForm', () => {
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);
return Vue.nextTick().then(() => {
selectDropdownOption(wrapper, sel.endEvent, stopEventDropdownIndex);
......@@ -219,8 +235,8 @@ describe('CustomStageForm', () => {
});
describe('Stop event', () => {
const startEventArrayIndex = 2;
const startEventDropdownIndex = 1;
const startEventArrayIndex = mergeRequestCreatedIndex;
const startEventDropdownIndex = startEventArrayIndex + 1;
const currAllowed = startEvents[startEventArrayIndex].allowedEndEvents;
beforeEach(() => {
......@@ -269,7 +285,7 @@ describe('CustomStageForm', () => {
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(() => {
stopOptions = wrapper.find(sel.endEvent);
......@@ -306,9 +322,9 @@ describe('CustomStageForm', () => {
wrapper.setData({
fields: {
name: 'Cool stage',
startEventIdentifier: 'issue_created',
startEventIdentifier: MERGE_REQUEST_CREATED,
startEventLabelId: null,
endEventIdentifier: 'issue_stage_end',
endEventIdentifier: MERGE_REQUEST_CLOSED,
endEventLabelId: null,
},
});
......
......@@ -6,7 +6,7 @@ module Gitlab
module StageEvents
class ProductionStageEnd < StageEvent
def self.name
PlanStageStart.name
_("Issue first depoloyed to production")
end
def self.identifier
......
......@@ -6127,19 +6127,19 @@ msgstr ""
msgid "CycleAnalyticsEvent|Issue last edited"
msgstr ""
msgid "CycleAnalyticsEvent|Merge Request label was added"
msgid "CycleAnalyticsEvent|Merge request closed"
msgstr ""
msgid "CycleAnalyticsEvent|Merge Request label was removed"
msgid "CycleAnalyticsEvent|Merge request created"
msgstr ""
msgid "CycleAnalyticsEvent|Merge request closed"
msgid "CycleAnalyticsEvent|Merge request first deployed to production"
msgstr ""
msgid "CycleAnalyticsEvent|Merge request created"
msgid "CycleAnalyticsEvent|Merge request label was added"
msgstr ""
msgid "CycleAnalyticsEvent|Merge request first deployed to production"
msgid "CycleAnalyticsEvent|Merge request label was removed"
msgstr ""
msgid "CycleAnalyticsEvent|Merge request last build finish time"
......@@ -11158,6 +11158,9 @@ msgstr ""
msgid "Issue events"
msgstr ""
msgid "Issue first depoloyed to production"
msgstr ""
msgid "Issue or Merge Request ID is required"
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