Commit d905b7b6 authored by David O'Regan's avatar David O'Regan

Merge branch 'nfriend-fix-projects-with-releases-stat' into 'master'

Fix group-level "Projects with releases" stats when stat is 0

See merge request gitlab-org/gitlab!60752
parents bb218f4f cbc0df46
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
return STAT_ERROR_PLACEHOLDER; return STAT_ERROR_PLACEHOLDER;
} }
if (this.rawStats?.releasesPercentage) { if (this.rawStats?.releasesPercentage != null) {
return sprintf(s__('CICDAnalytics|%{percent}%{percentSymbol}'), { return sprintf(s__('CICDAnalytics|%{percent}%{percentSymbol}'), {
percent: this.rawStats?.releasesPercentage, percent: this.rawStats?.releasesPercentage,
percentSymbol: '%', 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 { GlSkeletonLoader, GlCard } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import ReleaseStatsCard from 'ee/analytics/group_ci_cd_analytics/components/release_stats_card.vue'; import ReleaseStatsCard from 'ee/analytics/group_ci_cd_analytics/components/release_stats_card.vue';
...@@ -77,6 +78,33 @@ describe('Release stats card', () => { ...@@ -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', () => { describe('when an error occurs while loading data', () => {
beforeEach(() => { beforeEach(() => {
const apolloProvider = createMockApollo([ 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