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
f9c64e5b
Commit
f9c64e5b
authored
Jul 30, 2020
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added additional specs
parent
58ae16f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
ee/app/assets/javascripts/analytics/cycle_analytics/utils.js
ee/app/assets/javascripts/analytics/cycle_analytics/utils.js
+22
-0
ee/spec/frontend/analytics/cycle_analytics/utils_spec.js
ee/spec/frontend/analytics/cycle_analytics/utils_spec.js
+32
-0
No files found.
ee/app/assets/javascripts/analytics/cycle_analytics/utils.js
View file @
f9c64e5b
...
...
@@ -379,6 +379,28 @@ export const transformStagesForPathNavigation = ({ stages, medians, selectedStag
);
};
/**
* @typedef {Object} MetricData
* @property {String} title - Title of the metric measured
* @property {String} value - String representing the decimal point value, e.g '1.5'
* @property {String} [unit] - String representing the decimal point value, e.g '1.5'
*
* @typedef {Object} TransformedMetricData
* @property {String} label - Title of the metric measured
* @property {String} value - String representing the decimal point value, e.g '1.5'
* @property {String} key - Slugified string based on the 'title'
* @property {String} [tooltipText] - String to display for aa tooltip
* @property {String} [unit] - String representing the decimal point value, e.g '1.5'
*/
/**
* Prepares metric data to be rendered in the metric_card component
*
* @param {MetricData[]} data - The metric data to be rendered
* @param {Object} [tooltipText] - Key value pair of strings to display in the tooltip
* @returns {TransformedMetricData[]} An array of metrics ready to render in the metric_card
*/
export
const
prepareTimeMetricsData
=
(
data
=
[],
tooltipText
=
{})
=>
data
.
map
(({
title
:
label
,
...
rest
})
=>
{
const
key
=
slugify
(
label
);
...
...
ee/spec/frontend/analytics/cycle_analytics/utils_spec.js
View file @
f9c64e5b
...
...
@@ -17,6 +17,7 @@ import {
orderByDate
,
toggleSelectedLabel
,
transformStagesForPathNavigation
,
prepareTimeMetricsData
,
}
from
'
ee/analytics/cycle_analytics/utils
'
;
import
{
toYmd
}
from
'
ee/analytics/shared/utils
'
;
import
{
...
...
@@ -38,6 +39,7 @@ import {
stageMediansWithNumericIds
,
totalStage
,
pathNavIssueMetric
,
timeMetricsData
,
}
from
'
./mock_data
'
;
import
{
CAPITALIZED_STAGE_NAME
,
PATH_HOME_ICON
}
from
'
ee/analytics/cycle_analytics/constants
'
;
...
...
@@ -368,4 +370,34 @@ describe('Cycle analytics utils', () => {
});
});
});
describe
(
'
prepareTimeMetricsData
'
,
()
=>
{
let
prepared
;
beforeEach
(()
=>
{
prepared
=
prepareTimeMetricsData
(
timeMetricsData
);
});
it
(
'
will add a `key` based on the title
'
,
()
=>
{
expect
(
timeMetricsData
).
not
.
toMatchObject
([{
key
:
'
lead-time
'
},
{
key
:
'
cycle-time
'
}]);
expect
(
prepared
).
toMatchObject
([{
key
:
'
lead-time
'
},
{
key
:
'
cycle-time
'
}]);
});
it
(
'
will replace the title with a `label` key
'
,
()
=>
{
expect
(
timeMetricsData
).
not
.
toMatchObject
([{
label
:
'
Lead Time
'
},
{
label
:
'
Cycle Time
'
}]);
expect
(
prepared
).
toMatchObject
([{
label
:
'
Lead Time
'
},
{
label
:
'
Cycle Time
'
}]);
});
it
(
'
will add tooltip text using the key if it is provided
'
,
()
=>
{
prepared
=
prepareTimeMetricsData
(
timeMetricsData
,
{
'
lead-time
'
:
'
Is a value that is good
'
,
});
expect
(
timeMetricsData
).
not
.
toMatchObject
([{
tooltipText
:
'
Is a value that is good
'
}]);
expect
(
prepared
).
toMatchObject
([
{
tooltipText
:
'
Is a value that is good
'
},
{
tooltipText
:
''
},
]);
});
});
});
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