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