Commit 43893175 authored by Simon Knox's avatar Simon Knox Committed by Kushal Pandya

Fix query to create iteration in cadence

parent 5226c013
...@@ -200,7 +200,7 @@ export default { ...@@ -200,7 +200,7 @@ export default {
if (this.automatic) { if (this.automatic) {
return true; return true;
} }
const requiredFieldsForAutomatedScheduling = ['iterationsInAdvance']; const requiredFieldsForAutomatedScheduling = ['iterationsInAdvance', 'durationInWeeks'];
return !requiredFieldsForAutomatedScheduling.includes(field); return !requiredFieldsForAutomatedScheduling.includes(field);
}) })
.forEach((field) => { .forEach((field) => {
...@@ -216,6 +216,7 @@ export default { ...@@ -216,6 +216,7 @@ export default {
this.clearValidation(); this.clearValidation();
if (!value) { if (!value) {
this.iterationsInAdvance = 0; this.iterationsInAdvance = 0;
this.durationInWeeks = 0;
} }
}, },
save() { save() {
...@@ -353,9 +354,9 @@ export default { ...@@ -353,9 +354,9 @@ export default {
v-model.number="durationInWeeks" v-model.number="durationInWeeks"
:options="$options.availableDurations" :options="$options.availableDurations"
class="gl-form-input-md" class="gl-form-input-md"
required :required="automatic"
data-qa-selector="iteration_cadence_name_field" data-qa-selector="iteration_cadence_name_field"
:disabled="loadingCadence" :disabled="loadingCadence || !automatic"
@change="validate('durationInWeeks')" @change="validate('durationInWeeks')"
/> />
</gl-form-group> </gl-form-group>
......
...@@ -62,6 +62,11 @@ export default { ...@@ -62,6 +62,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
automatic: {
type: Boolean,
required: false,
default: false,
},
durationInWeeks: { durationInWeeks: {
type: Number, type: Number,
required: false, required: false,
...@@ -212,7 +217,7 @@ export default { ...@@ -212,7 +217,7 @@ export default {
text-sr-only text-sr-only
no-caret no-caret
> >
<gl-dropdown-item v-if="!durationInWeeks" :to="newIteration"> <gl-dropdown-item v-if="!automatic" :to="newIteration">
{{ s__('Iterations|Add iteration') }} {{ s__('Iterations|Add iteration') }}
</gl-dropdown-item> </gl-dropdown-item>
......
...@@ -156,6 +156,7 @@ export default { ...@@ -156,6 +156,7 @@ export default {
:key="cadence.id" :key="cadence.id"
:cadence-id="cadence.id" :cadence-id="cadence.id"
:duration-in-weeks="cadence.durationInWeeks" :duration-in-weeks="cadence.durationInWeeks"
:automatic="cadence.automatic"
:title="cadence.title" :title="cadence.title"
:iteration-state="state" :iteration-state="state"
@delete-cadence="deleteCadence" @delete-cadence="deleteCadence"
......
...@@ -99,9 +99,11 @@ export default { ...@@ -99,9 +99,11 @@ export default {
.mutate({ .mutate({
mutation: createIteration, mutation: createIteration,
variables: { variables: {
input: {
...this.variables, ...this.variables,
iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', this.cadenceId), iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', this.cadenceId),
}, },
},
}) })
.then(({ data }) => { .then(({ data }) => {
const { iteration, errors } = data.iterationCreate; const { iteration, errors } = data.iterationCreate;
......
...@@ -19,6 +19,7 @@ query IterationCadences( ...@@ -19,6 +19,7 @@ query IterationCadences(
id id
title title
durationInWeeks durationInWeeks
automatic
} }
pageInfo { pageInfo {
...PageInfo ...PageInfo
......
mutation createIteration($input: iterationCreateInput!) { mutation createIteration($input: iterationCreateInput!) {
iterationCreate(input: $input) { iterationCreate(input: $input) {
iteration { iteration {
id
title title
description description
descriptionHtml descriptionHtml
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User creates iteration in a cadence', :js do
let_it_be(:now) { Time.now }
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
let_it_be(:cadence) { create(:iterations_cadence, group: group, automatic: false, duration_in_weeks: 0) }
before do
stub_licensed_features(iterations: true)
sign_in(user)
visit new_group_iteration_cadence_iteration_path(group, iteration_cadence_id: cadence.id)
end
it 'prefills fields and allows updating all values' do
title = 'Iteration title'
desc = 'Iteration desc'
start_date = now + 4.days
due_date = now + 5.days
fill_in('Title', with: title)
fill_in('Description', with: desc)
fill_in('Start date', with: start_date.strftime('%Y-%m-%d'))
fill_in('Due date', with: due_date.strftime('%Y-%m-%d'))
click_button('Create iteration')
wait_for_requests
iteration = Iteration.last
aggregate_failures do
expect(page).to have_content(title)
expect(page).to have_content(desc)
expect(page).to have_content(start_date.strftime('%b %-d, %Y'))
expect(page).to have_content(due_date.strftime('%b %-d, %Y'))
expect(page).to have_current_path(group_iteration_cadence_iteration_path(group, iteration_cadence_id: cadence.id, id: iteration.id))
end
end
end
...@@ -193,20 +193,23 @@ describe('Iteration cadence form', () => { ...@@ -193,20 +193,23 @@ describe('Iteration cadence form', () => {
}); });
describe('automated scheduling disabled', () => { describe('automated scheduling disabled', () => {
it('disables future iterations', async () => { it('disables future iterations and duration in weeks', async () => {
setAutomaticValue(false); setAutomaticValue(false);
await nextTick(); await nextTick();
expect(findFutureIterations().attributes('disabled')).toBe('disabled'); expect(findFutureIterations().attributes('disabled')).toBe('disabled');
expect(findFutureIterations().attributes('required')).toBeUndefined();
expect(findDuration().attributes('disabled')).toBe('disabled');
expect(findDuration().attributes('required')).toBeUndefined();
}); });
it('sets future iterations to 0', async () => { it('sets future iterations and cadence duration to 0', async () => {
const title = 'Iteration 5'; const title = 'Iteration 5';
const startDate = '2020-05-05'; const startDate = '2020-05-05';
const durationInWeeks = 2;
setFutureIterations(10); setFutureIterations(10);
setDuration(2);
setAutomaticValue(false); setAutomaticValue(false);
...@@ -214,7 +217,6 @@ describe('Iteration cadence form', () => { ...@@ -214,7 +217,6 @@ describe('Iteration cadence form', () => {
setTitle(title); setTitle(title);
setStartDate(startDate); setStartDate(startDate);
setDuration(durationInWeeks);
clickSave(); clickSave();
...@@ -224,7 +226,7 @@ describe('Iteration cadence form', () => { ...@@ -224,7 +226,7 @@ describe('Iteration cadence form', () => {
title, title,
automatic: false, automatic: false,
startDate, startDate,
durationInWeeks, durationInWeeks: 0,
iterationsInAdvance: 0, iterationsInAdvance: 0,
description: '', description: '',
active: true, active: true,
......
...@@ -34,16 +34,19 @@ describe('Iteration cadences list', () => { ...@@ -34,16 +34,19 @@ describe('Iteration cadences list', () => {
id: 'gid://gitlab/Iterations::Cadence/561', id: 'gid://gitlab/Iterations::Cadence/561',
title: 'A eligendi molestias temporibus maiores architecto ut facilis autem.', title: 'A eligendi molestias temporibus maiores architecto ut facilis autem.',
durationInWeeks: 3, durationInWeeks: 3,
automatic: true,
}, },
{ {
id: 'gid://gitlab/Iterations::Cadence/392', id: 'gid://gitlab/Iterations::Cadence/392',
title: 'A quam repellat omnis eum veritatis voluptas voluptatem consequuntur est.', title: 'A quam repellat omnis eum veritatis voluptas voluptatem consequuntur est.',
durationInWeeks: 4, durationInWeeks: 4,
automatic: true,
}, },
{ {
id: 'gid://gitlab/Iterations::Cadence/152', id: 'gid://gitlab/Iterations::Cadence/152',
title: 'A repudiandae ut eligendi quae et ducimus porro nam sint perferendis.', title: 'A repudiandae ut eligendi quae et ducimus porro nam sint perferendis.',
durationInWeeks: 1, durationInWeeks: 1,
automatic: true,
}, },
]; ];
......
...@@ -120,12 +120,14 @@ describe('Iteration Form', () => { ...@@ -120,12 +120,14 @@ describe('Iteration Form', () => {
await clickSave(); await clickSave();
expect(resolverMock).toHaveBeenCalledWith({ expect(resolverMock).toHaveBeenCalledWith({
input: {
groupPath, groupPath,
title, title,
description, description,
iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', cadenceId), iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', cadenceId),
startDate, startDate,
dueDate, dueDate,
},
}); });
}); });
......
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