Commit 0711747a authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '336844-start-and-due-dates-are-incorrectly-set-on-epic-creation' into 'master'

Resolve "Start and due dates are incorrectly set on epic creation"

See merge request gitlab-org/gitlab!66809
parents 81144ba6 722e9a53
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
GlFormInput, GlFormInput,
} from '@gitlab/ui'; } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { formatDate } from '~/lib/utils/datetime_utility';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import MarkdownField from '~/vue_shared/components/markdown/field.vue'; import MarkdownField from '~/vue_shared/components/markdown/field.vue';
...@@ -70,9 +71,11 @@ export default { ...@@ -70,9 +71,11 @@ export default {
title: this.title, title: this.title,
description: this.description, description: this.description,
confidential: this.confidential, confidential: this.confidential,
startDateFixed: this.startDateFixed, startDateFixed: this.startDateFixed
? formatDate(this.startDateFixed, 'yyyy-mm-dd')
: null,
startDateIsFixed: Boolean(this.startDateFixed), startDateIsFixed: Boolean(this.startDateFixed),
dueDateFixed: this.dueDateFixed, dueDateFixed: this.dueDateFixed ? formatDate(this.dueDateFixed, 'yyyy-mm-dd') : null,
dueDateIsFixed: Boolean(this.dueDateFixed), dueDateIsFixed: Boolean(this.dueDateFixed),
}, },
}, },
......
import { GlForm } from '@gitlab/ui'; import { GlForm } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import EpicForm from 'ee/epic/components/epic_form.vue'; import EpicForm from 'ee/epic/components/epic_form.vue';
import createEpic from 'ee/epic/queries/createEpic.mutation.graphql'; import createEpic from 'ee/epic/queries/createEpic.mutation.graphql';
...@@ -85,31 +86,38 @@ describe('ee/epic/components/epic_form.vue', () => { ...@@ -85,31 +86,38 @@ describe('ee/epic/components/epic_form.vue', () => {
findResetter().vm.$emit('click'); findResetter().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return nextTick().then(() => {
expect(wrapper.vm[field]).toBe(null); expect(wrapper.vm[field]).toBe(null);
}); });
}); });
}); });
describe('save', () => { describe('save', () => {
it('submits successfully if form data is provided', async () => {
createWrapper();
const addLabelIds = [1]; const addLabelIds = [1];
const title = 'Status page MVP'; const title = 'Status page MVP';
const description = '### Goal\n\n- [ ] Item'; const description = '### Goal\n\n- [ ] Item';
const confidential = true; const confidential = true;
const startDateFixed = new Date();
const startDateIsFixed = true; it.each`
const dueDateFixed = null; startDateFixed | dueDateFixed | startDateIsFixed | dueDateIsFixed
const dueDateIsFixed = false; ${null} | ${null} | ${false} | ${false}
${'2021-07-01'} | ${null} | ${true} | ${false}
${null} | ${'2021-07-02'} | ${false} | ${true}
${'2021-07-01'} | ${'2021-07-02'} | ${true} | ${true}
`(
'requests mutation with correct data with all start and due date configurations',
async ({ startDateFixed, dueDateFixed, startDateIsFixed, dueDateIsFixed }) => {
createWrapper();
findTitle().vm.$emit('input', title); findTitle().vm.$emit('input', title);
findDescription().setValue(description); findDescription().setValue(description);
findConfidentialityCheck().vm.$emit('input', confidential); findConfidentialityCheck().vm.$emit('input', confidential);
findLabels().vm.$emit('updateSelectedLabels', [{ id: 1, set: 1 }]); findLabels().vm.$emit('updateSelectedLabels', [{ id: 1, set: 1 }]);
findStartDate().vm.$emit('input', startDateFixed);
findDueDate().vm.$emit('input', dueDateFixed); // Make sure the submitted values for start and due dates are date strings without timezone info.
// (Datepicker emits a Date object but the submitted value must be a date string).
findStartDate().vm.$emit('input', startDateFixed ? new Date(startDateFixed) : null);
findDueDate().vm.$emit('input', dueDateFixed ? new Date(dueDateFixed) : null);
findForm().vm.$emit('submit', { preventDefault: () => {} }); findForm().vm.$emit('submit', { preventDefault: () => {} });
...@@ -130,10 +138,11 @@ describe('ee/epic/components/epic_form.vue', () => { ...@@ -130,10 +138,11 @@ describe('ee/epic/components/epic_form.vue', () => {
}, },
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(visitUrl).toHaveBeenCalled(); expect(visitUrl).toHaveBeenCalled();
}); },
);
it.each` it.each`
status | result | loading status | result | loading
......
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