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
df5fdb62
Commit
df5fdb62
authored
Nov 02, 2020
by
mfluharty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group coverage summary spec
parent
d16e1a49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
132 additions
and
0 deletions
+132
-0
ee/spec/frontend/analytics/repository_analytics/components/test_coverage_summary_spec.js
...sitory_analytics/components/test_coverage_summary_spec.js
+132
-0
No files found.
ee/spec/frontend/analytics/repository_analytics/components/test_coverage_summary_spec.js
0 → 100644
View file @
df5fdb62
import
{
GlDeprecatedSkeletonLoading
as
GlSkeletonLoading
}
from
'
@gitlab/ui
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
useFakeDate
}
from
'
helpers/fake_date
'
;
import
createMockApollo
from
'
jest/helpers/mock_apollo_helper
'
;
import
waitForPromises
from
'
jest/helpers/wait_for_promises
'
;
import
TestCoverageSummary
from
'
ee/analytics/repository_analytics/components/test_coverage_summary.vue
'
;
import
getGroupTestCoverage
from
'
ee/analytics/repository_analytics/graphql/queries/get_group_test_coverage.query.graphql
'
;
const
localVue
=
createLocalVue
();
describe
(
'
Test coverage table component
'
,
()
=>
{
useFakeDate
();
let
wrapper
;
let
fakeApollo
;
const
findProjectsWithTests
=
()
=>
wrapper
.
find
(
'
.js-metric-card-item:nth-child(1) h3
'
);
const
findAverageCoverage
=
()
=>
wrapper
.
find
(
'
.js-metric-card-item:nth-child(2) h3
'
);
const
findTotalCoverages
=
()
=>
wrapper
.
find
(
'
.js-metric-card-item:nth-child(3) h3
'
);
const
findLoadingState
=
()
=>
wrapper
.
find
(
GlSkeletonLoading
);
const
createComponent
=
({
data
=
{}
}
=
{})
=>
{
wrapper
=
mount
(
TestCoverageSummary
,
{
localVue
,
data
()
{
return
{
projectCount
:
null
,
averageCoverage
:
null
,
coverageCount
:
null
,
hasError
:
false
,
isLoading
:
false
,
...
data
,
};
},
mocks
:
{
$apollo
:
{
queries
:
{
group
:
{
query
:
jest
.
fn
().
mockResolvedValue
(),
},
},
},
},
});
};
const
createComponentWithApollo
=
({
data
=
{}
}
=
{})
=>
{
localVue
.
use
(
VueApollo
);
fakeApollo
=
createMockApollo
([[
getGroupTestCoverage
,
jest
.
fn
().
mockResolvedValue
()]]);
wrapper
=
mount
(
TestCoverageSummary
,
{
localVue
,
data
()
{
return
{
projectCount
:
null
,
averageCoverage
:
null
,
coverageCount
:
null
,
hasError
:
false
,
isLoading
:
false
,
...
data
,
};
},
apolloProvider
:
fakeApollo
,
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
describe
(
'
when group code coverage is empty
'
,
()
=>
{
it
(
'
renders empty metrics
'
,
()
=>
{
createComponent
();
expect
(
findProjectsWithTests
().
text
()).
toBe
(
'
-
'
);
expect
(
findAverageCoverage
().
text
()).
toBe
(
'
-
'
);
expect
(
findTotalCoverages
().
text
()).
toBe
(
'
-
'
);
});
});
describe
(
'
when query is loading
'
,
()
=>
{
it
(
'
renders loading state
'
,
()
=>
{
createComponent
({
data
:
{
isLoading
:
true
}
});
expect
(
findLoadingState
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
when group code coverage is available
'
,
()
=>
{
it
(
'
renders coverage metrics
'
,
()
=>
{
const
projectCount
=
'
5
'
;
const
averageCoverage
=
'
74.35
'
;
const
coverageCount
=
'
5
'
;
createComponent
({
data
:
{
projectCount
,
averageCoverage
,
coverageCount
,
},
});
expect
(
findProjectsWithTests
().
text
()).
toBe
(
projectCount
);
expect
(
findAverageCoverage
().
text
()).
toBe
(
`
${
averageCoverage
}
%`
);
expect
(
findTotalCoverages
().
text
()).
toBe
(
coverageCount
);
});
});
describe
(
'
when group has no coverage
'
,
()
=>
{
it
(
'
renders empty metrics
'
,
async
()
=>
{
createComponentWithApollo
({
data
:
{},
queryData
:
{
data
:
{
group
:
{
codeCoverageActivities
:
{
nodes
:
[],
},
},
},
},
});
jest
.
runOnlyPendingTimers
();
await
waitForPromises
();
expect
(
findProjectsWithTests
().
text
()).
toBe
(
'
-
'
);
expect
(
findAverageCoverage
().
text
()).
toBe
(
'
-
'
);
expect
(
findTotalCoverages
().
text
()).
toBe
(
'
-
'
);
});
});
});
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