Commit 0883e2ac authored by Fatih Acet's avatar Fatih Acet

Merge branch...

Merge branch '6766-performance-mr-widget-is-expandable-even-when-there-are-no-changes' into 'master'

Resolve "Performance MR widget is expandable even when there are no changes"

Closes #6766

See merge request gitlab-org/gitlab-ee!6685
parents 9d8235ed 8df13b48
...@@ -55,8 +55,7 @@ export default { ...@@ -55,8 +55,7 @@ export default {
return ( return (
this.mr.performanceMetrics && this.mr.performanceMetrics &&
((this.mr.performanceMetrics.degraded && this.mr.performanceMetrics.degraded.length > 0) || ((this.mr.performanceMetrics.degraded && this.mr.performanceMetrics.degraded.length > 0) ||
(this.mr.performanceMetrics.improved && this.mr.performanceMetrics.improved.length > 0) || (this.mr.performanceMetrics.improved && this.mr.performanceMetrics.improved.length > 0))
(this.mr.performanceMetrics.neutral && this.mr.performanceMetrics.neutral.length > 0))
); );
}, },
shouldRenderPerformance() { shouldRenderPerformance() {
...@@ -229,7 +228,6 @@ export default { ...@@ -229,7 +228,6 @@ export default {
:success-text="performanceText" :success-text="performanceText"
:unresolved-issues="mr.performanceMetrics.degraded" :unresolved-issues="mr.performanceMetrics.degraded"
:resolved-issues="mr.performanceMetrics.improved" :resolved-issues="mr.performanceMetrics.improved"
:neutral-issues="mr.performanceMetrics.neutral"
:has-issues="hasPerformanceMetrics" :has-issues="hasPerformanceMetrics"
:component="$options.componentNames.PerformanceIssueBody" :component="$options.componentNames.PerformanceIssueBody"
class="js-performance-widget mr-widget-border-top mr-report" class="js-performance-widget mr-widget-border-top mr-report"
......
...@@ -66,7 +66,6 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -66,7 +66,6 @@ export default class MergeRequestStore extends CEMergeRequestStore {
this.performanceMetrics = { this.performanceMetrics = {
improved: [], improved: [],
degraded: [], degraded: [],
neutral: [],
}; };
} }
...@@ -92,7 +91,6 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -92,7 +91,6 @@ export default class MergeRequestStore extends CEMergeRequestStore {
const improved = []; const improved = [];
const degraded = []; const degraded = [];
const neutral = [];
Object.keys(headMetricsIndexed).forEach(subject => { Object.keys(headMetricsIndexed).forEach(subject => {
const subjectMetrics = headMetricsIndexed[subject]; const subjectMetrics = headMetricsIndexed[subject];
...@@ -110,24 +108,18 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -110,24 +108,18 @@ export default class MergeRequestStore extends CEMergeRequestStore {
delta: headMetricData.value - baseMetricData.value, delta: headMetricData.value - baseMetricData.value,
}; };
if (metricData.delta === 0) { if (metricData.delta !== 0) {
neutral.push(metricData); if (metricDirection > 0) {
} else if (metricData.delta * metricDirection > 0) { improved.push(metricData);
improved.push(metricData); } else {
} else { degraded.push(metricData);
degraded.push(metricData); }
} }
} else {
neutral.push({
name: metric,
path: subject,
score: headMetricData.value,
});
} }
}); });
}); });
this.performanceMetrics = { improved, degraded, neutral }; this.performanceMetrics = { improved, degraded };
} }
// normalize performance metrics by indexing on performance subject and metric name // normalize performance metrics by indexing on performance subject and metric name
......
---
title: Hide Expand button on empty MR widget Performance section
merge_request: 6685
author:
type: fixed
...@@ -479,21 +479,29 @@ describe('ee merge request widget options', () => { ...@@ -479,21 +479,29 @@ describe('ee merge request widget options', () => {
}); });
describe('with empty successful request', () => { describe('with empty successful request', () => {
beforeEach(() => { beforeEach(done => {
mock.onGet('head.json').reply(200, []); mock.onGet('head.json').reply(200, []);
mock.onGet('base.json').reply(200, []); mock.onGet('base.json').reply(200, []);
vm = mountComponent(Component); vm = mountComponent(Component);
// wait for network request from component created() method
setTimeout(done, 0);
}); });
it('should render provided data', done => { it('should render provided data', () => {
setTimeout(() => { expect(
expect( removeBreakLine(
removeBreakLine( vm.$el.querySelector('.js-performance-widget .js-code-text').textContent,
vm.$el.querySelector('.js-performance-widget .js-code-text').textContent, ),
), ).toEqual('No changes to performance metrics');
).toEqual('No changes to performance metrics'); });
done();
}, 0); it('does not show Expand button', () => {
const expandButton = vm.$el.querySelector('.js-performance-widget .js-collapse-btn');
expect(expandButton).toBeNull();
});
it('shows success icon', () => {
expect(vm.$el.querySelector('.js-performance-widget .js-ci-status-icon-success')).not.toBeNull();
}); });
}); });
......
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