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,6 +274,15 @@ describe('ProductivityApp component', () => { ...@@ -274,6 +274,15 @@ 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 column chart', () => {
expect(
findCommitBasedSection()
.find(GlColumnChart)
.exists(),
).toBe(true);
});
describe('metric dropdown', () => {
it('renders a metric type dropdown', () => { it('renders a metric type dropdown', () => {
expect( expect(
findCommitBasedSection() findCommitBasedSection()
...@@ -282,24 +291,26 @@ describe('ProductivityApp component', () => { ...@@ -282,24 +291,26 @@ describe('ProductivityApp component', () => {
).toBe(true); ).toBe(true);
}); });
it('should change the metric type', () => { describe('when the user changes the metric', () => {
beforeEach(() => {
findCommitBasedSection() findCommitBasedSection()
.findAll(GlDropdownItem) .findAll(GlDropdownItem)
.at(0) .at(0)
.vm.$emit('click'); .vm.$emit('click');
});
it('should dispatch setMetricType action', () => {
expect(actionSpies.setMetricType).toHaveBeenCalledWith({ expect(actionSpies.setMetricType).toHaveBeenCalledWith({
metricType: 'commits_count', metricType: 'commits_count',
chartKey: chartKeys.commitBasedHistogram, chartKey: chartKeys.commitBasedHistogram,
}); });
}); });
it('renders a column chart', () => { it("should update the chart's x axis label", () => {
expect( const columnChart = findCommitBasedSection().find(GlColumnChart);
findCommitBasedSection() expect(columnChart.props('xAxisTitle')).toBe('Number of commits per MR');
.find(GlColumnChart) });
.exists(), });
).toBe(true);
}); });
}); });
......
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