Commit 3b402949 authored by David O'Regan's avatar David O'Regan Committed by Ezekiel Kigbo

Clear add schedule form between creation

parent 46ee05ec
......@@ -125,6 +125,7 @@ export default {
}
this.$refs.addUpdateScheduleModal.hide();
this.$emit('scheduleCreated');
this.clearScheduleForm();
},
)
.catch((error) => {
......@@ -189,6 +190,11 @@ export default {
this.validationState.timezone = !isEmpty(this.form.timezone);
}
},
clearScheduleForm() {
this.form.name = '';
this.form.description = '';
this.form.timezone = {};
},
},
};
</script>
......
import { GlModal, GlAlert } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo';
import AddEditScheduleForm from 'ee/oncall_schedules/components/add_edit_schedule_form.vue';
import AddEditScheduleModal, {
i18n,
} from 'ee/oncall_schedules/components/add_edit_schedule_modal.vue';
......@@ -115,6 +116,7 @@ describe('AddScheduleModal', () => {
const findModal = () => wrapper.findComponent(GlModal);
const findAlert = () => wrapper.findComponent(GlAlert);
const findModalForm = () => wrapper.findComponent(AddEditScheduleForm);
describe('Schedule create', () => {
beforeEach(() => {
......@@ -164,6 +166,16 @@ describe('AddScheduleModal', () => {
expect(alert.exists()).toBe(true);
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', () => {
......
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