Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fbe3c417
Commit
fbe3c417
authored
Jul 29, 2020
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactor vsa api requests
Updates the remaining vsa routes to include value stream id
parent
2f9231ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
116 deletions
+83
-116
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
...ts/javascripts/analytics/cycle_analytics/store/actions.js
+13
-37
ee/app/assets/javascripts/analytics/cycle_analytics/store/modules/custom_stages/actions.js
...cs/cycle_analytics/store/modules/custom_stages/actions.js
+3
-7
ee/app/assets/javascripts/api.js
ee/app/assets/javascripts/api.js
+19
-27
ee/spec/frontend/api_spec.js
ee/spec/frontend/api_spec.js
+48
-45
No files found.
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
View file @
fbe3c417
...
@@ -154,22 +154,7 @@ export const receiveGroupStagesSuccess = ({ commit, dispatch }, stages) => {
...
@@ -154,22 +154,7 @@ export const receiveGroupStagesSuccess = ({ commit, dispatch }, stages) => {
return
dispatch
(
'
setDefaultSelectedStage
'
);
return
dispatch
(
'
setDefaultSelectedStage
'
);
};
};
export
const
fetchValueStreamStages
=
({
export
const
fetchGroupStagesAndEvents
=
({
dispatch
,
getters
})
=>
{
hasCreateMultipleValueStreams
,
valueStreamId
,
groupId
,
params
,
})
=>
{
return
hasCreateMultipleValueStreams
?
Api
.
cycleAnalyticsValueStreamGroupStagesAndEvents
(
groupId
,
valueStreamId
,
params
)
:
Api
.
cycleAnalyticsGroupStagesAndEvents
(
groupId
,
params
);
};
export
const
fetchGroupStagesAndEvents
=
({
state
,
dispatch
,
getters
})
=>
{
const
{
featureFlags
:
{
hasCreateMultipleValueStreams
=
false
},
}
=
state
;
const
{
const
{
currentValueStreamId
:
valueStreamId
,
currentValueStreamId
:
valueStreamId
,
currentGroupPath
:
groupId
,
currentGroupPath
:
groupId
,
...
@@ -178,8 +163,7 @@ export const fetchGroupStagesAndEvents = ({ state, dispatch, getters }) => {
...
@@ -178,8 +163,7 @@ export const fetchGroupStagesAndEvents = ({ state, dispatch, getters }) => {
dispatch
(
'
requestGroupStages
'
);
dispatch
(
'
requestGroupStages
'
);
dispatch
(
'
customStages/setStageEvents
'
,
[]);
dispatch
(
'
customStages/setStageEvents
'
,
[]);
return
fetchValueStreamStages
({
return
Api
.
cycleAnalyticsGroupStagesAndEvents
({
hasCreateMultipleValueStreams
,
groupId
,
groupId
,
valueStreamId
,
valueStreamId
,
params
:
{
start_date
:
created_after
,
project_ids
},
params
:
{
start_date
:
created_after
,
project_ids
},
...
@@ -224,18 +208,16 @@ export const receiveUpdateStageError = (
...
@@ -224,18 +208,16 @@ export const receiveUpdateStageError = (
return
dispatch
(
'
customStages/setStageFormErrors
'
,
errors
);
return
dispatch
(
'
customStages/setStageFormErrors
'
,
errors
);
};
};
export
const
updateStage
=
({
dispatch
,
state
},
{
id
,
...
rest
})
=>
{
export
const
updateStage
=
({
dispatch
,
getters
},
{
id
,
...
params
})
=>
{
const
{
const
{
currentGroupPath
,
currentValueStreamId
}
=
getters
;
selectedGroup
:
{
fullPath
},
}
=
state
;
dispatch
(
'
requestUpdateStage
'
);
dispatch
(
'
requestUpdateStage
'
);
dispatch
(
'
customStages/setSavingCustomStage
'
);
dispatch
(
'
customStages/setSavingCustomStage
'
);
return
Api
.
cycleAnalyticsUpdateStage
(
id
,
fullPath
,
{
...
rest
}
)
return
Api
.
cycleAnalyticsUpdateStage
(
currentGroupPath
,
currentValueStreamId
,
id
,
params
)
.
then
(({
data
})
=>
dispatch
(
'
receiveUpdateStageSuccess
'
,
data
))
.
then
(({
data
})
=>
dispatch
(
'
receiveUpdateStageSuccess
'
,
data
))
.
catch
(({
response
:
{
status
=
400
,
data
:
responseData
}
=
{}
})
=>
.
catch
(({
response
:
{
status
=
400
,
data
:
responseData
}
=
{}
})
=>
dispatch
(
'
receiveUpdateStageError
'
,
{
status
,
responseData
,
data
:
{
id
,
...
rest
}
}),
dispatch
(
'
receiveUpdateStageError
'
,
{
status
,
responseData
,
data
:
{
id
,
...
params
}
}),
);
);
};
};
...
@@ -300,17 +282,14 @@ export const receiveReorderStageError = ({ commit }) => {
...
@@ -300,17 +282,14 @@ export const receiveReorderStageError = ({ commit }) => {
createFlash
(
__
(
'
There was an error updating the stage order. Please try reloading the page.
'
));
createFlash
(
__
(
'
There was an error updating the stage order. Please try reloading the page.
'
));
};
};
export
const
reorderStage
=
({
dispatch
,
state
},
initialData
)
=>
{
export
const
reorderStage
=
({
dispatch
,
getters
},
initialData
)
=>
{
dispatch
(
'
requestReorderStage
'
);
dispatch
(
'
requestReorderStage
'
);
const
{
currentGroupPath
,
currentValueStreamId
}
=
getters
;
const
{
selectedGroup
:
{
fullPath
},
}
=
state
;
const
{
id
,
moveAfterId
,
moveBeforeId
}
=
initialData
;
const
{
id
,
moveAfterId
,
moveBeforeId
}
=
initialData
;
const
params
=
moveAfterId
?
{
move_after_id
:
moveAfterId
}
:
{
move_before_id
:
moveBeforeId
};
const
params
=
moveAfterId
?
{
move_after_id
:
moveAfterId
}
:
{
move_before_id
:
moveBeforeId
};
return
Api
.
cycleAnalyticsUpdateStage
(
id
,
fullPath
,
params
)
return
Api
.
cycleAnalyticsUpdateStage
(
currentGroupPath
,
currentValueStreamId
,
id
,
params
)
.
then
(({
data
})
=>
dispatch
(
'
receiveReorderStageSuccess
'
,
data
))
.
then
(({
data
})
=>
dispatch
(
'
receiveReorderStageSuccess
'
,
data
))
.
catch
(({
response
:
{
status
=
400
,
data
:
responseData
}
=
{}
})
=>
.
catch
(({
response
:
{
status
=
400
,
data
:
responseData
}
=
{}
})
=>
dispatch
(
'
receiveReorderStageError
'
,
{
status
,
responseData
}),
dispatch
(
'
receiveReorderStageError
'
,
{
status
,
responseData
}),
...
@@ -322,14 +301,11 @@ export const receiveCreateValueStreamSuccess = ({ commit, dispatch }) => {
...
@@ -322,14 +301,11 @@ export const receiveCreateValueStreamSuccess = ({ commit, dispatch }) => {
return
dispatch
(
'
fetchValueStreams
'
);
return
dispatch
(
'
fetchValueStreams
'
);
};
};
export
const
createValueStream
=
({
commit
,
dispatch
,
rootState
},
data
)
=>
{
export
const
createValueStream
=
({
commit
,
dispatch
,
getters
},
data
)
=>
{
const
{
const
{
currentGroupPath
}
=
getters
;
selectedGroup
:
{
fullPath
},
commit
(
types
.
REQUEST_CREATE_VALUE_STREAM
);
cycleAnalyticsSummaryData
}
=
rootState
;
commit
(
types
.
REQUEST_CREATE_VALUE_STREAM
);
return
Api
.
cycleAnalyticsCreateValueStream
(
full
Path
,
data
)
return
Api
.
cycleAnalyticsCreateValueStream
(
currentGroup
Path
,
data
)
.
then
(()
=>
dispatch
(
'
receiveCreateValueStreamSuccess
'
))
.
then
(()
=>
dispatch
(
'
receiveCreateValueStreamSuccess
'
))
.
catch
(({
response
}
=
{})
=>
{
.
catch
(({
response
}
=
{})
=>
{
const
{
data
:
{
message
,
payload
:
{
errors
}
}
=
null
}
=
response
;
const
{
data
:
{
message
,
payload
:
{
errors
}
}
=
null
}
=
response
;
...
...
ee/app/assets/javascripts/analytics/cycle_analytics/store/modules/custom_stages/actions.js
View file @
fbe3c417
...
@@ -65,17 +65,13 @@ export const receiveCreateStageError = (
...
@@ -65,17 +65,13 @@ export const receiveCreateStageError = (
return
dispatch
(
'
setStageFormErrors
'
,
errors
);
return
dispatch
(
'
setStageFormErrors
'
,
errors
);
};
};
export
const
createStage
=
({
dispatch
,
rootState
,
rootGetters
},
data
)
=>
{
export
const
createStage
=
({
dispatch
,
rootGetters
},
data
)
=>
{
const
{
const
{
currentGroupPath
,
currentValueStreamId
}
=
rootGetters
;
selectedGroup
:
{
fullPath
},
}
=
rootState
;
const
{
currentValueStreamId
}
=
rootGetters
;
dispatch
(
'
clearFormErrors
'
);
dispatch
(
'
clearFormErrors
'
);
dispatch
(
'
setSavingCustomStage
'
);
dispatch
(
'
setSavingCustomStage
'
);
return
Api
.
cycleAnalyticsCreateStage
(
full
Path
,
currentValueStreamId
,
data
)
return
Api
.
cycleAnalyticsCreateStage
(
currentGroup
Path
,
currentValueStreamId
,
data
)
.
then
(
response
=>
{
.
then
(
response
=>
{
const
{
status
,
data
:
responseData
}
=
response
;
const
{
status
,
data
:
responseData
}
=
response
;
return
dispatch
(
'
receiveCreateStageSuccess
'
,
{
status
,
data
:
responseData
});
return
dispatch
(
'
receiveCreateStageSuccess
'
,
{
status
,
data
:
responseData
});
...
...
ee/app/assets/javascripts/api.js
View file @
fbe3c417
...
@@ -14,19 +14,17 @@ export default {
...
@@ -14,19 +14,17 @@ export default {
cycleAnalyticsTopLabelsPath
:
'
/groups/:id/-/analytics/type_of_work/tasks_by_type/top_labels
'
,
cycleAnalyticsTopLabelsPath
:
'
/groups/:id/-/analytics/type_of_work/tasks_by_type/top_labels
'
,
cycleAnalyticsSummaryDataPath
:
'
/groups/:id/-/analytics/value_stream_analytics/summary
'
,
cycleAnalyticsSummaryDataPath
:
'
/groups/:id/-/analytics/value_stream_analytics/summary
'
,
cycleAnalyticsTimeSummaryDataPath
:
'
/groups/:id/-/analytics/value_stream_analytics/time_summary
'
,
cycleAnalyticsTimeSummaryDataPath
:
'
/groups/:id/-/analytics/value_stream_analytics/time_summary
'
,
cycleAnalyticsGroupStagesAndEventsPath
:
'
/groups/:id/-/analytics/value_stream_analytics/stages
'
,
cycleAnalyticsGroupStagesAndEventsPath
:
cycleAnalyticsValueStreamGroupStagesAndEventsPath
:
'
/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages
'
,
'
/groups/:group_id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages
'
,
cycleAnalyticsValueStreamsPath
:
'
/groups/:id/-/analytics/value_stream_analytics/value_streams
'
,
cycleAnalyticsValueStreamsPath
:
'
/groups/:group_id/-/analytics/value_stream_analytics/value_streams
'
,
cycleAnalyticsStageEventsPath
:
cycleAnalyticsStageEventsPath
:
'
/groups/:
group_
id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/records
'
,
'
/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/records
'
,
cycleAnalyticsStageMedianPath
:
cycleAnalyticsStageMedianPath
:
'
/groups/:
group_
id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/median
'
,
'
/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/median
'
,
cycleAnalyticsStagePath
:
cycleAnalyticsStagePath
:
'
/groups/:
group_
id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id
'
,
'
/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id
'
,
cycleAnalyticsDurationChartPath
:
cycleAnalyticsDurationChartPath
:
'
/groups/:
group_
id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/duration_chart
'
,
'
/groups/:id/-/analytics/value_stream_analytics/value_streams/:value_stream_id/stages/:stage_id/duration_chart
'
,
cycleAnalyticsGroupLabelsPath
:
'
/groups/:namespace_path/-/labels.json
'
,
cycleAnalyticsGroupLabelsPath
:
'
/groups/:namespace_path/-/labels.json
'
,
codeReviewAnalyticsPath
:
'
/api/:version/analytics/code_review
'
,
codeReviewAnalyticsPath
:
'
/api/:version/analytics/code_review
'
,
groupActivityIssuesPath
:
'
/api/:version/analytics/group_activity/issues_count
'
,
groupActivityIssuesPath
:
'
/api/:version/analytics/group_activity/issues_count
'
,
...
@@ -140,15 +138,9 @@ export default {
...
@@ -140,15 +138,9 @@ export default {
return
axios
.
get
(
url
,
{
params
});
return
axios
.
get
(
url
,
{
params
});
},
},
cycleAnalyticsGroupStagesAndEvents
(
groupId
,
params
=
{})
{
cycleAnalyticsGroupStagesAndEvents
(
groupId
,
valueStreamId
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsGroupStagesAndEventsPath
).
replace
(
'
:id
'
,
groupId
);
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsGroupStagesAndEventsPath
)
.
replace
(
'
:id
'
,
groupId
)
return
axios
.
get
(
url
,
{
params
});
},
cycleAnalyticsValueStreamGroupStagesAndEvents
(
groupId
,
valueStreamId
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsValueStreamGroupStagesAndEventsPath
)
.
replace
(
'
:group_id
'
,
groupId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
);
.
replace
(
'
:value_stream_id
'
,
valueStreamId
);
return
axios
.
get
(
url
,
{
params
});
return
axios
.
get
(
url
,
{
params
});
...
@@ -156,8 +148,8 @@ export default {
...
@@ -156,8 +148,8 @@ export default {
cycleAnalyticsStageEvents
(
groupId
,
valueStreamId
,
stageId
,
params
=
{})
{
cycleAnalyticsStageEvents
(
groupId
,
valueStreamId
,
stageId
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsStageEventsPath
)
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsStageEventsPath
)
.
replace
(
'
:id
'
,
groupId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:group_id
'
,
groupId
)
.
replace
(
'
:stage_id
'
,
stageId
);
.
replace
(
'
:stage_id
'
,
stageId
);
return
axios
.
get
(
url
,
{
params
});
return
axios
.
get
(
url
,
{
params
});
...
@@ -165,7 +157,7 @@ export default {
...
@@ -165,7 +157,7 @@ export default {
cycleAnalyticsStageMedian
(
groupId
,
valueStreamId
,
stageId
,
params
=
{})
{
cycleAnalyticsStageMedian
(
groupId
,
valueStreamId
,
stageId
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsStageMedianPath
)
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsStageMedianPath
)
.
replace
(
'
:
group_
id
'
,
groupId
)
.
replace
(
'
:id
'
,
groupId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:stage_id
'
,
stageId
);
.
replace
(
'
:stage_id
'
,
stageId
);
...
@@ -173,32 +165,32 @@ export default {
...
@@ -173,32 +165,32 @@ export default {
},
},
cycleAnalyticsCreateStage
(
groupId
,
valueStreamId
,
data
)
{
cycleAnalyticsCreateStage
(
groupId
,
valueStreamId
,
data
)
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalytics
ValueStream
GroupStagesAndEventsPath
)
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsGroupStagesAndEventsPath
)
.
replace
(
'
:
group_
id
'
,
groupId
)
.
replace
(
'
:id
'
,
groupId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
);
.
replace
(
'
:value_stream_id
'
,
valueStreamId
);
return
axios
.
post
(
url
,
data
);
return
axios
.
post
(
url
,
data
);
},
},
cycleAnalyticsCreateValueStream
(
groupId
,
data
)
{
cycleAnalyticsCreateValueStream
(
groupId
,
data
)
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsValueStreamsPath
).
replace
(
'
:
group_
id
'
,
groupId
);
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsValueStreamsPath
).
replace
(
'
:id
'
,
groupId
);
return
axios
.
post
(
url
,
data
);
return
axios
.
post
(
url
,
data
);
},
},
cycleAnalyticsValueStreams
(
groupId
,
data
)
{
cycleAnalyticsValueStreams
(
groupId
,
data
)
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsValueStreamsPath
).
replace
(
'
:
group_
id
'
,
groupId
);
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsValueStreamsPath
).
replace
(
'
:id
'
,
groupId
);
return
axios
.
get
(
url
,
data
);
return
axios
.
get
(
url
,
data
);
},
},
cycleAnalyticsStageUrl
(
groupId
,
valueStreamId
,
stageId
)
{
cycleAnalyticsStageUrl
(
groupId
,
valueStreamId
,
stageId
)
{
return
Api
.
buildUrl
(
this
.
cycleAnalyticsStagePath
)
return
Api
.
buildUrl
(
this
.
cycleAnalyticsStagePath
)
.
replace
(
'
:
group_
id
'
,
groupId
)
.
replace
(
'
:id
'
,
groupId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:stage_id
'
,
stageId
);
.
replace
(
'
:stage_id
'
,
stageId
);
},
},
cycleAnalyticsUpdateStage
(
groupId
,
valueStreamId
,
stageId
,
data
)
{
cycleAnalyticsUpdateStage
(
groupId
,
valueStreamId
,
stageId
,
data
)
{
const
url
=
this
.
cycleAnalyticsStageUrl
(
valueStreamId
,
stageId
,
group
Id
);
const
url
=
this
.
cycleAnalyticsStageUrl
(
groupId
,
valueStreamId
,
stage
Id
);
return
axios
.
put
(
url
,
data
);
return
axios
.
put
(
url
,
data
);
},
},
...
@@ -211,7 +203,7 @@ export default {
...
@@ -211,7 +203,7 @@ export default {
cycleAnalyticsDurationChart
(
groupId
,
valueStreamId
,
stageSlug
,
params
=
{})
{
cycleAnalyticsDurationChart
(
groupId
,
valueStreamId
,
stageSlug
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsDurationChartPath
)
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsDurationChartPath
)
.
replace
(
'
:
group_
id
'
,
groupId
)
.
replace
(
'
:id
'
,
groupId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:value_stream_id
'
,
valueStreamId
)
.
replace
(
'
:stage_id
'
,
stageSlug
);
.
replace
(
'
:stage_id
'
,
stageSlug
);
...
...
ee/spec/frontend/api_spec.js
View file @
fbe3c417
...
@@ -201,15 +201,18 @@ describe('Api', () => {
...
@@ -201,15 +201,18 @@ describe('Api', () => {
});
});
describe
(
'
Cycle analytics
'
,
()
=>
{
describe
(
'
Cycle analytics
'
,
()
=>
{
const
groupId
=
'
counting-54321
'
;
const
createdBefore
=
'
2019-11-18
'
;
const
createdBefore
=
'
2019-11-18
'
;
const
createdAfter
=
'
2019-08-18
'
;
const
createdAfter
=
'
2019-08-18
'
;
const
groupId
=
'
counting-54321
'
;
const
stageId
=
'
thursday
'
;
const
stageId
=
'
thursday
'
;
const
dummyCycleAnalyticsUrlRoot
=
`
${
dummyUrlRoot
}
/groups/
${
groupId
}
`
;
const
valueStreamId
=
'
a-city-by-the-light-divided
'
;
const
dummyCycleAnalyticsUrlRoot
=
`
${
dummyUrlRoot
}
/groups/
${
groupId
}
/-/analytics/value_stream_analytics`
;
const
defaultParams
=
{
const
defaultParams
=
{
created_after
:
createdAfter
,
created_after
:
createdAfter
,
created_before
:
createdBefore
,
created_before
:
createdBefore
,
};
};
const
valueStreamBaseUrl
=
({
resource
=
''
,
id
=
null
})
=>
[
dummyCycleAnalyticsUrlRoot
,
id
?
`value_streams/
${
id
}
/
${
resource
}
`
:
resource
].
join
(
'
/
'
);
const
expectRequestWithCorrectParameters
=
(
responseObj
,
{
params
,
expectedUrl
,
response
})
=>
{
const
expectRequestWithCorrectParameters
=
(
responseObj
,
{
params
,
expectedUrl
,
response
})
=>
{
const
{
const
{
...
@@ -288,11 +291,8 @@ describe('Api', () => {
...
@@ -288,11 +291,8 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsSummaryData
'
,
()
=>
{
describe
(
'
cycleAnalyticsSummaryData
'
,
()
=>
{
it
(
'
fetches value stream analytics summary data
'
,
done
=>
{
it
(
'
fetches value stream analytics summary data
'
,
done
=>
{
const
response
=
[{
value
:
0
,
title
:
'
New Issues
'
},
{
value
:
0
,
title
:
'
Deploys
'
}];
const
response
=
[{
value
:
0
,
title
:
'
New Issues
'
},
{
value
:
0
,
title
:
'
Deploys
'
}];
const
params
=
{
const
params
=
{
...
defaultParams
};
...
defaultParams
,
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/summary`
;
};
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/summary`
;
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsSummaryData
(
groupId
,
params
)
Api
.
cycleAnalyticsSummaryData
(
groupId
,
params
)
...
@@ -314,11 +314,9 @@ describe('Api', () => {
...
@@ -314,11 +314,9 @@ describe('Api', () => {
{
value
:
'
10.0
'
,
title
:
'
Lead time
'
,
unit
:
'
per day
'
},
{
value
:
'
10.0
'
,
title
:
'
Lead time
'
,
unit
:
'
per day
'
},
{
value
:
'
2.0
'
,
title
:
'
Cycle Time
'
,
unit
:
'
per day
'
},
{
value
:
'
2.0
'
,
title
:
'
Cycle Time
'
,
unit
:
'
per day
'
},
];
];
const
params
=
{
const
params
=
{
...
defaultParams
};
...
defaultParams
,
};
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/
-/analytics/value_stream_analytics/
time_summary`
;
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/time_summary`
;
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsTimeSummaryData
(
groupId
,
params
)
Api
.
cycleAnalyticsTimeSummaryData
(
groupId
,
params
)
...
@@ -337,8 +335,7 @@ describe('Api', () => {
...
@@ -337,8 +335,7 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsValueStreams
'
,
()
=>
{
describe
(
'
cycleAnalyticsValueStreams
'
,
()
=>
{
it
(
'
fetches custom value streams
'
,
done
=>
{
it
(
'
fetches custom value streams
'
,
done
=>
{
const
response
=
[{
name
:
'
value stream 1
'
,
id
:
1
}];
const
response
=
[{
name
:
'
value stream 1
'
,
id
:
1
}];
const
expectedUrl
=
valueStreamBaseUrl
({
resource
:
'
value_streams
'
});
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/value_streams`
;
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsValueStreams
(
groupId
)
Api
.
cycleAnalyticsValueStreams
(
groupId
)
...
@@ -356,10 +353,8 @@ describe('Api', () => {
...
@@ -356,10 +353,8 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsCreateValueStream
'
,
()
=>
{
describe
(
'
cycleAnalyticsCreateValueStream
'
,
()
=>
{
it
(
'
submit the custom value stream data
'
,
done
=>
{
it
(
'
submit the custom value stream data
'
,
done
=>
{
const
response
=
{};
const
response
=
{};
const
customValueStream
=
{
const
customValueStream
=
{
name
:
'
cool-value-stream-stage
'
};
name
:
'
cool-value-stream-stage
'
,
const
expectedUrl
=
valueStreamBaseUrl
({
resource
:
'
value_streams
'
});
};
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/value_streams`
;
mock
.
onPost
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onPost
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsCreateValueStream
(
groupId
,
customValueStream
)
Api
.
cycleAnalyticsCreateValueStream
(
groupId
,
customValueStream
)
...
@@ -381,10 +376,10 @@ describe('Api', () => {
...
@@ -381,10 +376,10 @@ describe('Api', () => {
'
cycle_analytics[created_after]
'
:
createdAfter
,
'
cycle_analytics[created_after]
'
:
createdAfter
,
'
cycle_analytics[created_before]
'
:
createdBefore
,
'
cycle_analytics[created_before]
'
:
createdBefore
,
};
};
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/stages`
;
const
expectedUrl
=
valueStreamBaseUrl
({
id
:
valueStreamId
,
resource
:
'
stages
'
})
;
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsGroupStagesAndEvents
(
groupId
,
params
)
Api
.
cycleAnalyticsGroupStagesAndEvents
(
groupId
,
valueStreamId
,
params
)
.
then
(
responseObj
=>
.
then
(
responseObj
=>
expectRequestWithCorrectParameters
(
responseObj
,
{
expectRequestWithCorrectParameters
(
responseObj
,
{
response
,
response
,
...
@@ -400,13 +395,14 @@ describe('Api', () => {
...
@@ -400,13 +395,14 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsStageEvents
'
,
()
=>
{
describe
(
'
cycleAnalyticsStageEvents
'
,
()
=>
{
it
(
'
fetches stage events
'
,
done
=>
{
it
(
'
fetches stage events
'
,
done
=>
{
const
response
=
{
events
:
[]
};
const
response
=
{
events
:
[]
};
const
params
=
{
const
params
=
{
...
defaultParams
};
...
defaultParams
,
const
expectedUrl
=
valueStreamBaseUrl
({
};
id
:
valueStreamId
,
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/stages/
${
stageId
}
/records`
;
resource
:
`stages/
${
stageId
}
/records`
,
});
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsStageEvents
(
groupId
,
stageId
,
params
)
Api
.
cycleAnalyticsStageEvents
(
groupId
,
valueStreamId
,
stageId
,
params
)
.
then
(
responseObj
=>
.
then
(
responseObj
=>
expectRequestWithCorrectParameters
(
responseObj
,
{
expectRequestWithCorrectParameters
(
responseObj
,
{
response
,
response
,
...
@@ -422,13 +418,14 @@ describe('Api', () => {
...
@@ -422,13 +418,14 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsStageMedian
'
,
()
=>
{
describe
(
'
cycleAnalyticsStageMedian
'
,
()
=>
{
it
(
'
fetches stage events
'
,
done
=>
{
it
(
'
fetches stage events
'
,
done
=>
{
const
response
=
{
value
:
'
5 days ago
'
};
const
response
=
{
value
:
'
5 days ago
'
};
const
params
=
{
const
params
=
{
...
defaultParams
};
...
defaultParams
,
const
expectedUrl
=
valueStreamBaseUrl
({
};
id
:
valueStreamId
,
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/stages/
${
stageId
}
/median`
;
resource
:
`stages/
${
stageId
}
/median`
,
});
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsStageMedian
(
groupId
,
stageId
,
params
)
Api
.
cycleAnalyticsStageMedian
(
groupId
,
valueStreamId
,
stageId
,
params
)
.
then
(
responseObj
=>
.
then
(
responseObj
=>
expectRequestWithCorrectParameters
(
responseObj
,
{
expectRequestWithCorrectParameters
(
responseObj
,
{
response
,
response
,
...
@@ -442,8 +439,6 @@ describe('Api', () => {
...
@@ -442,8 +439,6 @@ describe('Api', () => {
});
});
describe
(
'
cycleAnalyticsCreateStage
'
,
()
=>
{
describe
(
'
cycleAnalyticsCreateStage
'
,
()
=>
{
const
valueStreamId
=
'
fake-value-stream
'
;
it
(
'
submit the custom stage data
'
,
done
=>
{
it
(
'
submit the custom stage data
'
,
done
=>
{
const
response
=
{};
const
response
=
{};
const
customStage
=
{
const
customStage
=
{
...
@@ -453,7 +448,10 @@ describe('Api', () => {
...
@@ -453,7 +448,10 @@ describe('Api', () => {
end_event_identifier
:
'
issue_closed
'
,
end_event_identifier
:
'
issue_closed
'
,
end_event_label_id
:
null
,
end_event_label_id
:
null
,
};
};
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/value_streams/
${
valueStreamId
}
/stages`
;
const
expectedUrl
=
valueStreamBaseUrl
({
id
:
valueStreamId
,
resource
:
'
stages
'
,
});
mock
.
onPost
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onPost
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsCreateStage
(
groupId
,
valueStreamId
,
customStage
)
Api
.
cycleAnalyticsCreateStage
(
groupId
,
valueStreamId
,
customStage
)
...
@@ -462,6 +460,7 @@ describe('Api', () => {
...
@@ -462,6 +460,7 @@ describe('Api', () => {
expect
(
JSON
.
parse
(
reqData
)).
toMatchObject
(
customStage
);
expect
(
JSON
.
parse
(
reqData
)).
toMatchObject
(
customStage
);
expect
(
url
).
toEqual
(
expectedUrl
);
expect
(
url
).
toEqual
(
expectedUrl
);
})
})
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
...
@@ -470,14 +469,14 @@ describe('Api', () => {
...
@@ -470,14 +469,14 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsUpdateStage
'
,
()
=>
{
describe
(
'
cycleAnalyticsUpdateStage
'
,
()
=>
{
it
(
'
updates the stage data
'
,
done
=>
{
it
(
'
updates the stage data
'
,
done
=>
{
const
response
=
{
id
:
stageId
,
custom
:
false
,
hidden
:
true
,
name
:
'
nice-stage
'
};
const
response
=
{
id
:
stageId
,
custom
:
false
,
hidden
:
true
,
name
:
'
nice-stage
'
};
const
stageData
=
{
const
stageData
=
{
name
:
'
nice-stage
'
,
hidden
:
true
};
name
:
'
nice-stage
'
,
const
expectedUrl
=
valueStreamBaseUrl
({
hidden
:
true
,
id
:
valueStreamId
,
};
resource
:
`stages/
${
stageId
}
`
,
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/stages/
${
stageId
}
`
;
})
;
mock
.
onPut
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onPut
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsUpdateStage
(
stageId
,
group
Id
,
stageData
)
Api
.
cycleAnalyticsUpdateStage
(
groupId
,
valueStreamId
,
stage
Id
,
stageData
)
.
then
(({
data
,
config
:
{
data
:
reqData
,
url
}
})
=>
{
.
then
(({
data
,
config
:
{
data
:
reqData
,
url
}
})
=>
{
expect
(
data
).
toEqual
(
response
);
expect
(
data
).
toEqual
(
response
);
expect
(
JSON
.
parse
(
reqData
)).
toMatchObject
(
stageData
);
expect
(
JSON
.
parse
(
reqData
)).
toMatchObject
(
stageData
);
...
@@ -491,10 +490,13 @@ describe('Api', () => {
...
@@ -491,10 +490,13 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsRemoveStage
'
,
()
=>
{
describe
(
'
cycleAnalyticsRemoveStage
'
,
()
=>
{
it
(
'
deletes the specified data
'
,
done
=>
{
it
(
'
deletes the specified data
'
,
done
=>
{
const
response
=
{
id
:
stageId
,
hidden
:
true
,
custom
:
true
};
const
response
=
{
id
:
stageId
,
hidden
:
true
,
custom
:
true
};
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/stages/
${
stageId
}
`
;
const
expectedUrl
=
valueStreamBaseUrl
({
id
:
valueStreamId
,
resource
:
`stages/
${
stageId
}
`
,
});
mock
.
onDelete
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onDelete
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsRemoveStage
(
stageId
,
group
Id
)
Api
.
cycleAnalyticsRemoveStage
(
groupId
,
valueStreamId
,
stage
Id
)
.
then
(({
data
,
config
:
{
url
}
})
=>
{
.
then
(({
data
,
config
:
{
url
}
})
=>
{
expect
(
data
).
toEqual
(
response
);
expect
(
data
).
toEqual
(
response
);
...
@@ -508,13 +510,14 @@ describe('Api', () => {
...
@@ -508,13 +510,14 @@ describe('Api', () => {
describe
(
'
cycleAnalyticsDurationChart
'
,
()
=>
{
describe
(
'
cycleAnalyticsDurationChart
'
,
()
=>
{
it
(
'
fetches stage duration data
'
,
done
=>
{
it
(
'
fetches stage duration data
'
,
done
=>
{
const
response
=
[];
const
response
=
[];
const
params
=
{
const
params
=
{
...
defaultParams
};
...
defaultParams
,
const
expectedUrl
=
valueStreamBaseUrl
({
};
id
:
valueStreamId
,
const
expectedUrl
=
`
${
dummyCycleAnalyticsUrlRoot
}
/-/analytics/value_stream_analytics/stages/thursday/duration_chart`
;
resource
:
`stages/
${
stageId
}
/duration_chart`
,
});
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
response
);
Api
.
cycleAnalyticsDurationChart
(
groupId
,
stageId
,
params
)
Api
.
cycleAnalyticsDurationChart
(
groupId
,
valueStreamId
,
stageId
,
params
)
.
then
(
responseObj
=>
.
then
(
responseObj
=>
expectRequestWithCorrectParameters
(
responseObj
,
{
expectRequestWithCorrectParameters
(
responseObj
,
{
response
,
response
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment