aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap8
3 files changed, 15 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx
index 4f833156d2f..fce96f6e707 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx
@@ -38,6 +38,11 @@ export default function ProjectCardOverallMeasures({ measures }: Props) {
return null;
}
+ const { ncloc } = measures;
+ if (!ncloc) {
+ return <div className="note">{translate('overview.project.empty')}</div>;
+ }
+
return (
<div className="project-card-measures">
<div className="project-card-measure" data-key="reliability_rating">
diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx
index 51d54721b44..534b9e512d4 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx
@@ -70,7 +70,7 @@ it('should not render duplications', () => {
expect(wrapper.find('[data-key="duplicated_lines_density"]')).toMatchSnapshot();
});
-it('should not render ncloc', () => {
+it('should render empty', () => {
const measures = {
alert_status: 'ERROR',
bugs: '17',
@@ -82,8 +82,7 @@ it('should not render ncloc', () => {
sqale_rating: '1.0',
vulnerabilities: '0'
};
- const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />);
- expect(wrapper.find('[data-key="ncloc"]').length).toBe(0);
+ expect(shallow(<ProjectCardOverallMeasures measures={measures} />)).toMatchSnapshot();
});
it('should render ncloc correctly', () => {
diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap
index 48a600f9855..cc78296268a 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap
@@ -237,6 +237,14 @@ exports[`should render correctly with all data 1`] = `
</div>
`;
+exports[`should render empty 1`] = `
+<div
+ className="note"
+>
+ overview.project.empty
+</div>
+`;
+
exports[`should render ncloc correctly 1`] = `
<div
className="project-card-measure project-card-ncloc"