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
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 do
push_frontend_feature_flag(:burnup_charts, group)
push_frontend_feature_flag(:burnup_charts)
end
def index
......
......@@ -7,7 +7,7 @@ class Projects::MilestonesController < Projects::ApplicationController
before_action :check_issuables_available!
before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels, :promote]
before_action do
push_frontend_feature_flag(:burnup_charts, project)
push_frontend_feature_flag(:burnup_charts)
end
# Allow read any milestone
......
......@@ -4,7 +4,6 @@ import { __ } from '~/locale';
import BurndownChart from './burndown_chart.vue';
export default {
burnupChartsEnabled: gon.features.burnupCharts,
components: {
GlDeprecatedButton,
GlButtonGroup,
......@@ -33,11 +32,12 @@ export default {
data() {
return {
issuesSelected: true,
burnupChartsEnabled: gon.features.burnupCharts,
};
},
computed: {
title() {
return this.$options.burnupChartsEnabled ? __('Charts') : __('Burndown chart');
return this.burnupChartsEnabled ? __('Charts') : __('Burndown chart');
},
},
methods: {
......@@ -75,7 +75,7 @@ export default {
</gl-deprecated-button>
</gl-button-group>
</div>
<div v-if="$options.burnupChartsEnabled" class="row">
<div v-if="burnupChartsEnabled" class="row">
<burndown-chart
:start-date="startDate"
:due-date="dueDate"
......
......@@ -2,7 +2,7 @@
import { GlLineChart } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat';
import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue';
import { __, sprintf } from '~/locale';
import { s__, __, sprintf } from '~/locale';
export default {
components: {
......@@ -50,7 +50,15 @@ export default {
computed: {
dataSeries() {
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 = [
{
......
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';
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',
......@@ -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', () => {
it('does not show guideline', () => {
createComponent({
......
......@@ -3533,6 +3533,9 @@ msgstr ""
msgid "Changing group path can have unintended side effects."
msgstr ""
msgid "Charts"
msgstr ""
msgid "Charts can't be displayed as the request for data has timed out. %{documentationLink}"
msgstr ""
......
......@@ -14,9 +14,12 @@ module QA
element :total_issue_weight_value
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
element :burndown_chart
element :weight_button
end
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