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
3a47e385
Commit
3a47e385
authored
Jul 21, 2020
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use activeStages for fetchStageMedianValues
parent
1f640eae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
30 deletions
+50
-30
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
...ts/javascripts/analytics/cycle_analytics/store/actions.js
+3
-4
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
.../frontend/analytics/cycle_analytics/store/actions_spec.js
+47
-26
No files found.
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
View file @
3a47e385
...
...
@@ -71,10 +71,9 @@ const fetchStageMedian = (currentGroupPath, stageId, params) =>
...
data
,
}));
export
const
fetchStageMedianValues
=
({
state
,
dispatch
,
getters
})
=>
{
const
{
currentGroupPath
,
cycleAnalyticsRequestParams
}
=
getters
;
const
{
stages
}
=
state
;
const
stageIds
=
stages
.
map
(
s
=>
s
.
slug
);
export
const
fetchStageMedianValues
=
({
dispatch
,
getters
})
=>
{
const
{
currentGroupPath
,
cycleAnalyticsRequestParams
,
activeStages
}
=
getters
;
const
stageIds
=
activeStages
.
map
(
s
=>
s
.
slug
);
dispatch
(
'
requestStageMedianValues
'
);
return
Promise
.
all
(
...
...
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
View file @
3a47e385
...
...
@@ -18,7 +18,12 @@ import {
const
stageData
=
{
events
:
[]
};
const
error
=
new
Error
(
`Request failed with status code
${
httpStatusCodes
.
NOT_FOUND
}
`
);
const
flashErrorMessage
=
'
There was an error while fetching value stream analytics data.
'
;
const
[
selectedStage
]
=
stages
;
stages
[
0
].
hidden
=
true
;
const
activeStages
=
stages
.
filter
(({
hidden
})
=>
!
hidden
);
const
hiddenStage
=
stages
[
0
];
const
[
selectedStage
]
=
activeStages
;
const
selectedStageSlug
=
selectedStage
.
slug
;
const
stageEndpoint
=
({
stageId
})
=>
...
...
@@ -44,6 +49,7 @@ describe('Cycle analytics actions', () => {
hasDurationChart
:
true
,
hasDurationChartMedian
:
true
,
},
activeStages
,
};
mock
=
new
MockAdapter
(
axios
);
});
...
...
@@ -262,7 +268,10 @@ describe('Cycle analytics actions', () => {
.
mockImplementation
(
actions
.
receiveStageMedianValuesError
({
commit
:
()
=>
{}
})),
commit
:
()
=>
{},
state
:
{
...
state
},
getters
,
getters
:
{
...
getters
,
activeStages
,
},
}),
});
...
...
@@ -374,9 +383,7 @@ describe('Cycle analytics actions', () => {
return
testAction
(
actions
.
setDefaultSelectedStage
,
null
,
{
activeStages
:
stages
,
},
state
,
[],
[
{
type
:
'
setSelectedStage
'
,
payload
:
selectedStage
},
...
...
@@ -395,13 +402,10 @@ describe('Cycle analytics actions', () => {
});
it
(
'
will select the first active stage
'
,
()
=>
{
stages
[
0
].
hidden
=
true
;
return
testAction
(
actions
.
setDefaultSelectedStage
,
null
,
{
activeStages
:
getters
.
activeStages
({
stages
}),
},
state
,
[],
[
{
type
:
'
setSelectedStage
'
,
payload
:
stages
[
1
]
},
...
...
@@ -644,26 +648,44 @@ describe('Cycle analytics actions', () => {
describe
(
'
fetchStageMedianValues
'
,
()
=>
{
let
mockDispatch
=
jest
.
fn
();
const
fetchMedianResponse
=
activeStages
.
map
(({
slug
:
id
})
=>
({
events
:
[],
id
}));
beforeEach
(()
=>
{
state
=
{
...
state
,
stages
:
[{
slug
:
selectedStageSlug
}]
,
selectedGroup
};
state
=
{
...
state
,
stages
,
selectedGroup
};
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
endpoints
.
stageMedian
).
reply
(
200
,
{
events
:
[]
});
mockDispatch
=
jest
.
fn
();
});
it
(
'
dispatches receiveStageMedianValuesSuccess with received data on success
'
,
()
=>
{
return
testAction
(
actions
.
fetchStageMedianValues
,
null
,
state
,
[],
[
{
type
:
'
requestStageMedianValues
'
},
{
type
:
'
receiveStageMedianValuesSuccess
'
,
payload
:
fetchMedianResponse
},
],
);
});
it
(
'
does not request hidden stages
'
,
()
=>
{
return
actions
.
fetchStageMedianValues
({
state
,
getters
,
getters
:
{
...
getters
,
activeStages
,
},
commit
:
()
=>
{},
dispatch
:
mockDispatch
,
})
.
then
(()
=>
{
expect
(
mockDispatch
).
toHaveBeenCalledWith
(
'
requestStageMedianValues
'
);
expect
(
mockDispatch
).
toHaveBeenCalledWith
(
'
receiveStageMedianValuesSuccess
'
,
[
{
events
:
[],
id
:
selectedStageSlug
}
,
]
);
expect
(
mockDispatch
).
not
.
toHaveBeenCalledWith
(
'
receiveStageMedianValuesSuccess
'
,
{
events
:
[],
id
:
hiddenStage
.
id
,
}
);
});
});
...
...
@@ -673,17 +695,16 @@ describe('Cycle analytics actions', () => {
});
it
(
'
will dispatch receiveStageMedianValuesError
'
,
()
=>
{
return
actions
.
fetchStageMedianValues
({
state
,
getters
,
commit
:
()
=>
{},
dispatch
:
mockDispatch
,
})
.
then
(()
=>
{
expect
(
mockDispatch
).
toHaveBeenCalledWith
(
'
requestStageMedianValues
'
);
expect
(
mockDispatch
).
toHaveBeenCalledWith
(
'
receiveStageMedianValuesError
'
,
error
);
});
return
testAction
(
actions
.
fetchStageMedianValues
,
null
,
state
,
[],
[
{
type
:
'
requestStageMedianValues
'
},
{
type
:
'
receiveStageMedianValuesError
'
,
payload
:
error
},
],
);
});
});
});
...
...
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