Commit e6d77876 authored by Simon Knox's avatar Simon Knox

Fix and update specs

Add burn_charts spec, move relevent tests there
parent 0d3ad66b
...@@ -6,7 +6,7 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -6,7 +6,7 @@ class Groups::MilestonesController < Groups::ApplicationController
before_action :milestone, only: [:edit, :show, :update, :merge_requests, :participants, :labels, :destroy] before_action :milestone, only: [:edit, :show, :update, :merge_requests, :participants, :labels, :destroy]
before_action :authorize_admin_milestones!, only: [:edit, :new, :create, :update, :destroy] before_action :authorize_admin_milestones!, only: [:edit, :new, :create, :update, :destroy]
before_action do before_action do
push_frontend_feature_flag(:burnup_charts, group) push_frontend_feature_flag(:burnup_charts)
end end
def index def index
......
...@@ -7,7 +7,7 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -7,7 +7,7 @@ class Projects::MilestonesController < Projects::ApplicationController
before_action :check_issuables_available! before_action :check_issuables_available!
before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels, :promote] before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels, :promote]
before_action do before_action do
push_frontend_feature_flag(:burnup_charts, project) push_frontend_feature_flag(:burnup_charts)
end end
# Allow read any milestone # Allow read any milestone
......
...@@ -4,7 +4,6 @@ import { __ } from '~/locale'; ...@@ -4,7 +4,6 @@ import { __ } from '~/locale';
import BurndownChart from './burndown_chart.vue'; import BurndownChart from './burndown_chart.vue';
export default { export default {
burnupChartsEnabled: gon.features.burnupCharts,
components: { components: {
GlDeprecatedButton, GlDeprecatedButton,
GlButtonGroup, GlButtonGroup,
...@@ -33,11 +32,12 @@ export default { ...@@ -33,11 +32,12 @@ export default {
data() { data() {
return { return {
issuesSelected: true, issuesSelected: true,
burnupChartsEnabled: gon.features.burnupCharts,
}; };
}, },
computed: { computed: {
title() { title() {
return this.$options.burnupChartsEnabled ? __('Charts') : __('Burndown chart'); return this.burnupChartsEnabled ? __('Charts') : __('Burndown chart');
}, },
}, },
methods: { methods: {
...@@ -75,7 +75,7 @@ export default { ...@@ -75,7 +75,7 @@ export default {
</gl-deprecated-button> </gl-deprecated-button>
</gl-button-group> </gl-button-group>
</div> </div>
<div v-if="$options.burnupChartsEnabled" class="row"> <div v-if="burnupChartsEnabled" class="row">
<burndown-chart <burndown-chart
:start-date="startDate" :start-date="startDate"
:due-date="dueDate" :due-date="dueDate"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlLineChart } from '@gitlab/ui/dist/charts'; import { GlLineChart } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue'; import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue';
import { __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
export default { export default {
components: { components: {
...@@ -50,7 +50,15 @@ export default { ...@@ -50,7 +50,15 @@ export default {
computed: { computed: {
dataSeries() { dataSeries() {
let name; let name;
const data = this.issuesSelected ? this.openIssuesCount : this.openIssuesWeight; let data;
if (this.issuesSelected) {
name = s__('BurndownChartLabel|Open issues');
data = this.openIssuesCount;
} else {
name = s__('BurndownChartLabel|Open issue weight');
data = this.openIssuesWeight;
}
const series = [ const series = [
{ {
......
import { shallowMount } from '@vue/test-utils';
import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue';
describe('burndown_chart', () => {
let wrapper;
const issuesButton = () => wrapper.find({ ref: 'totalIssuesButton' });
const weightButton = () => wrapper.find({ ref: 'totalWeightButton' });
const defaultProps = {
startDate: '2019-08-07T00:00:00.000Z',
dueDate: '2019-09-09T00:00:00.000Z',
openIssuesCount: [],
openIssuesWeight: [],
};
const createComponent = (props = {}) => {
wrapper = shallowMount(BurnCharts, {
propsData: {
...defaultProps,
...props,
},
});
};
let origProp;
beforeEach(() => {
origProp = window.gon;
window.gon = {
features: {
monacoSnippets: false,
},
};
});
afterEach(() => {
window.gon = origProp;
});
it('inclues Issues and Issue weight buttons', () => {
createComponent();
expect(issuesButton().text()).toBe('Issues');
expect(weightButton().text()).toBe('Issue weight');
});
it('defaults to total issues', () => {
createComponent();
expect(issuesButton().attributes('variant')).toBe('primary');
expect(weightButton().attributes('variant')).toBe('inverted-primary');
});
it('toggles Issue weight', () => {
createComponent();
weightButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => {
expect(issuesButton().attributes('variant')).toBe('inverted-primary');
expect(weightButton().attributes('variant')).toBe('primary');
});
});
});
...@@ -4,9 +4,6 @@ import BurndownChart from 'ee/burndown_chart/components/burndown_chart.vue'; ...@@ -4,9 +4,6 @@ import BurndownChart from 'ee/burndown_chart/components/burndown_chart.vue';
describe('burndown_chart', () => { describe('burndown_chart', () => {
let wrapper; let wrapper;
const issuesButton = () => wrapper.find({ ref: 'totalIssuesButton' });
const weightButton = () => wrapper.find({ ref: 'totalWeightButton' });
const defaultProps = { const defaultProps = {
startDate: '2019-08-07T00:00:00.000Z', startDate: '2019-08-07T00:00:00.000Z',
dueDate: '2019-09-09T00:00:00.000Z', dueDate: '2019-09-09T00:00:00.000Z',
...@@ -23,31 +20,6 @@ describe('burndown_chart', () => { ...@@ -23,31 +20,6 @@ describe('burndown_chart', () => {
}); });
}; };
it('inclues Issues and Issue weight buttons', () => {
createComponent();
expect(issuesButton().text()).toBe('Issues');
expect(weightButton().text()).toBe('Issue weight');
});
it('defaults to total issues', () => {
createComponent();
expect(issuesButton().attributes('variant')).toBe('primary');
expect(weightButton().attributes('variant')).toBe('inverted-primary');
});
it('toggles Issue weight', () => {
createComponent();
weightButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => {
expect(issuesButton().attributes('variant')).toBe('inverted-primary');
expect(weightButton().attributes('variant')).toBe('primary');
});
});
describe('with single point', () => { describe('with single point', () => {
it('does not show guideline', () => { it('does not show guideline', () => {
createComponent({ createComponent({
......
...@@ -3533,6 +3533,9 @@ msgstr "" ...@@ -3533,6 +3533,9 @@ msgstr ""
msgid "Changing group path can have unintended side effects." msgid "Changing group path can have unintended side effects."
msgstr "" msgstr ""
msgid "Charts"
msgstr ""
msgid "Charts can't be displayed as the request for data has timed out. %{documentationLink}" msgid "Charts can't be displayed as the request for data has timed out. %{documentationLink}"
msgstr "" msgstr ""
......
...@@ -14,9 +14,12 @@ module QA ...@@ -14,9 +14,12 @@ module QA
element :total_issue_weight_value element :total_issue_weight_value
end end
view 'ee/app/assets/javascripts/burndown_chart/components/burn_charts.vue' do
element :weight_button
end
view 'ee/app/assets/javascripts/burndown_chart/components/burndown_chart.vue' do view 'ee/app/assets/javascripts/burndown_chart/components/burndown_chart.vue' do
element :burndown_chart element :burndown_chart
element :weight_button
end end
def click_weight_button def click_weight_button
......
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