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
71c9853c
Commit
71c9853c
authored
May 11, 2020
by
Ezekiel Kigbo
Committed by
Martin Wortschack
May 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds additional specs for time summary data
parent
eaebe279
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
ee/spec/frontend/analytics/cycle_analytics/components/time_metrics_card_spec.js
...tics/cycle_analytics/components/time_metrics_card_spec.js
+84
-0
No files found.
ee/spec/frontend/analytics/cycle_analytics/components/time_metrics_card_spec.js
0 → 100644
View file @
71c9853c
import
{
mount
}
from
'
@vue/test-utils
'
;
import
createFlash
from
'
~/flash
'
;
import
TimeMetricsCard
from
'
ee/analytics/cycle_analytics/components/time_metrics_card.vue
'
;
import
{
group
,
timeMetricsData
}
from
'
../mock_data
'
;
import
Api
from
'
ee/api
'
;
describe
(
'
TimeMetricsCard
'
,
()
=>
{
const
{
full_path
:
groupPath
}
=
group
;
let
wrapper
;
const
createComponent
=
(
additionalParams
=
{})
=>
{
return
mount
(
TimeMetricsCard
,
{
propsData
:
{
groupPath
,
additionalParams
,
},
});
};
const
findMetricCards
=
()
=>
wrapper
.
findAll
(
'
.js-metric-card-item
'
);
beforeEach
(()
=>
{
jest
.
spyOn
(
Api
,
'
cycleAnalyticsTimeSummaryData
'
).
mockResolvedValue
({
data
:
timeMetricsData
});
wrapper
=
createComponent
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
it
(
'
matches the snapshot
'
,
()
=>
{
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
it
(
'
fetches the time metrics data
'
,
()
=>
{
expect
(
Api
.
cycleAnalyticsTimeSummaryData
).
toHaveBeenCalledWith
(
groupPath
,
{});
});
describe
(
'
with data
'
,
()
=>
{
it
.
each
`
metric | value | index
${
'
Lead time
'
}
|
${
'
2 days
'
}
|
${
0
}
${
'
Cycle time
'
}
|
${
'
1.5 days
'
}
|
${
1
}
`
(
'
Renders the $metric
'
,
({
metric
,
value
,
index
})
=>
{
const
card
=
findMetricCards
().
at
(
index
);
expect
(
card
.
html
()).
toContain
(
metric
);
expect
(
card
.
html
()).
toContain
(
value
);
});
});
describe
(
'
with a failing request
'
,
()
=>
{
beforeEach
(()
=>
{
jest
.
spyOn
(
Api
,
'
cycleAnalyticsTimeSummaryData
'
).
mockRejectedValue
();
wrapper
=
createComponent
();
});
it
(
'
should render an error message
'
,
()
=>
{
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
There was an error while fetching value stream analytics time metrics data.
'
,
);
});
});
describe
(
'
with additional params
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
({
'
project_ids[]
'
:
[
1
],
created_after
:
'
2020-01-01
'
,
created_before
:
'
2020-02-01
'
,
});
});
it
(
'
sends additional parameters as query paremeters
'
,
()
=>
{
expect
(
Api
.
cycleAnalyticsTimeSummaryData
).
toHaveBeenCalledWith
(
groupPath
,
{
'
project_ids[]
'
:
[
1
],
created_after
:
'
2020-01-01
'
,
created_before
:
'
2020-02-01
'
,
});
});
});
});
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