Commit 14e52653 authored by Phil Hughes's avatar Phil Hughes

Merge branch '4582-fix-incorrect-neutral-count' into 'master'

Fix neutralCount computation to prevent negative values

Closes #4582

See merge request gitlab-org/gitlab-ee!4044
parents bbf9174e 4c1652cf
...@@ -37,6 +37,9 @@ export default { ...@@ -37,6 +37,9 @@ export default {
}, },
}, },
computed: { computed: {
neutralCount() {
return this.totalCount - this.successCount - this.failureCount;
},
successPercent() { successPercent() {
return this.getPercent(this.successCount); return this.getPercent(this.successCount);
}, },
...@@ -56,14 +59,13 @@ export default { ...@@ -56,14 +59,13 @@ export default {
return this.getTooltip(this.failureLabel, this.failureCount); return this.getTooltip(this.failureLabel, this.failureCount);
}, },
neutralPercent() { neutralPercent() {
return 100 - this.successPercent - this.failurePercent; return this.getPercent(this.neutralCount);
}, },
neutralBarStyle() { neutralBarStyle() {
return this.barStyle(this.neutralPercent); return this.barStyle(this.neutralPercent);
}, },
neutralTooltip() { neutralTooltip() {
const neutralCount = this.totalCount - this.successCount - this.failureCount; return this.getTooltip(this.neutralLabel, this.neutralCount);
return this.getTooltip(this.neutralLabel, neutralCount);
}, },
}, },
methods: { methods: {
......
---
title: Fix neutralCount computation to prevent negative values
merge_request: 4044
author:
type: fixed
...@@ -29,6 +29,14 @@ describe('StackedProgressBarComponent', () => { ...@@ -29,6 +29,14 @@ describe('StackedProgressBarComponent', () => {
vm.$destroy(); vm.$destroy();
}); });
describe('computed', () => {
describe('neutralCount', () => {
it('returns neutralCount based on totalCount, successCount and failureCount', () => {
expect(vm.neutralCount).toBe(5); // 20 - 10 - 5
});
});
});
describe('methods', () => { describe('methods', () => {
describe('getPercent', () => { describe('getPercent', () => {
it('returns percentage from provided count based on `totalCount`', () => { it('returns percentage from provided count based on `totalCount`', () => {
......
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