Commit 6aa4cb5d authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch '33112-label-based-ca-stage-fixtures' into 'master'

Adding label based stage to FE fixtures

Closes #33112

See merge request gitlab-org/gitlab!22459
parents 5cc1340c 2fd86551
...@@ -8,12 +8,11 @@ module Analytics ...@@ -8,12 +8,11 @@ module Analytics
expose :type expose :type
expose :can_be_start_event?, as: :can_be_start_event expose :can_be_start_event?, as: :can_be_start_event
expose :allowed_end_events expose :allowed_end_events
expose :label_based?, as: :label_based
private private
def type def type
'simple' object.label_based? ? 'label' : 'simple'
end end
def can_be_start_event? def can_be_start_event?
......
{ {
"type": "object", "type": "object",
"required": ["name", "identifier", "type", "can_be_start_event", "allowed_end_events", "label_based"], "required": ["name", "identifier", "type", "can_be_start_event", "allowed_end_events"],
"properties": { "properties": {
"name": { "name": {
"type": "string" "type": "string"
}, },
"identifier": { "identifier": {
"type": "string" "type": "string"
}, },
"type": { "type": {
"type": "string" , "type": "string",
"enum": ["simple"] "enum": ["simple", "label"]
}, },
"can_be_start_event": { "can_be_start_event": {
"type": "boolean" "type": "boolean"
}, },
"label_based": {
"type": "boolean"
},
"allowed_end_events": { "allowed_end_events": {
"type": "array", "type": "array",
"items": { "items": {
......
...@@ -9,6 +9,7 @@ exports[`CustomStageForm Editing a custom stage isSavingCustomStage=true display ...@@ -9,6 +9,7 @@ exports[`CustomStageForm Editing a custom stage isSavingCustomStage=true display
exports[`CustomStageForm Empty form Start event with events does not select events with canBeStartEvent=false for the start events dropdown 1`] = ` exports[`CustomStageForm Empty form 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__123\\"> "<select name=\\"custom-stage-start-event\\" required=\\"required\\" aria-required=\\"true\\" class=\\"gl-form-select custom-select\\" id=\\"__BVID__123\\">
<option value=\\"\\">Select start event</option> <option value=\\"\\">Select start event</option>
<option value=\\"issue_created\\">Issue created</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=\\"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>
...@@ -20,34 +21,18 @@ exports[`CustomStageForm Empty form Start event with events does not select even ...@@ -20,34 +21,18 @@ exports[`CustomStageForm Empty form Start event with events does not select even
<option value=\\"issue_closed\\">Issue closed</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_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_first_associated_with_milestone\\">Issue first associated with a milestone</option>
<option value=\\"issue_first_mentioned_in_commit\\">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_label_added\\">Merge Request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge Request label was removed</option>
<option value=\\"issue_first_mentioned_in_commit\\">Issue first mentioned in a commit</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_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=\\"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_first_mentioned_in_commit\\">Issue first mentioned in a commit</option>
<option value=\\"issue_label_added\\">Issue label was added</option> <option value=\\"issue_label_added\\">Issue label was added</option>
<option value=\\"issue_label_removed\\">Issue label was removed</option> <option value=\\"issue_label_removed\\">Issue label was removed</option>
<option value=\\"merge_request_closed\\">Merge request closed</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_added\\">Merge Request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge Request label was removed</option> <option value=\\"merge_request_label_removed\\">Merge Request label was removed</option>
<option value=\\"issue_created\\">Issue created</option>
</select>" </select>"
`; `;
exports[`CustomStageForm Empty form Start event with events selects events with canBeStartEvent=true for the start events dropdown 1`] = ` exports[`CustomStageForm Empty form 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__95\\"> "<select name=\\"custom-stage-start-event\\" required=\\"required\\" aria-required=\\"true\\" class=\\"gl-form-select custom-select\\" id=\\"__BVID__95\\">
<option value=\\"\\">Select start event</option> <option value=\\"\\">Select start event</option>
<option value=\\"issue_created\\">Issue created</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=\\"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>
...@@ -59,28 +44,11 @@ exports[`CustomStageForm Empty form Start event with events selects events with ...@@ -59,28 +44,11 @@ exports[`CustomStageForm Empty form Start event with events selects events with
<option value=\\"issue_closed\\">Issue closed</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_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_first_associated_with_milestone\\">Issue first associated with a milestone</option>
<option value=\\"issue_first_mentioned_in_commit\\">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_label_added\\">Merge Request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge Request label was removed</option>
<option value=\\"issue_first_mentioned_in_commit\\">Issue first mentioned in a commit</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_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=\\"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_first_mentioned_in_commit\\">Issue first mentioned in a commit</option>
<option value=\\"issue_label_added\\">Issue label was added</option> <option value=\\"issue_label_added\\">Issue label was added</option>
<option value=\\"issue_label_removed\\">Issue label was removed</option> <option value=\\"issue_label_removed\\">Issue label was removed</option>
<option value=\\"merge_request_closed\\">Merge request closed</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_added\\">Merge Request label was added</option>
<option value=\\"merge_request_label_removed\\">Merge Request label was removed</option> <option value=\\"merge_request_label_removed\\">Merge Request label was removed</option>
<option value=\\"issue_created\\">Issue created</option>
</select>" </select>"
`; `;
......
...@@ -161,8 +161,9 @@ describe('CustomStageForm', () => { ...@@ -161,8 +161,9 @@ describe('CustomStageForm', () => {
}); });
describe('Stop event', () => { describe('Stop event', () => {
const index = 2; const startEventArrayIndex = 2;
const currAllowed = startEvents[index].allowedEndEvents; const startEventDropdownIndex = 1;
const currAllowed = startEvents[startEventArrayIndex].allowedEndEvents;
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({}, false); wrapper = createComponent({}, false);
...@@ -173,7 +174,7 @@ describe('CustomStageForm', () => { ...@@ -173,7 +174,7 @@ describe('CustomStageForm', () => {
}); });
it('clears notification when a start event is selected', done => { it('clears notification when a start event is selected', done => {
selectDropdownOption(wrapper, sel.startEvent, 1); selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex);
Vue.nextTick(() => { Vue.nextTick(() => {
expect(wrapper.text()).not.toContain('Please select a start event first'); expect(wrapper.text()).not.toContain('Please select a start event first');
done(); done();
...@@ -184,7 +185,7 @@ describe('CustomStageForm', () => { ...@@ -184,7 +185,7 @@ describe('CustomStageForm', () => {
const el = wrapper.find(sel.endEvent); const el = wrapper.find(sel.endEvent);
expect(el.attributes('disabled')).toEqual('disabled'); expect(el.attributes('disabled')).toEqual('disabled');
selectDropdownOption(wrapper, sel.startEvent, 1); selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex);
Vue.nextTick(() => { Vue.nextTick(() => {
expect(el.attributes('disabled')).toBeUndefined(); expect(el.attributes('disabled')).toBeUndefined();
done(); done();
...@@ -193,11 +194,10 @@ describe('CustomStageForm', () => { ...@@ -193,11 +194,10 @@ describe('CustomStageForm', () => {
it('will update the list of stop events when a start event is changed', done => { it('will update the list of stop events when a start event is changed', done => {
let stopOptions = wrapper.find(sel.endEvent).findAll('option'); let stopOptions = wrapper.find(sel.endEvent).findAll('option');
const selectedStartEventIndex = 1; const selectedStartEvent = startEvents[startEventDropdownIndex];
const selectedStartEvent = startEvents[selectedStartEventIndex];
expect(stopOptions.length).toEqual(1); expect(stopOptions.length).toEqual(1);
selectDropdownOption(wrapper, sel.startEvent, selectedStartEventIndex); selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex);
Vue.nextTick(() => { Vue.nextTick(() => {
stopOptions = wrapper.find(sel.endEvent); stopOptions = wrapper.find(sel.endEvent);
...@@ -214,7 +214,7 @@ describe('CustomStageForm', () => { ...@@ -214,7 +214,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, index); selectDropdownOption(wrapper, sel.startEvent, startEventArrayIndex + 1);
Vue.nextTick(() => { Vue.nextTick(() => {
stopOptions = wrapper.find(sel.endEvent); stopOptions = wrapper.find(sel.endEvent);
...@@ -232,7 +232,7 @@ describe('CustomStageForm', () => { ...@@ -232,7 +232,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, index); selectDropdownOption(wrapper, sel.startEvent, startEventArrayIndex + 1);
Vue.nextTick(() => { Vue.nextTick(() => {
stopOptions = wrapper.find(sel.endEvent); stopOptions = wrapper.find(sel.endEvent);
...@@ -386,13 +386,14 @@ describe('CustomStageForm', () => { ...@@ -386,13 +386,14 @@ describe('CustomStageForm', () => {
}); });
describe('with all fields set', () => { describe('with all fields set', () => {
const startEventIndex = 2; const startEventDropdownIndex = 2;
const startEventArrayIndex = startEventDropdownIndex - 1;
const stopEventIndex = 1; const stopEventIndex = 1;
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({}, false); wrapper = createComponent({}, false);
selectDropdownOption(wrapper, sel.startEvent, startEventIndex); selectDropdownOption(wrapper, sel.startEvent, startEventDropdownIndex);
return Vue.nextTick() return Vue.nextTick()
.then(() => { .then(() => {
...@@ -424,9 +425,8 @@ describe('CustomStageForm', () => { ...@@ -424,9 +425,8 @@ describe('CustomStageForm', () => {
}); });
it(`${STAGE_ACTIONS.CREATE} event receives the latest data`, () => { it(`${STAGE_ACTIONS.CREATE} event receives the latest data`, () => {
const startEv = startEvents[startEventIndex]; const startEv = startEvents[startEventArrayIndex];
const selectedStopEvent = getDropdownOption(wrapper, sel.endEvent, stopEventIndex); const selectedStopEvent = getDropdownOption(wrapper, sel.endEvent, stopEventIndex);
let event = findEvent(STAGE_ACTIONS.CREATE); let event = findEvent(STAGE_ACTIONS.CREATE);
expect(event).toBeUndefined(); expect(event).toBeUndefined();
......
import { uniq } from 'underscore';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { getJSONFixture } from 'helpers/fixtures'; import { getJSONFixture } from 'helpers/fixtures';
import mutations from 'ee/analytics/cycle_analytics/store/mutations'; import mutations from 'ee/analytics/cycle_analytics/store/mutations';
...@@ -97,31 +98,25 @@ export const medians = stageMedians; ...@@ -97,31 +98,25 @@ export const medians = stageMedians;
const { events: rawCustomStageEvents } = customizableStagesAndEvents; const { events: rawCustomStageEvents } = customizableStagesAndEvents;
const camelCasedStageEvents = rawCustomStageEvents.map(deepCamelCase); const camelCasedStageEvents = rawCustomStageEvents.map(deepCamelCase);
export const customStageLabelEvents = camelCasedStageEvents.filter(ev => ev.type === 'label');
export const customStageStartEvents = camelCasedStageEvents.filter(ev => ev.canBeStartEvent); export const customStageStartEvents = camelCasedStageEvents.filter(ev => ev.canBeStartEvent);
// find get all the possible stop events // get all the possible stop events
const allowedEndEventIds = new Set(customStageStartEvents.flatMap(e => e.allowedEndEvents)); const allowedEndEventIds = new Set(customStageStartEvents.flatMap(e => e.allowedEndEvents));
export const customStageStopEvents = camelCasedStageEvents.filter(ev => export const customStageStopEvents = camelCasedStageEvents.filter(ev =>
allowedEndEventIds.has(ev.identifier), allowedEndEventIds.has(ev.identifier),
); );
// TODO: the shim below should be removed once we have label events seeding export const customStageEvents = uniq(
// https://gitlab.com/gitlab-org/gitlab/issues/33112 [...customStageStartEvents, ...customStageStopEvents],
export const labelStartEvent = { ...customStageStartEvents[0], type: 'label' }; false,
const firstAllowedStopEvent = labelStartEvent.allowedEndEvents[0]; ev => ev.identifier,
// We need to enusre that the stop event can be applied to the start event );
export const labelStopEvent = {
...customStageStopEvents.find(ev => ev.identifier === firstAllowedStopEvent),
type: 'label',
};
export const customStageEvents = [ export const labelStartEvent = customStageLabelEvents[0];
...customStageStartEvents.filter(ev => ev.identifier !== labelStartEvent.identifier), export const labelStopEvent = customStageLabelEvents.find(
...customStageStopEvents.filter(ev => ev.identifier !== labelStopEvent.identifier), ev => ev.identifier === labelStartEvent.allowedEndEvents[0],
labelStartEvent, );
labelStopEvent,
];
const dateRange = getDatesInRange(startDate, endDate, toYmd); const dateRange = getDatesInRange(startDate, endDate, toYmd);
......
...@@ -20,8 +20,8 @@ import { ...@@ -20,8 +20,8 @@ import {
import { toYmd } from 'ee/analytics/shared/utils'; import { toYmd } from 'ee/analytics/shared/utils';
import { import {
customStageEvents as events, customStageEvents as events,
customStageLabelEvents as labelEvents,
labelStartEvent, labelStartEvent,
labelStopEvent,
customStageStartEvents as startEvents, customStageStartEvents as startEvents,
transformedDurationData, transformedDurationData,
transformedDurationMedianData, transformedDurationMedianData,
...@@ -35,7 +35,7 @@ import { ...@@ -35,7 +35,7 @@ import {
transformedTasksByTypeData, transformedTasksByTypeData,
} from './mock_data'; } from './mock_data';
const labelEvents = [labelStartEvent, labelStopEvent].map(i => i.identifier); const labelEventIds = labelEvents.map(ev => ev.identifier);
describe('Cycle analytics utils', () => { describe('Cycle analytics utils', () => {
describe('isStartEvent', () => { describe('isStartEvent', () => {
...@@ -54,13 +54,14 @@ describe('Cycle analytics utils', () => { ...@@ -54,13 +54,14 @@ describe('Cycle analytics utils', () => {
describe('isLabelEvent', () => { describe('isLabelEvent', () => {
it('will return true if the given event identifier is in the labelEvents array', () => { it('will return true if the given event identifier is in the labelEvents array', () => {
expect(isLabelEvent(labelEvents, labelStartEvent.identifier)).toEqual(true); expect(isLabelEvent(labelEventIds, labelStartEvent.identifier)).toEqual(true);
}); });
it('will return false if the given event identifier is not in the labelEvents array', () => { it('will return false if the given event identifier is not in the labelEvents array', () => {
[startEvents[1].identifier, null, undefined, ''].forEach(ev => { [startEvents[1].identifier, null, undefined, ''].forEach(ev => {
expect(isLabelEvent(labelEvents, ev)).toEqual(false); expect(isLabelEvent(labelEventIds, ev)).toEqual(false);
}); });
expect(isLabelEvent(labelEvents)).toEqual(false); expect(isLabelEvent(labelEventIds)).toEqual(false);
}); });
}); });
...@@ -89,8 +90,7 @@ describe('Cycle analytics utils', () => { ...@@ -89,8 +90,7 @@ describe('Cycle analytics utils', () => {
describe('getLabelEventsIdentifiers', () => { describe('getLabelEventsIdentifiers', () => {
it('will return an array of identifiers for the label events', () => { it('will return an array of identifiers for the label events', () => {
const res = getLabelEventsIdentifiers(events); const res = getLabelEventsIdentifiers(events);
expect(res.length).toEqual(labelEvents.length); expect(res).toEqual(labelEventIds);
expect(res).toEqual(labelEvents);
}); });
it('will return an empty array when there are no matches', () => { it('will return an empty array when there are no matches', () => {
...@@ -115,7 +115,7 @@ describe('Cycle analytics utils', () => { ...@@ -115,7 +115,7 @@ describe('Cycle analytics utils', () => {
describe('eventsByIdentifier', () => { describe('eventsByIdentifier', () => {
it('will return the events with an identifier in the provided array', () => { it('will return the events with an identifier in the provided array', () => {
expect(eventsByIdentifier(events, labelEvents)).toEqual([labelStartEvent, labelStopEvent]); expect(eventsByIdentifier(events, labelEventIds)).toEqual(labelEvents);
}); });
it('will return an empty array if there are no matching events', () => { it('will return an empty array if there are no matching events', () => {
......
...@@ -16,6 +16,8 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do ...@@ -16,6 +16,8 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
let(:issue_2) { create(:issue, project: project, created_at: 4.days.ago) } let(:issue_2) { create(:issue, project: project, created_at: 4.days.ago) }
let(:issue_3) { create(:issue, project: project, created_at: 3.days.ago) } let(:issue_3) { create(:issue, project: project, created_at: 3.days.ago) }
let(:label) { create(:group_label, name: 'in-code-review', group: group) }
let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") } let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") }
let(:mr_1) { create(:merge_request, source_project: project, allow_broken: true, created_at: 20.days.ago) } let(:mr_1) { create(:merge_request, source_project: project, allow_broken: true, created_at: 20.days.ago) }
let(:mr_2) { create(:merge_request, source_project: project, allow_broken: true, created_at: 19.days.ago) } let(:mr_2) { create(:merge_request, source_project: project, allow_broken: true, created_at: 19.days.ago) }
...@@ -29,6 +31,17 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do ...@@ -29,6 +31,17 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
let(:build_2) { create(:ci_build, :success, pipeline: pipeline_2, author: user) } let(:build_2) { create(:ci_build, :success, pipeline: pipeline_2, author: user) }
let(:build_3) { create(:ci_build, :success, pipeline: pipeline_3, author: user) } let(:build_3) { create(:ci_build, :success, pipeline: pipeline_3, author: user) }
let(:label_based_stage) do
create(:cycle_analytics_group_stage, {
name: 'label-based-stage',
parent: group,
start_event_identifier: :issue_label_added,
start_event_label_id: label.id,
end_event_identifier: :issue_label_removed,
end_event_label_id: label.id
})
end
def prepare_cycle_analytics_data def prepare_cycle_analytics_data
group.add_maintainer(user) group.add_maintainer(user)
project.add_maintainer(user) project.add_maintainer(user)
...@@ -81,6 +94,32 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do ...@@ -81,6 +94,32 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
deploy_master(user, project, environment: 'staging') deploy_master(user, project, environment: 'staging')
end end
def create_label_based_cycle_analytics_stage
label_based_stage
issue = create(:issue, project: project, created_at: 20.days.ago, author: user)
Timecop.travel(5.days.ago) do
Issues::UpdateService.new(
project,
user,
label_ids: [label.id]
).execute(issue)
end
Timecop.travel(2.days.ago) do
Issues::UpdateService.new(
project,
user,
label_ids: []
).execute(issue)
end
end
around do |example|
Timecop.freeze { example.run }
end
before(:all) do before(:all) do
clean_frontend_fixtures('analytics/') clean_frontend_fixtures('analytics/')
clean_frontend_fixtures('cycle_analytics/') clean_frontend_fixtures('cycle_analytics/')
...@@ -145,6 +184,8 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do ...@@ -145,6 +184,8 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
group.cycle_analytics_stages.build(params).save! group.cycle_analytics_stages.build(params).save!
end end
create_label_based_cycle_analytics_stage
prepare_cycle_analytics_data prepare_cycle_analytics_data
create_deployment create_deployment
...@@ -174,6 +215,18 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do ...@@ -174,6 +215,18 @@ describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
expect(response).to be_successful expect(response).to be_successful
end end
end end
it "analytics/cycle_analytics/stages/label-based-stage/records.json" do
get(:records, params: params.merge({ id: label_based_stage.id }), format: :json)
expect(response).to be_successful
end
it "analytics/cycle_analytics/stages/label-based-stage/median.json" do
get(:median, params: params.merge({ id: label_based_stage.id }), format: :json)
expect(response).to be_successful
end
end end
describe Analytics::CycleAnalytics::SummaryController, type: :controller do describe Analytics::CycleAnalytics::SummaryController, type: :controller do
......
# frozen_string_literal: true
require 'spec_helper'
describe Analytics::CycleAnalytics::EventEntity do
describe '#type' do
it 'returns `simple` for non-label based events' do
event = Gitlab::Analytics::CycleAnalytics::StageEvents::IssueCreated
expect(described_class.new(event).as_json[:type]).to eq('simple')
end
it 'returns `label` for label based events' do
event = Gitlab::Analytics::CycleAnalytics::StageEvents::IssueLabelAdded
expect(described_class.new(event).as_json[:type]).to eq('label')
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