Commit 3a3b0c7b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'psi-create-iteration' into 'master'

Fix query to create iteration in cadence

See merge request gitlab-org/gitlab!65627
parents 301666c5 43893175
......@@ -200,7 +200,7 @@ export default {
if (this.automatic) {
return true;
}
const requiredFieldsForAutomatedScheduling = ['iterationsInAdvance'];
const requiredFieldsForAutomatedScheduling = ['iterationsInAdvance', 'durationInWeeks'];
return !requiredFieldsForAutomatedScheduling.includes(field);
})
.forEach((field) => {
......@@ -216,6 +216,7 @@ export default {
this.clearValidation();
if (!value) {
this.iterationsInAdvance = 0;
this.durationInWeeks = 0;
}
},
save() {
......@@ -353,9 +354,9 @@ export default {
v-model.number="durationInWeeks"
:options="$options.availableDurations"
class="gl-form-input-md"
required
:required="automatic"
data-qa-selector="iteration_cadence_name_field"
:disabled="loadingCadence"
:disabled="loadingCadence || !automatic"
@change="validate('durationInWeeks')"
/>
</gl-form-group>
......
......@@ -62,6 +62,11 @@ export default {
type: String,
required: true,
},
automatic: {
type: Boolean,
required: false,
default: false,
},
durationInWeeks: {
type: Number,
required: false,
......@@ -212,7 +217,7 @@ export default {
text-sr-only
no-caret
>
<gl-dropdown-item v-if="!durationInWeeks" :to="newIteration">
<gl-dropdown-item v-if="!automatic" :to="newIteration">
{{ s__('Iterations|Add iteration') }}
</gl-dropdown-item>
......
......@@ -156,6 +156,7 @@ export default {
:key="cadence.id"
:cadence-id="cadence.id"
:duration-in-weeks="cadence.durationInWeeks"
:automatic="cadence.automatic"
:title="cadence.title"
:iteration-state="state"
@delete-cadence="deleteCadence"
......
......@@ -99,8 +99,10 @@ export default {
.mutate({
mutation: createIteration,
variables: {
...this.variables,
iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', this.cadenceId),
input: {
...this.variables,
iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', this.cadenceId),
},
},
})
.then(({ data }) => {
......
......@@ -19,6 +19,7 @@ query IterationCadences(
id
title
durationInWeeks
automatic
}
pageInfo {
...PageInfo
......
mutation createIteration($input: iterationCreateInput!) {
iterationCreate(input: $input) {
iteration {
id
title
description
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', () => {
});
describe('automated scheduling disabled', () => {
it('disables future iterations', async () => {
it('disables future iterations and duration in weeks', async () => {
setAutomaticValue(false);
await nextTick();
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 startDate = '2020-05-05';
const durationInWeeks = 2;
setFutureIterations(10);
setDuration(2);
setAutomaticValue(false);
......@@ -214,7 +217,6 @@ describe('Iteration cadence form', () => {
setTitle(title);
setStartDate(startDate);
setDuration(durationInWeeks);
clickSave();
......@@ -224,7 +226,7 @@ describe('Iteration cadence form', () => {
title,
automatic: false,
startDate,
durationInWeeks,
durationInWeeks: 0,
iterationsInAdvance: 0,
description: '',
active: true,
......
......@@ -34,16 +34,19 @@ describe('Iteration cadences list', () => {
id: 'gid://gitlab/Iterations::Cadence/561',
title: 'A eligendi molestias temporibus maiores architecto ut facilis autem.',
durationInWeeks: 3,
automatic: true,
},
{
id: 'gid://gitlab/Iterations::Cadence/392',
title: 'A quam repellat omnis eum veritatis voluptas voluptatem consequuntur est.',
durationInWeeks: 4,
automatic: true,
},
{
id: 'gid://gitlab/Iterations::Cadence/152',
title: 'A repudiandae ut eligendi quae et ducimus porro nam sint perferendis.',
durationInWeeks: 1,
automatic: true,
},
];
......
......@@ -120,12 +120,14 @@ describe('Iteration Form', () => {
await clickSave();
expect(resolverMock).toHaveBeenCalledWith({
groupPath,
title,
description,
iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', cadenceId),
startDate,
dueDate,
input: {
groupPath,
title,
description,
iterationsCadenceId: convertToGraphQLId('Iterations::Cadence', cadenceId),
startDate,
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