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 {
return (
this.mr.performanceMetrics &&
((this.mr.performanceMetrics.degraded && this.mr.performanceMetrics.degraded.length > 0) ||
(this.mr.performanceMetrics.improved && this.mr.performanceMetrics.improved.length > 0) ||
(this.mr.performanceMetrics.neutral && this.mr.performanceMetrics.neutral.length > 0))
(this.mr.performanceMetrics.improved && this.mr.performanceMetrics.improved.length > 0))
);
},
shouldRenderPerformance() {
......@@ -229,7 +228,6 @@ export default {
:success-text="performanceText"
:unresolved-issues="mr.performanceMetrics.degraded"
:resolved-issues="mr.performanceMetrics.improved"
:neutral-issues="mr.performanceMetrics.neutral"
:has-issues="hasPerformanceMetrics"
:component="$options.componentNames.PerformanceIssueBody"
class="js-performance-widget mr-widget-border-top mr-report"
......
......@@ -66,7 +66,6 @@ export default class MergeRequestStore extends CEMergeRequestStore {
this.performanceMetrics = {
improved: [],
degraded: [],
neutral: [],
};
}
......@@ -92,7 +91,6 @@ export default class MergeRequestStore extends CEMergeRequestStore {
const improved = [];
const degraded = [];
const neutral = [];
Object.keys(headMetricsIndexed).forEach(subject => {
const subjectMetrics = headMetricsIndexed[subject];
......@@ -110,24 +108,18 @@ export default class MergeRequestStore extends CEMergeRequestStore {
delta: headMetricData.value - baseMetricData.value,
};
if (metricData.delta === 0) {
neutral.push(metricData);
} else if (metricData.delta * metricDirection > 0) {
if (metricData.delta !== 0) {
if (metricDirection > 0) {
improved.push(metricData);
} else {
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
......
---
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', () => {
});
describe('with empty successful request', () => {
beforeEach(() => {
beforeEach(done => {
mock.onGet('head.json').reply(200, []);
mock.onGet('base.json').reply(200, []);
vm = mountComponent(Component);
// wait for network request from component created() method
setTimeout(done, 0);
});
it('should render provided data', done => {
setTimeout(() => {
it('should render provided data', () => {
expect(
removeBreakLine(
vm.$el.querySelector('.js-performance-widget .js-code-text').textContent,
),
).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