Commit 015aa1fc authored by Simon Knox's avatar Simon Knox

Merge branch 'fix-epic-date-change-without-user-input' into 'master'

Fix epic date changes without user input

See merge request gitlab-org/gitlab!75817
parents 7e0e61ea 813257fd
......@@ -124,6 +124,9 @@ export default {
isLoading() {
return this.$apollo.queries.issuable.loading || this.loading;
},
initialLoading() {
return this.$apollo.queries.issuable.loading;
},
hasDate() {
return this.dateValue !== null;
},
......@@ -271,10 +274,10 @@ export default {
<span class="collapse-truncated-title">{{ formattedDate }}</span>
</div>
<sidebar-inherit-date
v-if="canInherit"
v-if="canInherit && !initialLoading"
:issuable="issuable"
:is-loading="isLoading"
:date-type="dateType"
:is-loading="isLoading"
@reset-date="setDate(null)"
@set-date="setFixedDate"
/>
......
......@@ -17,8 +17,9 @@ export default {
type: Object,
},
isLoading: {
required: true,
required: false,
type: Boolean,
default: false,
},
dateType: {
type: String,
......@@ -31,6 +32,7 @@ export default {
return this.issuable?.[dateFields[this.dateType].isDateFixed] || false;
},
set(fixed) {
if (fixed === this.issuable[dateFields[this.dateType].isDateFixed]) return;
this.$emit('set-date', fixed);
},
},
......
......@@ -145,13 +145,20 @@ describe('Sidebar date Widget', () => {
${false} | ${SidebarInheritDate} | ${'SidebarInheritDate'} | ${false}
`(
'when canInherit is $canInherit, $componentName display is $expected',
({ canInherit, component, expected }) => {
async ({ canInherit, component, expected }) => {
createComponent({ canInherit });
await waitForPromises();
expect(wrapper.find(component).exists()).toBe(expected);
},
);
it('does not render SidebarInheritDate when canInherit is true and date is loading', async () => {
createComponent({ canInherit: true });
expect(wrapper.find(SidebarInheritDate).exists()).toBe(false);
});
it('displays a flash message when query is rejected', async () => {
createComponent({
dueDateQueryHandler: jest.fn().mockRejectedValue('Houston, we have a problem'),
......
......@@ -10,7 +10,7 @@ describe('SidebarInheritDate', () => {
const findFixedRadio = () => wrapper.findAll(GlFormRadio).at(0);
const findInheritRadio = () => wrapper.findAll(GlFormRadio).at(1);
const createComponent = () => {
const createComponent = ({ dueDateIsFixed = false } = {}) => {
wrapper = shallowMount(SidebarInheritDate, {
provide: {
canUpdate: true,
......@@ -18,11 +18,10 @@ describe('SidebarInheritDate', () => {
propsData: {
issuable: {
dueDate: '2021-04-15',
dueDateIsFixed: true,
dueDateIsFixed,
dueDateFixed: '2021-04-15',
dueDateFromMilestones: '2021-05-15',
},
isLoading: false,
dateType: 'dueDate',
},
});
......@@ -45,6 +44,13 @@ describe('SidebarInheritDate', () => {
expect(findInheritRadio().text()).toBe('Inherited:');
});
it('does not emit set-date if fixed value does not change', () => {
createComponent({ dueDateIsFixed: true });
findFixedRadio().vm.$emit('input', true);
expect(wrapper.emitted('set-date')).toBeUndefined();
});
it('emits set-date event on click on radio button', () => {
findFixedRadio().vm.$emit('input', true);
......
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