Commit 97dad2e3 authored by Albert Salim's avatar Albert Salim

Import JSON fixtures in cycle_analytics mock_data

parent 5d85c6d9
/* eslint-disable import/no-deprecated */
import { uniq } from 'lodash'; import { uniq } from 'lodash';
import valueStreamAnalyticsStages from 'test_fixtures/analytics/value_stream_analytics/stages.json';
import valueStreamAnalyticsSummary from 'test_fixtures/analytics/metrics/value_stream_analytics/summary.json';
import valueStreamAnalyticsTimeSummary from 'test_fixtures/analytics/metrics/value_stream_analytics/time_summary.json';
import tasksByType from 'test_fixtures/analytics/charts/type_of_work/tasks_by_type.json'; import tasksByType from 'test_fixtures/analytics/charts/type_of_work/tasks_by_type.json';
import apiGroupLabels from 'test_fixtures/api/group_labels.json';
import issueStageFixtures from 'test_fixtures/analytics/value_stream_analytics/stages/issue/records.json';
import planStageFixtures from 'test_fixtures/analytics/value_stream_analytics/stages/plan/records.json';
import reviewStageFixtures from 'test_fixtures/analytics/value_stream_analytics/stages/review/records.json';
import codeStageFixtures from 'test_fixtures/analytics/value_stream_analytics/stages/code/records.json';
import testStageFixtures from 'test_fixtures/analytics/value_stream_analytics/stages/test/records.json';
import stagingStageFixtures from 'test_fixtures/analytics/value_stream_analytics/stages/staging/records.json';
import issueCountFixture from 'test_fixtures/analytics/value_stream_analytics/stages/issue/count.json';
import planCountFixture from 'test_fixtures/analytics/value_stream_analytics/stages/plan/count.json';
import reviewCountFixture from 'test_fixtures/analytics/value_stream_analytics/stages/review/count.json';
import codeCountFixture from 'test_fixtures/analytics/value_stream_analytics/stages/code/count.json';
import testCountFixture from 'test_fixtures/analytics/value_stream_analytics/stages/test/count.json';
import stagingCountFixture from 'test_fixtures/analytics/value_stream_analytics/stages/staging/count.json';
import { import {
TASKS_BY_TYPE_SUBJECT_ISSUE, TASKS_BY_TYPE_SUBJECT_ISSUE,
OVERVIEW_STAGE_CONFIG, OVERVIEW_STAGE_CONFIG,
...@@ -12,10 +29,8 @@ import { ...@@ -12,10 +29,8 @@ import {
getTasksByTypeData, getTasksByTypeData,
transformRawTasksByTypeData, transformRawTasksByTypeData,
} from 'ee/analytics/cycle_analytics/utils'; } from 'ee/analytics/cycle_analytics/utils';
import { getJSONFixture } from 'helpers/fixtures';
import { import {
getStageByTitle, getStageByTitle,
defaultStages,
rawStageMedians, rawStageMedians,
createdBefore, createdBefore,
createdAfter, createdAfter,
...@@ -26,16 +41,6 @@ import { transformStagesForPathNavigation, formatMedianValues } from '~/cycle_an ...@@ -26,16 +41,6 @@ import { transformStagesForPathNavigation, formatMedianValues } from '~/cycle_an
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { getDatesInRange } from '~/lib/utils/datetime_utility'; import { getDatesInRange } from '~/lib/utils/datetime_utility';
const fixtureEndpoints = {
customizableCycleAnalyticsStagesAndEvents: 'analytics/value_stream_analytics/stages.json', // customizable stages and events endpoint
stageEvents: (stage) => `analytics/value_stream_analytics/stages/${stage}/records.json`,
stageMedian: (stage) => `analytics/value_stream_analytics/stages/${stage}/median.json`,
stageCount: (stage) => `analytics/value_stream_analytics/stages/${stage}/count.json`,
recentActivityData: 'analytics/metrics/value_stream_analytics/summary.json',
timeMetricsData: 'analytics/metrics/value_stream_analytics/time_summary.json',
groupLabels: 'api/group_labels.json',
};
export const endpoints = { export const endpoints = {
groupLabels: /groups\/[A-Z|a-z|\d|\-|_]+\/-\/labels.json/, groupLabels: /groups\/[A-Z|a-z|\d|\-|_]+\/-\/labels.json/,
recentActivityData: /analytics\/value_stream_analytics\/summary/, recentActivityData: /analytics\/value_stream_analytics\/summary/,
...@@ -55,16 +60,13 @@ export const valueStreams = [ ...@@ -55,16 +60,13 @@ export const valueStreams = [
{ id: 2, name: 'Value stream 2' }, { id: 2, name: 'Value stream 2' },
]; ];
export const groupLabels = getJSONFixture(fixtureEndpoints.groupLabels).map( export const groupLabels = apiGroupLabels.map(convertObjectPropsToCamelCase);
convertObjectPropsToCamelCase,
);
export const recentActivityData = getJSONFixture(fixtureEndpoints.recentActivityData); export const recentActivityData = valueStreamAnalyticsSummary;
export const timeMetricsData = getJSONFixture(fixtureEndpoints.timeMetricsData);
export const customizableStagesAndEvents = getJSONFixture( export const timeMetricsData = valueStreamAnalyticsTimeSummary;
fixtureEndpoints.customizableCycleAnalyticsStagesAndEvents,
); export const customizableStagesAndEvents = valueStreamAnalyticsStages;
const dummyState = {}; const dummyState = {};
...@@ -104,13 +106,14 @@ export const stagingStage = getStageByTitle(dummyState.stages, 'staging'); ...@@ -104,13 +106,14 @@ export const stagingStage = getStageByTitle(dummyState.stages, 'staging');
export const allowedStages = [issueStage, planStage, codeStage]; export const allowedStages = [issueStage, planStage, codeStage];
const stageFixtures = defaultStages.reduce((acc, stage) => { const stageFixtures = {
const events = getJSONFixture(fixtureEndpoints.stageEvents(stage)); issue: issueStageFixtures,
return { plan: planStageFixtures,
...acc, review: reviewStageFixtures,
[stage]: events, code: codeStageFixtures,
}; test: testStageFixtures,
}, {}); staging: stagingStageFixtures,
};
const getStageId = (name) => { const getStageId = (name) => {
const { id } = getStageByTitle(dummyState.stages, name); const { id } = getStageByTitle(dummyState.stages, name);
...@@ -124,10 +127,32 @@ export const stageMediansWithNumericIds = formatMedianValues( ...@@ -124,10 +127,32 @@ export const stageMediansWithNumericIds = formatMedianValues(
}), }),
); );
export const rawStageCounts = defaultStages.map((id) => ({ export const rawStageCounts = [
id, {
...getJSONFixture(fixtureEndpoints.stageCount(id)), id: 'issue',
})); ...issueCountFixture,
},
{
id: 'plan',
...planCountFixture,
},
{
id: 'review',
...reviewCountFixture,
},
{
id: 'code',
...codeCountFixture,
},
{
id: 'test',
...testCountFixture,
},
{
id: 'staging',
...stagingCountFixture,
},
];
export const stageCounts = rawStageCounts.reduce((acc, { id: name, count }) => { export const stageCounts = rawStageCounts.reduce((acc, { id: name, count }) => {
const id = getStageId(name); const id = getStageId(name);
......
/* eslint-disable import/no-deprecated */ import valueStreamAnalyticsStages from 'test_fixtures/projects/analytics/value_stream_analytics/stages.json';
import valueStreamAnalyticsSummary from 'test_fixtures/projects/analytics/value_stream_analytics/summary.json';
import issueStageFixtures from 'test_fixtures/projects/analytics/value_stream_analytics/events/issue.json';
import planStageFixtures from 'test_fixtures/projects/analytics/value_stream_analytics/events/plan.json';
import reviewStageFixtures from 'test_fixtures/projects/analytics/value_stream_analytics/events/review.json';
import codeStageFixtures from 'test_fixtures/projects/analytics/value_stream_analytics/events/code.json';
import testStageFixtures from 'test_fixtures/projects/analytics/value_stream_analytics/events/test.json';
import stagingStageFixtures from 'test_fixtures/projects/analytics/value_stream_analytics/events/staging.json';
import { getJSONFixture } from 'helpers/fixtures';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { import {
DEFAULT_VALUE_STREAM, DEFAULT_VALUE_STREAM,
...@@ -20,28 +26,20 @@ export const deepCamelCase = (obj) => convertObjectPropsToCamelCase(obj, { deep: ...@@ -20,28 +26,20 @@ export const deepCamelCase = (obj) => convertObjectPropsToCamelCase(obj, { deep:
export const getStageByTitle = (stages, title) => export const getStageByTitle = (stages, title) =>
stages.find((stage) => stage.title && stage.title.toLowerCase().trim() === title) || {}; stages.find((stage) => stage.title && stage.title.toLowerCase().trim() === title) || {};
const fixtureEndpoints = { export const metricsData = valueStreamAnalyticsSummary;
customizableCycleAnalyticsStagesAndEvents:
'projects/analytics/value_stream_analytics/stages.json',
stageEvents: (stage) => `projects/analytics/value_stream_analytics/events/${stage}.json`,
metricsData: 'projects/analytics/value_stream_analytics/summary.json',
};
export const metricsData = getJSONFixture(fixtureEndpoints.metricsData);
export const customizableStagesAndEvents = getJSONFixture( export const customizableStagesAndEvents = valueStreamAnalyticsStages;
fixtureEndpoints.customizableCycleAnalyticsStagesAndEvents,
);
export const defaultStages = ['issue', 'plan', 'review', 'code', 'test', 'staging']; export const defaultStages = ['issue', 'plan', 'review', 'code', 'test', 'staging'];
const stageFixtures = defaultStages.reduce((acc, stage) => { const stageFixtures = {
const events = getJSONFixture(fixtureEndpoints.stageEvents(stage)); issue: issueStageFixtures,
return { plan: planStageFixtures,
...acc, review: reviewStageFixtures,
[stage]: events, code: codeStageFixtures,
}; test: testStageFixtures,
}, {}); staging: stagingStageFixtures,
};
export const summary = [ export const summary = [
{ value: '20', title: 'New Issues' }, { value: '20', title: 'New Issues' },
......
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