Commit c91fbebf authored by Simon Knox's avatar Simon Knox

Merge branch '12100-guideline-edge-cases' into 'master'

Fix burnup guideline

See merge request gitlab-org/gitlab!65958
parents 856a51d3 1631fca2
...@@ -76,8 +76,10 @@ export default { ...@@ -76,8 +76,10 @@ export default {
}, },
]; ];
if (series[0] && series[0].data.length >= 2) { if (data.length > 0) {
const idealStart = [this.startDate, data[0][1]]; const zeroStart = [this.startDate, 0];
const firstNonZero = data.find((dataObj) => dataObj[1] !== 0) || zeroStart;
const idealStart = [this.startDate, firstNonZero[1]];
const idealEnd = [this.dueDate, 0]; const idealEnd = [this.dueDate, 0];
const idealData = [idealStart, idealEnd]; const idealData = [idealStart, idealEnd];
......
...@@ -35,10 +35,10 @@ describe('burndown_chart', () => { ...@@ -35,10 +35,10 @@ describe('burndown_chart', () => {
expect(findChart().exists()).toBe(true); expect(findChart().exists()).toBe(true);
}); });
describe('with single point', () => { describe('with no points', () => {
it('does not show guideline', () => { it('does not show guideline', () => {
createComponent({ createComponent({
openIssuesCount: [{ '2019-08-07T00:00:00.000Z': 100 }], openIssuesCount: [],
}); });
const data = wrapper.vm.dataSeries; const data = wrapper.vm.dataSeries;
...@@ -47,6 +47,30 @@ describe('burndown_chart', () => { ...@@ -47,6 +47,30 @@ describe('burndown_chart', () => {
}); });
}); });
describe('with single point and zero issues', () => {
it('shows guideline', () => {
createComponent({
openIssuesCount: [{ '2019-08-07T00:00:00.000Z': 0 }],
});
const data = wrapper.vm.dataSeries;
expect(data).toHaveLength(2);
expect(data[1].name).toBe('Guideline');
});
});
describe('with single point', () => {
it('shows guideline', () => {
createComponent({
openIssuesCount: [{ '2019-08-07T00:00:00.000Z': 100 }],
});
const data = wrapper.vm.dataSeries;
expect(data).toHaveLength(2);
expect(data[1].name).toBe('Guideline');
});
});
describe('with multiple points', () => { describe('with multiple points', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
......
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