Commit 4ac79201 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '273797-multi-schedules-dry' into 'master'

Clear add schedule form between creation

See merge request gitlab-org/gitlab!60417
parents d40bd86c 3b402949
...@@ -125,6 +125,7 @@ export default { ...@@ -125,6 +125,7 @@ export default {
} }
this.$refs.addUpdateScheduleModal.hide(); this.$refs.addUpdateScheduleModal.hide();
this.$emit('scheduleCreated'); this.$emit('scheduleCreated');
this.clearScheduleForm();
}, },
) )
.catch((error) => { .catch((error) => {
...@@ -189,6 +190,11 @@ export default { ...@@ -189,6 +190,11 @@ export default {
this.validationState.timezone = !isEmpty(this.form.timezone); this.validationState.timezone = !isEmpty(this.form.timezone);
} }
}, },
clearScheduleForm() {
this.form.name = '';
this.form.description = '';
this.form.timezone = {};
},
}, },
}; };
</script> </script>
......
import { GlModal, GlAlert } from '@gitlab/ui'; import { GlModal, GlAlert } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import AddEditScheduleForm from 'ee/oncall_schedules/components/add_edit_schedule_form.vue';
import AddEditScheduleModal, { import AddEditScheduleModal, {
i18n, i18n,
} from 'ee/oncall_schedules/components/add_edit_schedule_modal.vue'; } from 'ee/oncall_schedules/components/add_edit_schedule_modal.vue';
...@@ -115,6 +116,7 @@ describe('AddScheduleModal', () => { ...@@ -115,6 +116,7 @@ describe('AddScheduleModal', () => {
const findModal = () => wrapper.findComponent(GlModal); const findModal = () => wrapper.findComponent(GlModal);
const findAlert = () => wrapper.findComponent(GlAlert); const findAlert = () => wrapper.findComponent(GlAlert);
const findModalForm = () => wrapper.findComponent(AddEditScheduleForm);
describe('Schedule create', () => { describe('Schedule create', () => {
beforeEach(() => { beforeEach(() => {
...@@ -164,6 +166,16 @@ describe('AddScheduleModal', () => { ...@@ -164,6 +166,16 @@ describe('AddScheduleModal', () => {
expect(alert.exists()).toBe(true); expect(alert.exists()).toBe(true);
expect(alert.text()).toContain(error); expect(alert.text()).toContain(error);
}); });
it('should clear the schedule form on a successful creation', () => {
mutate.mockResolvedValueOnce({});
findModal().vm.$emit('primary', { preventDefault: jest.fn() });
expect(findModalForm().props('form')).toMatchObject({
name: '',
description: '',
timezone: {},
});
});
}); });
describe('Schedule update', () => { describe('Schedule update', () => {
......
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