Commit d11585f9 authored by Illya Klymov's avatar Illya Klymov

Fix props mutation in anomaly.vue

Upgrade to @vue/test-utils 1.x revealed props mutation in anomaly.vue
resulting in infinite render loop in tests.

Fix this behavior by using immer to generate derived value
parent 0e1bd185
<script> <script>
import produce from 'immer';
import { flattenDeep, isNumber } from 'lodash'; import { flattenDeep, isNumber } from 'lodash';
import { GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import { roundOffFloat } from '~/lib/utils/common_utils'; import { roundOffFloat } from '~/lib/utils/common_utils';
...@@ -84,11 +85,13 @@ export default { ...@@ -84,11 +85,13 @@ export default {
metricData() { metricData() {
const originalMetricQuery = this.graphData.metrics[0]; const originalMetricQuery = this.graphData.metrics[0];
const metricQuery = { ...originalMetricQuery }; const metricQuery = produce(originalMetricQuery, draftQuery => {
metricQuery.result[0].values = metricQuery.result[0].values.map(([x, y]) => [ // eslint-disable-next-line no-param-reassign
draftQuery.result[0].values = draftQuery.result[0].values.map(([x, y]) => [
x, x,
y + this.yOffset, y + this.yOffset,
]); ]);
});
return { return {
...this.graphData, ...this.graphData,
type: panelTypes.LINE_CHART, type: panelTypes.LINE_CHART,
......
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