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,55 +86,63 @@ describe('ee/epic/components/epic_form.vue', () => { ...@@ -85,55 +86,63 @@ 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 () => { const addLabelIds = [1];
createWrapper(); const title = 'Status page MVP';
const description = '### Goal\n\n- [ ] Item';
const confidential = true;
const addLabelIds = [1]; it.each`
const title = 'Status page MVP'; startDateFixed | dueDateFixed | startDateIsFixed | dueDateIsFixed
const description = '### Goal\n\n- [ ] Item'; ${null} | ${null} | ${false} | ${false}
const confidential = true; ${'2021-07-01'} | ${null} | ${true} | ${false}
const startDateFixed = new Date(); ${null} | ${'2021-07-02'} | ${false} | ${true}
const startDateIsFixed = true; ${'2021-07-01'} | ${'2021-07-02'} | ${true} | ${true}
const dueDateFixed = null; `(
const dueDateIsFixed = false; 'requests mutation with correct data with all start and due date configurations',
async ({ startDateFixed, dueDateFixed, startDateIsFixed, dueDateIsFixed }) => {
findTitle().vm.$emit('input', title); createWrapper();
findDescription().setValue(description);
findConfidentialityCheck().vm.$emit('input', confidential); findTitle().vm.$emit('input', title);
findLabels().vm.$emit('updateSelectedLabels', [{ id: 1, set: 1 }]); findDescription().setValue(description);
findStartDate().vm.$emit('input', startDateFixed); findConfidentialityCheck().vm.$emit('input', confidential);
findDueDate().vm.$emit('input', dueDateFixed); findLabels().vm.$emit('updateSelectedLabels', [{ id: 1, set: 1 }]);
findForm().vm.$emit('submit', { preventDefault: () => {} }); // 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).
expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({ findStartDate().vm.$emit('input', startDateFixed ? new Date(startDateFixed) : null);
mutation: createEpic, findDueDate().vm.$emit('input', dueDateFixed ? new Date(dueDateFixed) : null);
variables: {
input: { findForm().vm.$emit('submit', { preventDefault: () => {} });
groupPath: TEST_GROUP_PATH,
addLabelIds, expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
title, mutation: createEpic,
description, variables: {
confidential, input: {
startDateFixed, groupPath: TEST_GROUP_PATH,
startDateIsFixed, addLabelIds,
dueDateFixed, title,
dueDateIsFixed, description,
confidential,
startDateFixed,
startDateIsFixed,
dueDateFixed,
dueDateIsFixed,
},
}, },
}, });
});
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