Commit c9f10589 authored by Martin Wortschack's avatar Martin Wortschack Committed by Filipa Lacerda

Update axis label when metric changes

- Ensures that we update the x axis label
on the commit based histogram when
the user changes the metric
parent d7b32ec1
...@@ -289,7 +289,7 @@ export default { ...@@ -289,7 +289,7 @@ export default {
:data="{ full: getChartData(chartKeys.commitBasedHistogram) }" :data="{ full: getChartData(chartKeys.commitBasedHistogram) }"
:option="getColumnChartOption(chartKeys.commitBasedHistogram)" :option="getColumnChartOption(chartKeys.commitBasedHistogram)"
:y-axis-title="__('Merge requests')" :y-axis-title="__('Merge requests')"
:x-axis-title="__('Commits')" :x-axis-title="getMetricDropdownLabel(chartKeys.commitBasedHistogram)"
x-axis-type="category" x-axis-type="category"
/> />
</template> </template>
......
...@@ -274,32 +274,43 @@ describe('ProductivityApp component', () => { ...@@ -274,32 +274,43 @@ describe('ProductivityApp component', () => {
store.state.charts.charts[chartKeys.commitBasedHistogram].data = { 1: 2, 2: 3 }; store.state.charts.charts[chartKeys.commitBasedHistogram].data = { 1: 2, 2: 3 };
}); });
it('renders a metric type dropdown', () => { it('renders a column chart', () => {
expect( expect(
findCommitBasedSection() findCommitBasedSection()
.find(GlDropdown) .find(GlColumnChart)
.exists(), .exists(),
).toBe(true); ).toBe(true);
}); });
it('should change the metric type', () => { describe('metric dropdown', () => {
findCommitBasedSection() it('renders a metric type dropdown', () => {
.findAll(GlDropdownItem) expect(
.at(0) findCommitBasedSection()
.vm.$emit('click'); .find(GlDropdown)
.exists(),
expect(actionSpies.setMetricType).toHaveBeenCalledWith({ ).toBe(true);
metricType: 'commits_count',
chartKey: chartKeys.commitBasedHistogram,
}); });
});
it('renders a column chart', () => { describe('when the user changes the metric', () => {
expect( beforeEach(() => {
findCommitBasedSection() findCommitBasedSection()
.find(GlColumnChart) .findAll(GlDropdownItem)
.exists(), .at(0)
).toBe(true); .vm.$emit('click');
});
it('should dispatch setMetricType action', () => {
expect(actionSpies.setMetricType).toHaveBeenCalledWith({
metricType: 'commits_count',
chartKey: chartKeys.commitBasedHistogram,
});
});
it("should update the chart's x axis label", () => {
const columnChart = findCommitBasedSection().find(GlColumnChart);
expect(columnChart.props('xAxisTitle')).toBe('Number of commits per MR');
});
});
}); });
}); });
......
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