Commit cbc0df46 authored by Nathan Friend's avatar Nathan Friend Committed by David O'Regan

Fix "Projects with release" stat when value is 0

This commit fixes a bug that prevented the "Projects with releases"
stat from being rendered when the value of the statistic was 0.
parent abcf5dbe
......@@ -59,7 +59,7 @@ export default {
return STAT_ERROR_PLACEHOLDER;
}
if (this.rawStats?.releasesPercentage) {
if (this.rawStats?.releasesPercentage != null) {
return sprintf(s__('CICDAnalytics|%{percent}%{percentSymbol}'), {
percent: this.rawStats?.releasesPercentage,
percentSymbol: '%',
......
---
title: Fix group-level "Projects with releases" stat when value is 0
merge_request: 60752
author:
type: fixed
import { GlSkeletonLoader, GlCard } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import ReleaseStatsCard from 'ee/analytics/group_ci_cd_analytics/components/release_stats_card.vue';
......@@ -77,6 +78,33 @@ describe('Release stats card', () => {
});
});
describe('when the data is successfully returned, but the stats are all 0', () => {
beforeEach(() => {
const responseWithZeros = merge({}, groupReleaseStatsQueryResponse, {
data: {
group: {
stats: {
releaseStats: {
releasesCount: 0,
releasesPercentage: 0,
},
},
},
},
});
const apolloProvider = createMockApollo([
[groupReleaseStatsQuery, jest.fn().mockResolvedValueOnce(responseWithZeros)],
]);
createComponent({ apolloProvider });
});
it('renders the statistics', () => {
expect(findStats().text()).toMatchInterpolatedText('0 Releases 0% Projects with releases');
});
});
describe('when an error occurs while loading data', () => {
beforeEach(() => {
const apolloProvider = createMockApollo([
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment